一、安装依赖
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
添加OpenResty源
yum install yum-utils
yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo
安装OpenResty
yum install -y openresty
二、安装 etcd
下载etcd并解压
tar -zxvf etcd-v3.4.15-linux-amd64.tar.gz
环境配置
cd etcd-v3.4.15-linux-amd64/
mv etcd /usr/local/bin/
mv etcdctl /usr/local/bin/
修改环境变量
vim /etc/profile
在文件最后添加:
export ETCDCTL_API=3
变量生效:
source /etc/profile
查看etcd版本
etcdctl version
---------------
etcdctl version: 3.4.15
API version: 3.4
创建etcd配置文件
mkdir -p /var/lib/etcd/
cat <<EOF | sudo tee /etc/etcd.conf
#节点名称
ETCD_NAME=$(hostname -s)
#数据存放位置
ETCD_DATA_DIR=/var/lib/etcd/
EOF
创建开机启动文件
cat <<EOF | sudo tee /etc/systemd/system/etcd.service
[Unit]
Description=Etcd Server
Documentation=https://github.com/coreos/etcd
After=network.target
[Service]
User=root
Type=notify
#这个文件特别关键,etcd使用的环境变量都需要通过环境变量文件读取
EnvironmentFile=-/etc/etcd.conf
ExecStart=/usr/local/bin/etcd
Restart=on-failure
RestartSec=10s
LimitNOFILE=40000
[Install]
WantedBy=multi-user.target
EOF
重新加载配置 && 开机启动 && 启动etcd
systemctl daemon-reload && systemctl enable etcd && systemctl start etcd
开机启动设置状态,状态enabled
systemctl list-unit-files etcd.service
--------------------------------------
UNIT FILE STATE
etcd.service enabled
1 unit files listed.
查看etcd状态
systemctl show etcd.service
检查2379端口是否成功启动
netstat -an |grep 2379
三、安装Apisix
1.下载安装apisix
yum install -y https://github.com/apache/apisix/releases/download/2.5/apisix-2.5-0.x86_64.rpm
如果下载很慢,可以在Windows本机下载后传送至服务器端,并由以下命令进行安装
sudo yum install -y apisix-2.5-0.x86_64.rpm
2.检查 apisix的版本号
apisix version
3.启动apisix(etcd>=3.4)
apisix start
4.安装dashboard
yum install -y https://github.com/apache/apisix-dashboard/releases/download/v2.6/apisix-dashboard-2.6-0.x86_64.rpm
如果下载很慢,可以在Windows本机下载后传送至服务器端,并由以下命令进行安装
sudo yum install -y dashboard-2.6-0.x86_64.rpm
5.配置dashboard
cd /usr/local/apisix/dashboard/conf
vim conf.yaml
修改host为0.0.0.0并注释掉allow_list
6.启动并访问Apisix
nohup manager-api -p /usr/local/apisix/dashboard/ &
访问地址: http://127.0.0.1:9000
登录账号/密码:admin/admin