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
03-22
### APISIX 入门指南 APISIX 是一个高性能、可扩展的开源 API 网关,支持动态路由、负载均衡、服务发现等功能。以下是关于 APISIX 安装、配置以及使用的详细介绍。 --- #### 一、安装方式 APISIX 提供多种安装方法,包括通过 Docker Compose 和 Standalone 方式部署: 1. **Docker Compose 部署** 用户可以通过 Docker Compose 文件快速启动 APISIX 及其依赖的服务(如 etcd)。etcd 被用来存储 APISIX 的路由、插件等相关配置信息[^1]。以下是一个简单的 `docker-compose.yml` 示例文件: ```yaml version: '3' services: apisix: image: apache/apisix:latest ports: - "9080:9080" - "9443:9443" environment: - ETCD_HOST=etcd etcd: image: bitnami/etcd:latest ports: - "2379:2379" ``` 2. **Standalone 部署** 如果用户希望单独运行 APISIX 并手动管理配置文件,则可以编辑 `apisix.yaml` 来完成初始化设置。例如,在该文件中添加 Vault 插件的支持时,需指定如下字段[^2]: ```yaml secrets: - id: vault/1 prefix: apisix token: root uri: 127.0.0.1:8200 ``` --- #### 二、基本配置示例 为了更好地理解如何使用 APISIX 进行动态路由管理和插件启用,下面提供几个常见的配置场景。 1. **创建路由规则** 下面是一条典型的 HTTP 请求转发到上游服务器的 JSON 配置命令: ```bash curl http://127.0.0.1:9080/apisix/admin/routes/1 \ -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "uri": "/hello", "upstream": { "type": "roundrobin", "nodes": { "127.0.0.1:1980": 1 } } }' ``` 上述代码定义了一个 `/hello` URI,并将其请求流量分发至本地地址 `127.0.0.1:1980` 处理。 2. **启用限流插件** 若要对特定接口实施访问频率控制,可通过以下 JSON 数据结构实现: ```json { "plugins": { "limit-count": { "count": 2, "time_window": 60, "rejected_code": 503, "key_type": "var", "key": "remote_addr" } }, "uri": "/limited-resource" } ``` 此处设置了每分钟最多允许两次来自同一 IP 地址的请求访问路径 `/limited-resource`。 --- #### 三、主要功能概述 APISIX 不仅提供了基础的反向代理能力,还集成了丰富的特性来满足现代微服务体系下的需求: - 动态路由调整无需重启服务即可生效; - 支持多协议传输(HTTP, WebSocket, TCP/UDP); - 内建众多开箱即用的插件库(认证鉴权、日志记录、性能监控等); - 易于集成第三方工具和服务(Prometheus, Kafka, Redis 等)。 ---
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值