Apisix

1
sudo yum install -y https://repos.apiseven.com/packages/centos/apache-apisix-repo-1.0-1.noarch.rpm
1
sudo yum-config-manager --add-repo https://repos.apiseven.com/packages/centos/apache-apisix.repo
1
2
3
4
5
6
7
8
# 查看仓库中最新的 apisix 软件包的信息
sudo yum info -y apisix

# 显示仓库中现有的 apisix 软件包
sudo yum --showduplicates list apisix

# 安装最新的 apisix 软件包
sudo yum install apisix
1
2
3
4
5
6
7
8
ETCD_VERSION='3.4.13'
wget https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/etcd-v${ETCD_VERSION}-linux-amd64.tar.gz

tar -xvf etcd-v${ETCD_VERSION}-linux-amd64.tar.gz && \
cd etcd-v${ETCD_VERSION}-linux-amd64 && \
sudo cp -a etcd etcdctl /usr/bin/

nohup etcd >/tmp/etcd.log 2>&1 &

vim /usr/local/apisix/conf/config-default.yaml

apisix:

node_listen: # This style support multiple ports

80

allow_admin: # http://nginx.org/en/docs/http/ngx_http_access_module.html#allow

​ 0.0.0.0/0

1
apisix init
1
apisix test
1
apisix start
1
2
# stop Apache APISIX server gracefully
apisix quit

执行强制停机的命令如下所示:

1
2
# stop Apache APISIX server immediately
apisix stop

apisix-dashboard

1
sudo yum install -y https://github.com/apache/apisix-dashboard/releases/download/v2.10.1/apisix-dashboard-2.10.1-0.el7.x86_64.rpm
1
2
3
4
5
# run dashboard in the shell
sudo manager-api -p /usr/local/apisix/dashboard/

# or run dashboard as a service
systemctl start apisix-dashboard

vim /usr/local/apisix/dashboard/conf/conf.yaml

Allow all IPv4 access

By default, the IPv4 range of 127.0.0.0/24 is allowed to access APISIX Dashboard. If you want to allow all IPv4 access, then just configure conf.allow_list in the configuration file of conf/conf.yaml as follows:

1
2
3
conf:
allow_list:
- 0.0.0.0/0

Allow all IPv6 access

By default, the IPv6 range of ::1 is allowed to access APISIX Dashboard. If you want to allow all IPv6 access, then just configure conf.allow_list in the configuration file of conf/conf.yaml as follows:

1
2
3
conf:
allow_list:
- ::/0

Allow all IP access

If you want to allow all IPs to access APISIX Dashboard, you only need to do the following configuration in the configuration file of conf/conf.yaml:

1
2
conf:
allow_list:

自动备份

自动备份

#!/bin/bash
#时间戳,用来区分不同备份
timestamp=date +%Y%m%d-%H%M%S
#备份到哪个文件夹
back_dir=“/root/etcd_db_bak”
#etcd集群列表
endpoints=“https://127.0.0.1:2379
#etcd证书路径
#cert_file=“/etc/etcd/ssl/etcd.pem”
#etcd证书的key路径
#key_file=“/etc/etcd/ssl/etcd-key.pem”
#ca证书路径
#cacert_file=“/etc/kubernetes/ssl/ca.pem”

mkdir -p $back_dir
ETCDCTL_API=3 /usr/bin/etcdctl
snapshot save back_dir/snapshot_timestamp.db
#–endpoints="{endpoints}" \ #--cert=cert_file
#–key=key_file \ #--cacert=cacert_file
#snapshot save back_dir/snapshot_timestamp.db

数据恢复

关闭etcd
恢复数据之前需要先将etcd的旧工作目录

执行恢复命令
ETCDCTL_API=3 etcdctl --data-dir=/root/default.etcd snapshot restore /root/etcd_db_bak/snapshot_20220427-021136.db

启动etcd
nohup etcd >/tmp/etcd.log 2>&1 &
重启apisix-dashboard
systemctl restart apisix-dashboard