最近一直在研究微服务相关内容,通过对比各大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的安装过程,如果安装中大家有什么问题,可以一起留言讨论一下

基于CentOS 7.6安装及配置APISIX 3.0环境的更多相关文章

  1. 在 CentOS 7上安装并配置 Python 3.6 环境

    前言 按照此方法安装保证以下报错什么的统统都没有! 基础环境 系统:centos7.4 软件:python3 Retrying (Retry(total=0, connect=None, read=N ...

  2. 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:4.安装Oracle RAC FAQ-4.6.重新配置与缷载11R2 Grid Infrastructure

    1.[root@linuxrac1 ~]# /u01/app/oraInventory/orainstRoot.sh 2.[root@linuxrac2 ~]# /u01/app/oraInvento ...

  3. 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:3.安装Oracle RAC-3.1.安装并配置ASM驱动

    3.1.安装并配置ASM驱动 3.3.1.检查内核 [root@linuxrac2 etc]# uname -r 2.6.18-164.el5 下载以下rpm包(注意rpm包版本和Linux内核版本一 ...

  4. 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:2.搭建环境-2.7. 配置资源与参数

    2.7.配置资源与参数 2.7.1. 修改主机名称 [root@linuxrac1 ~]# cd /etc/sysconfig [root@linuxrac1 sysconfig]# vi netwo ...

  5. 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:2.搭建环境-2.6. 安装Oracle所依赖的必要包

    2.6. 安装Oracle所依赖的必要包 2.6.1. 检查Oracle所依赖的必要rpm包 [root@localhost /]#rpm -q binutils compat-libstdc elf ...

  6. 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:2.搭建环境-2.5. 配置网络

    2.5. 配置网络 2.5.1. 配置网络 Oracle Rac数据库涉及到公用网络和私有网络,因此要做网络划分和IP地址规划,下表列出了要安装的RAC数据库对应的IP地址.主机名以及网络连接类型: ...

  7. 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:2.搭建环境-2.4. 安装JDK

    2.4.安装JDK 2.4.1.准备JDK 在百度搜索:JDK下载 2.4.2.上传JDK put E:\软件安装文件\jdk-8u11-linux-x64.rpm /home/linuxrac1/D ...

  8. 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:2.搭建环境-2.3配置共享磁盘

    2.3.配置共享磁盘 2.3.1.创建共享磁盘 在cmd中进入WMware Workstation 10.0 安装目录: 1.创建存储Oracle Clusterware文件  (Oracle Clu ...

  9. 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:2.搭建环境-2.2安装操作系统CentOS5.4

    2.2. 安装操作系统CentOS5.4 两个虚拟机都安装,此步骤在创建虚拟机节点时: 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境所有链接: 1.资源 ...

  10. 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:4.安装Oracle RAC FAQ-4.1.系统界面报错Gnome

    1.错误信息:登录系统后,屏幕弹出几个错误对话框,无菜单.无按钮 GConf error: Failed to contact configuration server; some possible ...

随机推荐

  1. C# DataTable操作,转载

    DataTable 排序   DataRow[] rows = dataTable1.Select("", "ord asc");   DataTable t ...

  2. idea开发使用外置tomcat配置

    1. 添加依赖 <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId> ...

  3. CF1732A Bestie

    思路 观察数据\(n \le 20\) 直接暴力. 我们直接算所有数的\(GCD\),然后枚举\(1\)~\(n\)的每一个数要不要选,然后选的话,就把原来的\(GCD\)和当前枚举的数\(GCD\) ...

  4. IntelliJ IDEA常用插件

    Mybatis Log Plugin安装好插件后,在Tools工具栏中可以看到安装好的插件,点击即可打开相应窗口,在Debug时,相应的Sql语句即可输出到此窗口,方便查看.此插件相当好用,提升开发效 ...

  5. pragma pack(字节对齐用法)---C语言

    #pragma pack(4) typedef struct { char buf[3]; word a; }kk; #pragma pack() 对齐的原则是min(sizeof(word ),4) ...

  6. AI智能问答助手 AI智能批量文章生成器 网站优化SEO批量内容生成工具 原创文章生成软件

    <AI智能问答助手>   软件基于当下热门的OpenAI的ChatGPT技术,导入问题列表就可以批量生成对应的内容,内容质量高.原创度高.适合对内容生成需求量大的场景,如网站优化.广告文案 ...

  7. node使用multer进行文件上传

    开场白 在平时的业务中,我们很多使用都会有文件上传这个功能. 今天分享一下使用 node+element-ui实现一下文件上传. 请个人大佬指点一番~~~.批评的时候稍微轻一点. 毕竟我心里承受能力弱 ...

  8. 什么是RPA?

    RPA是Robotic Process Automation(机器人流程自动化)的简称,是以软件机器人及人工智能为基础的业务过程自动化科技.它让软件机器人自动处理大量重复的.基于规则的工作流程任务,能 ...

  9. JS兼容问题总结

    JS兼容问题总结 "标准浏览器"和"低版本浏览器(IE)"兼容写法 一.浏览器卷去的高度和宽度 var scrollTop = document.documen ...

  10. 【2019CCPC秦皇岛:A】Angle Beats 分类讨论 (unordered_map 加 hash)

    题意:n个给定点,q个询问点,每次询问给出一个坐标A,问从n中选定两个点B,C,有多少种方案使得ABC是个直角三角形. 思路:直角三角形能想的就那几个,枚举边,枚举顶点,这个题都行,写的枚举顶点的,A ...