首页 > 系统相关 >基于CentOS 7.6安装及配置APISIX 3.0环境

基于CentOS 7.6安装及配置APISIX 3.0环境

时间:2023-05-10 12:56:14浏览次数:36  
标签:http etcd CentOS 3.0 7.6 APISIX ETCD 安装 apisix

最近一直在研究微服务相关内容,通过对比各大API网关,发现新起之秀 APISIX无论从开源程度上来讲还是功能上,都拥有很大的优势。

经历了几天折磨一样的学习,目前在本地环境中配置成功了一套,以供自己留存吧,实在是网上的很多文章要么太老了,要么就是乱写一通。

 

APISIX官方网址:https://apisix.apache.org/

ETCD官方网址:https://etcd.io/

 

1、安装ETCD(分布式Key-Value存储系统)

根据apisix提供的官方网档,执行以下脚本就可以了:

wget https://github.com/etcd-io/etcd/releases/download/v3.5.8/etcd-v3.5.8-linux-amd64.tar.gz
tar -xvf etcd-v3.5.8-linux-amd64.tar.gz && \
  cd etcd-v3.5.8-linux-amd64 && \
sudo cp -a etcd etcdctl /usr/bin/

 这里的安装时间因为国内的原因,可能需要执行很长时间,我们同样也可以将文件提前下载好,丢到CentOS服务器上,再执行解压缩就可以了。

2、配置ETCD

不知道是我找的资料不对,还是官方精简了一些,本打算使用 systemctl 安装ETCD,但是各种提示报错,经过了大量的资料搜索和文章的研究与尝试,这里需要以下步骤进行安装配置:

(1)创建 /etc/etcd/etcd.service 服务配置文件,并编辑内容如下(本实例为单机模式部署):

ETCD_NAME=etcd
ETCD_DATA_DIR=/etc/etcd/data

ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379
ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380

ETCD_ADVERTISE_CLIENT_URLS=http://0.0.0.0:2379
ETCD_INITIAL_ADVERTISE_PEER_URLS=http://0.0.0.0:2380
ETCD_INITIAL_CLUSTER_STATE=new
ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster

编写完成后,保存即可。

(2)以服务方式启用及启用加载自启

systemctl start etcd
systemctl enable etcd

到这里,整个ETCD服务就安装完成了

3、安装APISIX

这一步操作很简单,直接根据官方文档来操作就可以了,安装说明:https://apisix.apache.org/docs/apisix/installation-guide/

(1)安装OpenRestry并且安装APISIX包

sudo yum install -y https://repos.apiseven.com/packages/centos/apache-apisix-repo-1.0-1.noarch.rpm

(2)添加APISIX YUM包源

sudo yum-config-manager --add-repo https://repos.apiseven.com/packages/centos/apache-apisix.repo

(3)执行APISIX安装

# 默认安装
sudo yum install apisix

# 指定版本安装
sudo yum install apisix-3.3.0

安装完APISIX我们先不要启动,先去 /usr/local/apisix/conf/config.yaml中修改对应的文件配置,我这例子的配置如下:

#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# If you want to set the specified configuration value, you can set the new
# in this file. For example if you want to specify the etcd address:
#
# deployment:
#   role: traditional
#   role_traditional:
#     config_provider: etcd
#   etcd:
#     host:
#       - http://127.0.0.1:2379
#
# To configure via environment variables, you can use `${{VAR}}` syntax. For instance:
#
# deployment:
#   role: traditional
#   role_traditional:
#     config_provider: etcd
#   etcd:
#     host:
#       - http://${{ETCD_HOST}}:2379
#
# And then run `export ETCD_HOST=$your_host` before `make init`.
#
# If the configured environment variable can't be found, an error will be thrown.
#
# Also, If you want to use default value when the environment variable not set,
# Use `${{VAR:=default_value}}` instead. For instance:
#
# deployment:
#   role: traditional
#   role_traditional:
#     config_provider: etcd
#   etcd:
#     host:
#       - http://${{ETCD_HOST:=localhost}}:2379
#
# This will find environment variable `ETCD_HOST` first, and if it's not exist it will use `localhost` as default value.
#

apisix:
  node_listen: 8000

deployment:
  role: traditional
  role_traditional:
    config_provider: etcd
  etcd:
    host:
      - http://127.0.0.1:2379
  admin:
    admin_key:
      - name: admin
        key: edd1c9f034335f136f87ad84b625c8f1  # using fixed API token has security risk, please update it when you deploy to production environment
        role: admin

这里要注意的是,apisix: node_listen 是不存在的,你要自己添加上并指定一下需要绑定的端口,并且在etcd 下的host 指定你ETCD服务器安装的位置(推荐使用内网,不要对外开放端口哈)

这里配置完成后,我们就可以使用systemctl启动APISIX咯

# 使用systemctl 将APISIX安装为服务
systemctl start apisix

# 添加服务开机自启动
systemctl enable apsix

启动成功后,通过访问网址 http://127.0.0.1:8000 会提示404 Route Not Found的字样,这时,我们的APISIX服务就安装完成咯!

4、安装APISIX-DASHBOARD(管理控制面板)

同样的,我们根据官方给的文档进行安装,文档地址:https://apisix.apache.org/docs/dashboard/install/

因为我们使用的CENTOS直接安装,那么我们执行如下的BASH脚本即可:

sudo yum install -y https://github.com/apache/apisix-dashboard/releases/download/v3.0.1/apisix-dashboard-3.0.1-0.el7.x86_64.rpm

安装需要一定的时间,安装完成后记得去 /usr/local/apisix/dashboard/conf/conf.yaml 文件中修改对应的配置ETCD地址及管理员、用户的账号及密码!

以上操作完成后,同样的执行以下命令,apisix-dashboard也就启动完成,我这里默认开的是9000端口,那么完成后通过浏览器访问 http://127.0.0.1:9000 就可以使用咯

# 使用systemctl 将APISIX-DASHBOARD安装为服务
systemctl start apisix-dashboard

# 添加服务开机自启动
systemctl enable apsix-dashboard

 

 

以上所有便是APISIX在centos 7.6的安装过程,如果安装中大家有什么问题,可以一起留言讨论一下

 

标签:http,etcd,CentOS,3.0,7.6,APISIX,ETCD,安装,apisix
From: https://www.cnblogs.com/briny/p/17387663.html

相关文章

  • ArcGIS Pro 3.0.1破解版安装步骤
    记录ArcGISPro3.0.1破解版安装步骤。1、先安装windowsdesktop组件:windowsdesktop-runtime-6.0.5-win-x64.exe2、安装ArcGISPro3.0软件:ArcGISPro_30_182209.exe等待安装完成: 安装完成后先不运行。3、安装3.0.1升级包:ArcGIS_Pro_301_182232.msp 同样,安装完成后先不运......
  • Centos7使用s3fs-fuse挂载minio对象存储实践
    Centos7使用s3fs-fuse挂载minio对象存储实践事前准备主机可以访问到对象存储API、例如minio默认的9000端口主机安装好s3fs软件已在minio上创建存储桶安装s3fs(本文使用centos发行版)其他发行版本教程请参考Github官网Github:https://github.com/s3fs-fuse/s3fs-fus......
  • 解决CentOS 7出现docker-compose: command not found
    解决CentOS7出现docker-compose:commandnotfound1.安装docker-compose既然使用了docker-compose那自然得安装了在GitHub上拉取过慢,建议在国内源DaoCloud中拉取:curl-Lhttps://get.daocloud.io/docker/compose/releases/download/1.29.2/docker-compose-`uname-s`-`unam......
  • 安装docker和docker-compose的shell脚本(Centos7版本)
    在执行脚本之前,我们需要先做两件事:避免防火墙与docker产生冲突,应先关闭防火墙。shell#去掉防火墙的开机自启动systemctldisablefirewalld.service#关闭防火墙systemctlstopfirewalld.service国内拉取dockerhub中的镜像速度一般都很慢,现在有一种方法可以提高......
  • CentOS /RHEL 系统更新安全补丁的方法
    在 Linux 系统上,其中一个最重要的需求就是保持定期更新最新的安全补丁,或者为相应的Linux版本更新可用的安全补丁。在这篇文章中,我们将分享如何在 CentOS/RHEL7/6版本中设置在需要时自动更新重要的安全补丁。和它同一家族的其它Linux版本(Fedora或ScientificLinux)中......
  • VMware之Centos7环境搭建
    VMware安装VMware安装步骤forWindows傻瓜式安装,下一步下一步即可,再不会直接百度细节:优先装VM16,其次VM15(如果开机蓝屏,换版本即可),本质没太大区别验证成功去你的windows网络连接中,能看到VMNet1和VMNet8两个网卡即可 VmwareforMac安装直接下一......
  • Centos 安装 supervisord服务
    安装supervisord执行如下命令安装supervisordyuminstallepel-release-yyuminstallsupervisor-y设置开机启动supervisordsystemctlenablesupervisord启动supervisordsystemctlstartsupervisord配置supervisord默认配置文件位置:/etc/supervisord.conf默......
  • 【2023.05.09】厦门无线电A证考试体验(无线电台执照)
    考这个证书主要是上班事情不多,所以业余时间学了一下无线电三月份去厦门无线电管理局考试,三天前接到无管局接到电话今天才刚拿到证,也就是说考完可能要等一个月半才能拿到证书进去无管局,会先在会议室抽号码排队,会议室收拾得很干净,奖牌也很多因为我和同学一起去,所以我们是连号......
  • centos7设置nginx开机自启
    3、配置nginx开机启动切换到/lib/systemd/system/目录,创建nginx.service文件vimnginx.service#cd/lib/systemd/system/#vimnginx.service文件内容如下:[Unit]Description=nginxAfter=network.target[Service]Type=forkingExecStart=/usr/local/nginx/sbin/ngin......
  • centos中 hisat2 软件的安装
     001、下载安装包[root@PC1hisat2]#wgethttps://github.com/DaehwanKimLab/hisat2/archive/refs/tags/v2.2.1.tar.gz 002、tar-xavfv2.2.1.tar.gz##解压cdhisat2-2.2.1/make##编译 003、测试软件./hisat2--versio......