apisix集群安装指南

1、apisix 安装

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


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

(3)yum install apisixls

2、etcd安装

wget https://github.com/etcd-io/etcd/releases/download/v3.4.18/etcd-v3.4.18-linux-amd64.tar.gz

tar -xvf etcd-v3.4.18-linux-amd64.tar.gz

3、apisix dashboard安装

yum install -y https://github.com/apache/apisix-dashboard/releases/download/v2.10.1/apisix-dashboard-2.10.1-0.el7.x86_64.rpm

版本号

apisix 2.11.0

dashboard 2.10.1

etcd 3.4.18

openresty 1.19.9.1

启动顺序

nohup etcd &

nohup manager-api &

apisix start

集群高可用方案

二.Etcd集群安装

1、4 etcd安装

wget https://github.com/etcd-io/etcd/releases/download/v3.4.18/etcd-v3.4.18-linux-amd64.tar.gz

tar -xvf etcd-v3.4.18-linux-amd64.tar.gz

2、脚本编写(重点)

(1)启动脚本

#集群机器节点命名

NAME_1=machine-1

NAME_2=machine-2

NAME_3=machine-3

#集群节点内网ip

HOST_1=172.26.77.1

HOST_2=172.26.77.0

HOST_3=172.26.76.252

#启动集群

CLUSTER=${NAME_1}=http://${HOST_1}:2380,${NAME_2}=http://${HOST_2}:2380,${NAME_3}=http://${HOST_3}:2380

#内网ip

THIS_IP=${HOST_2}

THIS_NAME=${NAME_2}

./etcd --auto-compaction-retention=1 --data-dir=/data/etcd --name ${THIS_NAME} --initial-advertise-peer-urls http://${THIS_IP}:2380 --listen-peer-urls http://${THIS_IP}:2380 --advertise-client-urls http://${THIS_IP}:2379 --listen-client-urls http://${THIS_IP}:2379 --initial-cluster ${CLUSTER} --initial-cluster-state new

(2)停止脚本

kill -9 $(ps -A | grep etcd | awk '{print $1}')

2、etcd集群安装遇到的问题:

(执行集群命令需要制定endpoints执行)

for ex查看当前member list

执行etcdctl member list 报错127.0.0.1:2379拒绝连接,由于启动脚本制定通过内网ip访问执行命令,

查看当前节点状态

etcdctl --endpoints 172.26.77.1:2379,172.26.77.0:2379,172.26.76.252:2379 endpoint status --write-out=table

(3)apisix配置设置

修改apisix 配置文件config-default.yaml

修改配置文件中etcd配置

etcd:

host: # it's possible to define multiple etcd hosts addresses of the same etcd cluster.

- "http://172.26.77.1:2379"

- "http://172.26.77.0:2379"

- "http://172.26.76.252:2379"

(4)apisix dashbodard 配置

修改config.yaml配置文件


(5)模拟apisix etcd 高可用场景

节点1 172.26.77.1:2380 从节点

节点2 172.26.77.0:2380 主节点

节点3 172.26.76.252:2380 从节点


杀死etcd主节点进程,etcd自动选举出新的主节点


3、keepalived安装

keepalived在apisix 集群中提供了节点健康检查、故障发现自动转移高可用方案,避免出现单点故障导致服务不可用

架构图:

(1)安装keepalived

分别在主机1 和主机2安装keepalived

yum install keepalived

(2)keepalived 配置vip

(3)keepalived 脚本配置

(4)keepalive 主备节点配置

(阿里云默认ECS不支持Vip,需要提工单说明开通Vip )

你可能感兴趣的:(apisix集群安装指南)