安装依赖
如果当前系统没有安装 OpenResty,请使用以下命令来安装 OpenResty 和 APISIX 仓库:
sudo yum install -y https://repos.apiseven.com/packages/centos/apache-apisix-repo-1.0-1.noarch.rpm
如果已安装 OpenResty 的官方 RPM 仓库,请使用以下命令安装 APISIX 的 RPM 仓库:
sudo yum-config-manager --add-repo https://repos.apiseven.com/packages/centos/apache-apisix.repo
完成上述操作后使用以下命令安装 APISIX:
sudo yum install apisix
# yum install -y https://repos.apiseven.com/packages/centos/apache-apisix-repo-1.0-1.noarch.rpm
Loaded plugins: fastestmirror
apache-apisix-repo-1.0-1.noarch.rpm | 2.6 kB 00:00:00
Examining /var/tmp/yum-root-xyycZK/apache-apisix-repo-1.0-1.noarch.rpm: apache-apisix-repo-1.0-1.noarch
Marking /var/tmp/yum-root-xyycZK/apache-apisix-repo-1.0-1.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package apache-apisix-repo.noarch 0:1.0-1 will be installed
--> Finished Dependency ResolutionDependencies Resolved==========================================================================================================================================================================================Package Arch Version Repository Size
==========================================================================================================================================================================================
Installing:apache-apisix-repo noarch 1.0-1 /apache-apisix-repo-1.0-1.noarch 512 Transaction Summary
==========================================================================================================================================================================================
Install 1 PackageTotal size: 512
Installed size: 512
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionInstalling : apache-apisix-repo-1.0-1.noarch 1/1 Verifying : apache-apisix-repo-1.0-1.noarch 1/1 Installed:apache-apisix-repo.noarch 0:1.0-1 Complete!
指定安装apisix版本
# yum install apisix-3.4.1 -y
Loaded plugins: fastestmirror
Determining fastest mirrors
loc-cdrom | 3.6 kB 00:00:00
openresty | 2.9 kB 00:00:00
release/7/x86_64/signature | 833 B 00:00:00
Retrieving key from https://repos.apiseven.com/KEYS
Importing GPG key 0x79882014:Userid : "Joey Ma (GPG Key) <majunjie@apache.org>"Fingerprint: 3ccc ec58 6d4f 1d26 35a9 9242 9097 ddae 7988 2014From : https://repos.apiseven.com/KEYS
release/7/x86_64/signature | 3.0 kB 00:00:00 !!!
(1/2): release/7/x86_64/primary_db | 27 kB 00:00:00
(2/2): openresty/7/x86_64/primary_db | 51 kB 00:00:01
Resolving Dependencies
--> Running transaction check
---> Package apisix.x86_64 0:3.4.1-0.el7 will be installed
--> Processing Dependency: apisix-base < 1.21.5 for package: apisix-3.4.1-0.el7.x86_64
--> Processing Dependency: apisix-base >= 1.21.4.1.7 for package: apisix-3.4.1-0.el7.x86_64
--> Processing Dependency: openldap-devel for package: apisix-3.4.1-0.el7.x86_64
--> Running transaction check
---> Package apisix-base.x86_64 0:1.21.4.2.2-0.el7 will be installed
--> Processing Dependency: openresty-openssl111 >= 1.1.1n-1 for package: apisix-base-1.21.4.2.2-0.el7.x86_64
--> Processing Dependency: openresty-pcre >= 8.45-1 for package: apisix-base-1.21.4.2.2-0.el7.x86_64
--> Processing Dependency: openresty-zlib >= 1.2.12-1 for package: apisix-base-1.21.4.2.2-0.el7.x86_64
---> Package openldap-devel.x86_64 0:2.4.44-22.el7 will be installed
--> Processing Dependency: cyrus-sasl-devel(x86-64) for package: openldap-devel-2.4.44-22.el7.x86_64
--> Running transaction check
---> Package cyrus-sasl-devel.x86_64 0:2.1.26-23.el7 will be installed
--> Processing Dependency: cyrus-sasl(x86-64) = 2.1.26-23.el7 for package: cyrus-sasl-devel-2.1.26-23.el7.x86_64
---> Package openresty-openssl111.x86_64 0:1.1.1w-1.el7 will be installed
---> Package openresty-pcre.x86_64 0:8.45-1.el7 will be installed
---> Package openresty-zlib.x86_64 0:1.3.1-1.el7 will be installed
--> Running transaction check
---> Package cyrus-sasl.x86_64 0:2.1.26-23.el7 will be installed
--> Finished Dependency ResolutionDependencies Resolved==========================================================================================================================================================================================Package Arch Version Repository Size
==========================================================================================================================================================================================
Installing:apisix x86_64 3.4.1-0.el7 release 3.0 M
Installing for dependencies:apisix-base x86_64 1.21.4.2.2-0.el7 release 47 Mcyrus-sasl x86_64 2.1.26-23.el7 loc-cdrom 88 kcyrus-sasl-devel x86_64 2.1.26-23.el7 loc-cdrom 310 kopenldap-devel x86_64 2.4.44-22.el7 loc-cdrom 804 kopenresty-openssl111 x86_64 1.1.1w-1.el7 openresty 1.6 Mopenresty-pcre x86_64 8.45-1.el7 openresty 151 kopenresty-zlib x86_64 1.3.1-1.el7 openresty 56 kTransaction Summary
==========================================================================================================================================================================================
Install 1 Package (+7 Dependent packages)Total download size: 53 M
Installed size: 172 M
Downloading packages:
(1/8): cyrus-sasl-2.1.26-23.el7.x86_64.rpm | 88 kB 00:00:00
(2/8): cyrus-sasl-devel-2.1.26-23.el7.x86_64.rpm | 310 kB 00:00:00
(3/8): openldap-devel-2.4.44-22.el7.x86_64.rpm | 804 kB 00:00:00
warning: /var/cache/yum/x86_64/7/openresty/packages/openresty-pcre-8.45-1.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID d5edeb74: NOKEY ] 991 kB/s | 2.6 MB 00:00:51 ETA
Public key for openresty-pcre-8.45-1.el7.x86_64.rpm is not installed
(4/8): openresty-pcre-8.45-1.el7.x86_64.rpm | 151 kB 00:00:01
(5/8): openresty-zlib-1.3.1-1.el7.x86_64.rpm | 56 kB 00:00:01
warning: /var/cache/yum/x86_64/7/release/packages/apisix-3.4.1-0.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 96c07346: NOKEY ] 2.5 MB/s | 32 MB 00:00:08 ETA
Public key for apisix-3.4.1-0.el7.x86_64.rpm is not installed
(6/8): apisix-3.4.1-0.el7.x86_64.rpm | 3.0 MB 00:00:12
(7/8): apisix-base-1.21.4.2.2-0.el7.x86_64.rpm | 47 MB 00:00:20
(8/8): openresty-openssl111-1.1.1w-1.el7.x86_64.rpm | 1.6 MB 00:00:33
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.5 MB/s | 53 MB 00:00:34
Retrieving key from https://openresty.org/package/pubkey.gpg
Importing GPG key 0xD5EDEB74:Userid : "OpenResty Admin <admin@openresty.com>"Fingerprint: e522 18e7 0878 97dc 6dea 6d6d 97db 7443 d5ed eb74From : https://openresty.org/package/pubkey.gpg
Retrieving key from https://repos.apiseven.com/KEYS
Importing GPG key 0x79882014:Userid : "Joey Ma (GPG Key) <majunjie@apache.org>"Fingerprint: 3ccc ec58 6d4f 1d26 35a9 9242 9097 ddae 7988 2014From : https://repos.apiseven.com/KEYS
Importing GPG key 0x96C07346:Userid : "APISIX Publisher <dev@apisix.apache.org>"Fingerprint: 713f 1a8f 45e0 2766 dbba bd64 b44c 2b62 96c0 7346From : https://repos.apiseven.com/KEYS
Importing GPG key 0x7F829327:Userid : "zhaoshirui <shirui@api7.ai>"Fingerprint: 22e1 7957 9fbd 69f3 8120 94dc a85c d39d 7f82 9327From : https://repos.apiseven.com/KEYS
Importing GPG key 0xEF915680:Userid : "chenjunxu <chenjunxu@api7.ai>"Fingerprint: 1580 f1e6 8985 1c11 ec61 590d 76a2 3bcc ef91 5680From : https://repos.apiseven.com/KEYS
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionInstalling : openresty-zlib-1.3.1-1.el7.x86_64 1/8 Installing : openresty-openssl111-1.1.1w-1.el7.x86_64 2/8 Installing : cyrus-sasl-2.1.26-23.el7.x86_64 3/8 Installing : cyrus-sasl-devel-2.1.26-23.el7.x86_64 4/8 Installing : openldap-devel-2.4.44-22.el7.x86_64 5/8 Installing : openresty-pcre-8.45-1.el7.x86_64 6/8 Installing : apisix-base-1.21.4.2.2-0.el7.x86_64 7/8 Installing : apisix-3.4.1-0.el7.x86_64 8/8 Verifying : openresty-openssl111-1.1.1w-1.el7.x86_64 1/8 Verifying : openresty-pcre-8.45-1.el7.x86_64 2/8 Verifying : apisix-3.4.1-0.el7.x86_64 3/8 Verifying : openresty-zlib-1.3.1-1.el7.x86_64 4/8 Verifying : openldap-devel-2.4.44-22.el7.x86_64 5/8 Verifying : cyrus-sasl-2.1.26-23.el7.x86_64 6/8 Verifying : apisix-base-1.21.4.2.2-0.el7.x86_64 7/8 Verifying : cyrus-sasl-devel-2.1.26-23.el7.x86_64 8/8 Installed:apisix.x86_64 0:3.4.1-0.el7 Dependency Installed:apisix-base.x86_64 0:1.21.4.2.2-0.el7 cyrus-sasl.x86_64 0:2.1.26-23.el7 cyrus-sasl-devel.x86_64 0:2.1.26-23.el7 openldap-devel.x86_64 0:2.4.44-22.el7 openresty-openssl111.x86_64 0:1.1.1w-1.el7 openresty-pcre.x86_64 0:8.45-1.el7 openresty-zlib.x86_64 0:1.3.1-1.el7 Complete!
管理apisix
初始化 NGINX 配置文件和 etcd
yum install安装后,默认位置在/usr/local/apisix下
# ll
total 4
drwxr-xr-x 17 root root 4096 Jul 16 11:25 apisix
drwxr-xr-x 3 root root 100 Jul 16 11:25 conf
drwxr-xr-x 5 root root 41 Jul 16 11:25 deps
drwxr-xr-x 2 root root 6 Jul 24 2023 logs
# pwd
/usr/local/apisix
修改apisix配置文件
apisix:node_listen: 9080enable_ipv6: truessl:enable: falselisten: - port: 9182enable_admin: trueenable_control: truecontrol:ip: 127.0.0.1port: 9284deployment:etcd:host:- "http://10.1.1.1:2379"- "http://10.1.1.2:2379"- "http://10.1.1.3:2379"user: rootpassword: auyd871477shaprefix: "/apisix"timeout: 30use_grpc: trueadmin:allow_admin:- 0.0.0.0/0admin_key:- name: adminkey: edd1c9f034335f136f87ad84b625c8f1role: adminadmin_listen:ip: 0.0.0.0port: 9180
初始化
# apisix init
/usr/local/openresty//luajit/bin/luajit ./apisix/cli/apisix.lua initWARNING: using fixed Admin API token has security risk.
Please modify "admin_key" in conf/config.yaml .[root@host-10-apisix]# apisix start
/usr/local/openresty//luajit/bin/luajit ./apisix/cli/apisix.lua startWARNING: using fixed Admin API token has security risk.
Please modify "admin_key" in conf/config.yaml .
启动
# apisix start
/usr/local/openresty//luajit/bin/luajit ./apisix/cli/apisix.lua start
Warning! Current maximum number of open file descriptors [1024] is not greater than 1024, please increase user limits by execute 'ulimit -n <new user limits>' , otherwise the performance is low.WARNING: using fixed Admin API token has security risk.
Please modify "admin_key" in conf/config.yaml .etcd cluster version 3.0.0 is less than the required version 3.4.0, please upgrade your etcd cluster
参考
null本文档主要介绍了 APISIX 多种安装方法。https://apisix.apache.org/zh/docs/apisix/installation-guide/
安装apisix-dashboard
yum install -y https://github.com/apache/apisix-dashboard/releases/download/v2.15.0/apisix-dashboard-2.15.0-0.el7.x86_64.rpm
Loaded plugins: fastestmirror
apisix-dashboard-2.15.0-0.el7.x86_64.rpm 11% [======- ] 165 kB/s | 3.9 MB 00:03:07 ETA
apisix-dashboard-2.15.0-0.el7.x86_64.rpm 50% [============================= ] 156 kB/s | 17 MB 00:01:50 ETA
apisix-dashboard-2.15.0-0.el7.x86_64.rpm 79% [=============================================- ] 166 kB/s | 27 MB 00:00:43 ETA
apisix-dashboard-2.15.0-0.el7.x86_64.rpm | 34 MB 00:02:53
Examining /var/tmp/yum-root-xyycZK/apisix-dashboard-2.15.0-0.el7.x86_64.rpm: apisix-dashboard-local-2.15.0-0.el7.x86_64
Marking /var/tmp/yum-root-xyycZK/apisix-dashboard-2.15.0-0.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package apisix-dashboard-local.x86_64 0:2.15.0-0.el7 will be installed
--> Finished Dependency ResolutionDependencies Resolved=====================================================================================================================================================================Package Arch Version Repository Size
=====================================================================================================================================================================
Installing:apisix-dashboard-local x86_64 2.15.0-0.el7 /apisix-dashboard-2.15.0-0.el7.x86_64 122 MTransaction Summary
=====================================================================================================================================================================
Install 1 PackageTotal size: 122 M
Installed size: 122 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionInstalling : apisix-dashboard-local-2.15.0-0.el7.x86_64 1/1 Verifying : apisix-dashboard-local-2.15.0-0.el7.x86_64 1/1 Installed:apisix-dashboard-local.x86_64 0:2.15.0-0.el7 Complete!
修改配置
1.将allow_list中的IP改成0.0.0.0/0
2.修改etcd的地址
3.修改用户名,密码
参数说明:
listen.host: dashboard部署服务器IP
listen.port: dashboard启动监听端口
etcd.endpoints:部署的ETCD集群 信息以及ETCD认证账号密码
authentication.users:dashboard管理页面登录账号密码
启动apisix-dashboard
# systemctl start apisix-dashboard
# systemctl status apisix-dashboard
● apisix-dashboard.service - apisix-dashboardLoaded: loaded (/usr/lib/systemd/system/apisix-dashboard.service; static; vendor preset: disabled)Active: active (running) since Wed 2024-07-17 10:13:58 CST; 1s agoMain PID: 31569 (manager-api)CGroup: /system.slice/apisix-dashboard.service└─31569 /usr/local/apisix/dashboard/manager-api -c /usr/local/apisix/dashboard/conf/conf.yamlJul 17 10:13:58 host-10-200-207-3 systemd[1]: Started apisix-dashboard.
Jul 17 10:13:58 host-10-200-207-3 manager-api[31569]: The manager-api is running successfully!
Jul 17 10:13:58 host-10-200-207-3 manager-api[31569]: Version : 2.15.0
Jul 17 10:13:58 host-10-200-207-3 manager-api[31569]: GitHash : a1ffd33
Jul 17 10:13:58 host-10-200-207-3 manager-api[31569]: Config File: /usr/local/apisix/dashboard/conf/conf.yaml
Jul 17 10:13:58 host-10-200-207-3 manager-api[31569]: Listen : 10.19.195.185:9077
Jul 17 10:13:58 host-10-200-207-3 manager-api[31569]: Loglevel: warn
Jul 17 10:13:58 host-10-200-207-3 manager-api[31569]: ErrorLogFile: /usr/local/apisix/dashboard/logs/error.log
Jul 17 10:13:58 host-10-200-207-3 manager-api[31569]: AccessLogFile: /usr/local/apisix/dashboard/logs/access.log
或者用命令行启动
# cd /usr/local/apisix/dashboard
# pwd
/usr/local/apisix/dashboard
[root@host-10-19-195-185 dashboard]# ll
total 28764
drwxr-xr-x 2 root root 93 Jul 17 10:13 conf
drwxr-xr-x 2 root root 59 Jul 17 09:59 dag-to-lua
drwxr-xr-x 4 root root 8192 Jul 17 09:59 html
drwxr-xr-x 2 root root 41 Jul 17 10:13 logs
-rwxr-xr-x 1 root root 29441454 Jan 6 2023 manager-api# nohup ./manager-api &
登陆页面
查看apisix的信息