APISIX安装记录

依赖:

  1. etcd : 版本必须为v3.4以上,不支持3.4以下的版本

  1. openresty

  1. luarocks

etcd安装

https://github.com/etcd-io/etcd/releases/

访问以上页面,根据自己的系统选择相应的安装包进行下载。解压安装包,进入安装目录,

执行 nohup ./etcd --name infra1 --listen-client-urls http://172.16.254.131:2379 --advertise-client-urls http://172.16.254.131:2379 &根据自己的服务器地址和端口启动etcd。

后台运行 'nohup ./etcd --name infra1 --listen-client-urls http://172.16.254.129:2379 --advertise-client-urls http://172.16.254.129:2379 &'根据自己的服务器地址和端口启动etcd。

报错解决

在arm架构的服务器中会出现etcd on unsupported platform without ETCD_UNSUPPORTED_ARCH=arm64 set报错。输入export ETCD_UNSUPPORTED_ARCH=arm64 命令之后再次执行启动命令方可解决

openresty 安装

openresty依赖openssl,需要提前安装openssl

openssl 安装

下载源码包

openssl-1.1.1k.tar.gz

tar -zxvf openssl-version.tar.gz
cd openssl-version/
./config --prefix=/usr/local/openssl
make
make install

报错

报错1
     wget https://www.cpan.org/src/5.0/perl-5.30.1.tar.gz
     tar -xzf perl-5.30.1.tar.gz
     cd perl-5.30.1
     ./Configure -des -Dprefix=$HOME/localperl
     make
     make install
报错2

安装时一直报Go find a public domain implementation or fix your PATH setting!是因为安装系统的时候使用的是最小化mini安装,系统没有安装make。直接yum安装下即可:yum -y install gcc automake autoconf libtool make


openresty 安装

https://openresty.org/cn/download.html

下载源码包

openresty-1.19.3.2.tar.gz

tar -zxvf openresty-version.tar.gz
cd openresty-version

## --with 是启用一些插件 
## --without 是禁用一些插件
./configure --with-luajit \
            --without-http_redis2_module \
            --with-http_iconv_module \
            --with-http_stub_status_module \
            --with-http_realip_module \
            --with-http_v2_module \
            --with-openssl=/usr/local/openssl  
make
make install 

报错

报错1

报错 ‘/bin/sh: line 2: ./config: No such file or directory’

解决该问题,修改配置文件/bundle/nginx-1.11.2/auto/lib/openssl/conf中

/.openssl删除掉,也就是避免了找路径的时候找.openssl这个路径

解决问题后重新执行上一步的./configure
报错2

需要安装pcre的devel包,pcre-devel。使用yum安装即可:(以下命令还带有ssl、zlib等依赖的安装)

yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
报错3

是CentOS 8没有安装epel源的问题。安装epel源后问题解决。

yum install epel-release
报错3

需要指定源码路径。因为openresty(确切的说,是nginx)依赖pcre做正则引擎,还有要用openssl做安全引擎。所以,先要安装pcre和openssl。千万注意,要用源码,在安装openresty的时候,通过--with-<module>指定源码路径。

./configure --prefix=/usr/local/openresty --with-pcre=/opt/pcre2-10.23 --with-openssl=/opt/openssl-1.1.0e

仍然报错,就直接去nginx下执行 ./configure。手动把nginx给解析了

配置openresty环境变量

vim /etc/profile

#文件末尾添加
export PATH=$PATH:/user/local/openresty/bin:/usr/local/openresty/nginx/sbin

source /etc/profile

luarocks 安装

Source code(tar.gz)

下载源码包

tar -zxvf luarocks-3.4.0.tar.gz

cd luarocks

./configure --with-lua=/usr/local/openresty/luajit

make build

make install

apisix安装

wget https://downloads.apache.org/apisix/2.12.0/apache-apisix-2.12.0-src.tgz
tar zxvf apache-apisix-2.12.0-src.tgz -C apisix-2.12.0
LUAROCKS_SERVER=https://luarocks.cn make deps
### Apisix 安装部署教程 #### 使用 Docker 部署 Apache APISIX 对于希望快速上手并测试 APISIX 功能的开发者来说,Docker 是一种便捷的选择。只需几条命令即可完成环境搭建[^5]。 ```bash docker pull apache/apisix:latest docker run -it --rm \ --name apisix \ -p 9080:9080 \ -p 9443:9443 \ apache/apisix:latest ``` 上述命令会拉取最新版的官方镜像,并启动容器,在本地映射 HTTP 和 HTTPS 端口用于访问 API 网关服务。 #### Kubernetes 上使用 Helm Chart 部署 为了实现更灵活高效的资源管理和调度,推荐在生产环境中采用基于 Kubernetes 的部署方式。Helm 图表简化了复杂应用程序的一键式安装过程,允许用户自定义参数来适应不同场景需求。 ```yaml # values.yaml 示例片段 replicaCount: 2 image: repository: apache/apisix tag: "latest" service: type: LoadBalancer port: 9080 configProvider: type: etcd endpoints: - http://etcd.default.svc.cluster.local:2379 ``` 执行如下指令以应用配置文件: ```bash helm repo add apache https://apache.github.io/incubator-apisix-helm-chart helm install my-release apache/apisix -f values.yaml ``` 这将依据指定设置自动创建所需的服务实例及相关组件,极大地方便运维人员的操作维护工作。 #### 关于配置中心的选择 默认情况下,APISIX 将依赖 Etcd 来存储路由规则和其他动态数据。Etcd 凭借其出色的性能表现以及广泛的社区支持成为首选方案之一;不过根据实际业务特点也可以考虑其他替代品如 Consul 或 Nacos 等[^4]。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值