目录
(1).部署etcd集群
(2).部署apisix集群
1.安装apisix集群
A1.centos部署apisix的准备工作
A2.amazon linux部署apisix的准备工作
A3.部署apisix
2.apisix配置文件
3.启动apisix集群
4.验证etcd中的apisix数据
(3).部署apisix-dashboard
(4).参考资料
(1).部署etcd集群
3节点集群部署餐参考:
etcd-1:部署etcd集群
(2).部署apisix集群
1.安装apisix集群
直接按照官方建议:RPM包方式。
Installation via RPM Package(CentOS 7)
This installation method is suitable for CentOS 7, please run the following command to install Apache APISIX.
sudo yum install -y https://github.com/apache/apisix/releases/download/2.8/apisix-2.8-0.x86_64.rpm
但是通过这种方式依赖openresty:
openresty选择最新版:
先装openresty的依赖包:
yum install pcre-devel openssl-devel gcc curl -y
找到openresty1.19.9.1在centos下的yum源并装载:
A1.centos部署apisix的准备工作
https://openresty.org/cn/linux-packages.html#centos
# add the yum repo:
wget https://openresty.org/package/centos/openresty.repo
vim /etc/yum.repos.d/openresty.repo
[openresty]
name=Official OpenResty Open Source Repository for CentOS
baseurl=https://openresty.org/package/centos/releasever/basearch
skip_if_unavailable=False
gpgcheck=1
repo_gpgcheck=0
gpgkey=https://openresty.org/package/pubkey.gpg
enabled=1
enabled_metadata=1
# update the yum index:
sudo yum check-update
aliyun竟然不识别:openresty.org
我通过手动加host解决:
182.92.62.145 openresty.org
然后就可以像下面这样安装软件包,比如 openresty:
sudo yum install -y openresty
如果你想安装命令行工具 resty,那么可以像下面这样安装 openresty-resty 包:
sudo yum install -y openresty-resty
A2.amazon linux部署apisix的准备工作
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://openresty.org/package/amazon/openresty.repo
然后你就可以像下面这样安装包了,比如说安装 openresty:
sudo yum install -y openresty
如果想安装 resty 命令行工具,则像下面这样安装 openresty-resty 软件包:
sudo yum install -y openresty-resty
A3.部署apisix
再次yum安装apisix:
sudo yum install -y https://github.com/apache/apisix/releases/download/2.8/apisix-2.8-0.x86_64.rpm
默认安装在目录:
/usr/local/apisix
2.apisix配置文件
主要是指定etcd的集群地址:
vim /usr/local/apisix/conf/config.yaml
开启prometheus:
plugin_attr:
prometheus:
export_addr:
ip: 本机IP (如果不配置,其他机器无法访问)
port: 9091
etcd配置:
etcd:
host:
- http://ip0:2379
- http://ip1:2379
- http://ip2:2379
prefix: "/apisix-user" (表示这个apisix的集群配置放在etcd的哪个节点下,所以apisix-dashboard也要配置这个指向)
3.启动apisix集群
rm -rf /usr/local/apisix/logs
mkdir -p /app/logs/apisix
ln -s /app/logs/apisix /usr/local/apisix/logs
启动命令:
systemctl start apisix
终止命令:
systemctl stop apisix
4.验证etcd中的apisix数据
etcdctl get / --prefix --keys-only
(3).部署apisix-dashboard
下载apisi-dashboard rpm:
https://github.com/apache/apisix-dashboard/releases
wget https://github.com/apache/apisix-dashboard/releases/download/v2.7.1/apisix-dashboard-2.7.1-0.x86_64.rpm
yum install -y apisix-dashboard-2.7.1-0.x86_64.rpm
默认安装到目录:
/usr/local/apisix/dashboard
修改配置文件:/usr/local/apisix/dashboard/conf/conf.yaml
(4).参考资料
1.apisix官方安装文档
https://github.com/apache/apisix/blob/master/docs/en/latest/how-to-build.md
2.apisix-dashboard官方安装文档
https://github.com/apache/apisix-dashboard/blob/master/docs/en/latest/deploy-with-docker.md
3.apisix-config
https://github.com/apache/apisix-dashboard/blob/1fa139f5316805f6f2ae765434ab47615256bc3d/api/conf/conf.yaml
4.apisix配置详解
https://blog.csdn.net/yanshanlangren/article/details/108648626