apisix 容器安装

Posted lucidar

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了apisix 容器安装相关的知识,希望对你有一定的参考价值。

1. 按照官方文档进行docker容器安装,安装完成后启动报错,关键错误日志如下:

apisix | 2023/05/25 06:36:35 [error] 7#7: *205 [lua] resolver.lua:80: parse_domain(): failed to parse domain: etcd-server, error: failed to query the DNS server: dns server error: 3 name error, context: ngx.timer
apisix | 2023/05/25 06:36:35 [warn] 7#7: *205 [lua] v3.lua:245: _request_uri(): http://etcd-server:2379: failed to parse domain: failed to query the DNS server: dns server error: 3 name error. Retrying, context: ngx.timer
...
apisix | 2023/05/25 06:36:36 [error] 34#34: *115 [lua] config_etcd.lua:628: no healthy etcd endpoint available, next retry after 8s, context: ngx.timer

2. 查阅官方Issue

  https://github.com/apache/apisix/issues/8800,若是luaJit的bug,已经修复。然后按照官方文档 安装最新版apisix-3.3.0,依然报错。按照Issue中的说法,需要自己rebuild的apisix-base. 

 3. 然后下载apisix-build-tools,在虚拟机中进行build

4. 整个build过程是在docker容器中进行,并需要不断从互联网下载各种包、库以及github代码,而且需要容器能够连接互联网(需梯子)。

  build之前需要修改构建脚本添加VPN代理:

   修改build-apisix-base.sh,在开始从github仓库下载代码之前,添加VPN代理:  

export https_proxy=http://192.168.144.129:7890 http_proxy=http://192.168.144.129:7890 all_proxy=socks5://192.168.144.129:7890

    export https_proxy=http://192.168.144.129:7890 http_proxy=http://192.168.144.129:7890 all_proxy=socks5://192.168.144.129:7890

    192.168.144.129为运行VPN软件的宿主机的IP地址,你的虚拟机要能够访问到(即虚拟机与宿主机需要互通)。

  在 cd grpc-client-nginx-module-$grpc_client_nginx_module_ver || exit 1 这一行后面,添加如下代码:

sed -i \'/#!\\/usr\\/bin\\/env\\sbash/a\\export https_proxy=http://192.168.144.129:7890 http_proxy=http://192.168.144.129:7890 all_proxy=socks5://192.168.144.129:7890\' install-util.sh
sed -i \'/install-util.sh\\sinstall_go/a\\\\tPATH="$(PATH):/usr/local/go/bin" go env -w GOPROXY=https://goproxy.io,direct\' Makefile

  第一行是在install-util.sh中添加代理,第二行是为go设置环境变量GOPROXY (go语言下载包时使用的代理)

5. 执行构建:

  make package type=rpm app=apisix-base version=1.21.4.1.8 image_base=centos image_tag=7

  注意:version参数,必须与apisix-3.3.0 依赖的版本一致,不一致会导致rpm包无法安装。

apisix安装过程和坑

参考技术A 参考资料:

添加OpenResty源

安装OpenResty

yum installe etcd也可以安装,你需要yum list etcd 先看看是不是3.4以上。

如果你是x86/centos,需要安装amd64的版本。

etcd默认端口是2379
如果起不来,那么你需要补etcd的配置和etcd.service,按照:
手动安装etcd和配置 来操作。
确保所需的所有端口(默认的 9080/9443/2379);可以通过

来查找端口占用情况,并停止对方,以方便etcd启动;如果对方不方便停止,那么就修改etcd的端口吧;

检查 APISIX 的版本号:

启动 APISIX:
必须依赖etc>=3.4

dashboard需要比apisix高0.1个版本。apisix=2.5,那么dashboard就是2.6。

进入dashboard目录

修改conf.yaml

$ vim conf.yaml

修改host为0.0.0.0并注释掉allow_list

在浏览器输入 http://hostip:9000 ,默认登录用户密码均为admin

登录成功进入主界面

为了方便管理,写个脚本来启停:
start.sh

以上是关于apisix 容器安装的主要内容,如果未能解决你的问题,请参考以下文章

APISIX在CentOS7下安装使用

docker 安装配置 apisix 网关服务

微服务网关 APISIX 群集配置指南

apisix安装过程和坑

体验 Apache APISIX

apisix在k8s上的实践