赞
踩
公司部分机器因为某些原因无法联网,只能离线安装apisix,折腾了很久,走了很多弯路,记录一下安装过程。
sudo yum install epel-release
在home下创建文件夹/apisix-dependence
yumdownloader yum-utils-1.1.31-54.el7_8.noarch
yumdownloader python-kitchen-1.1.1-5.el7.noarch
yumdownloader python-chardet-2.2.1-3.el7.noarch
yumdownloader libxml2-python-2.9.1-6.el7_9.6.x86_64
yumdownloader libxml2-2.9.1-6.el7_9.6.x86_64
yum install -y https://repos.apiseven.com/packages/centos/apache-apisix-repo-1.0-1.noarch.rpm
cd /var/tmp/yum-root-
mv apache-apisix-repo-1.0-1.noarch.rpm /home/apisix-dependence
yumdownloader gcc-4.8.5-44.el7.x86_64
yumdownloader pcre-8.32-17.el7.x86_64
yumdownloader pcre-devel-8.32-17.el7.x86_64
yumdownloader git-1.8.3.1-23.el7_8.x86_64
yumdownloader curl-7.29.0-59.el7_9.1.x86_64
yumdownloader libcurl-7.29.0-59.el7_9.1.x86_64
yumdownloader openldap-2.4.44-25.el7_9.x86_64
yumdownloader openldap-devel-2.4.44-25.el7_9.x86_64
yumdownloader cyrus-sasl-devel-2.1.26-24.el7_9.x86_64
安装cyrus-sasl-devel-2.1.26-24.el7_9.x86_64的依赖
yum -y install cyrus-sasl-devel-2.1.26-24.el7_9.x86_64.rpm --downloadonly --downloaddir=./
yumdownloader unzip-6.0-24.el7_9.x86_64
安装apisix-base并获取其依赖
yumdownloader apisix-base-1.21.4.1.3-0.el7.x86_64
yum -y install apisix-base-1.21.4.1.3-0.el7.x86_64.rpm --downloadonly --downloaddir=./
wget https://github.com/luarocks/luarocks/archive/v3.8.0.tar.gz
wget https://github.com/etcd-io/etcd/releases/download/v3.5.4/etcd-v3.5.4-linux-amd64.tar.gz
如果apisix init报ssl.core找不到,解决方案:将openresty1.21版本改成1.19版本,apisix默认安装openresty-1.21。
方式1:
yumdownloader openresty-1.19.9.1-1.el7.x86_64
方式2:
wget https://openresty.org/download/openresty-1.19.9.1.tar.gz
wget https://www.openssl.org/source/openssl-1.0.2k.tar.gz --no-check-certificate
下载openssl的依赖,zlib和zlib-devel
yumdownloader zlib
yumdownloader zlib-devel
yumdownloader perl
yumdownloader perl-parent-0.225-244.el7.noarch perl-HTTP-Tiny-0.033-3.el7.noarch perl-podlators-2.5.1-3.el7.noarch perl-Pod-Perldoc-3.20-4.el7.noarch perl-Pod-Escapes-1.04-297.el7.noarch perl-Encode-2.51-7.el7.x86_64 perl-Text-ParseWords-3.29-4.el7.noarch perl-Pod-Usage-1.63-3.el7.noarch perl-libs-5.16.3-297.el7.x86_64 perl-Exporter-5.68-3.el7.noarch perl-constant-1.27-2.el7.noarch perl-Socket-2.010-5.el7.x86_64 perl-Time-Local-1.2300-2.el7.noarch perl-Carp-1.26-244.el7.noarch perl-PathTools-3.40-5.el7.x86_64 perl-Scalar-List-Utils-1.27-248.el7.x86_64 perl-macros-5.16.3-297.el7.x86_64 perl-Pod-Simple-3.28-4.el7.noarch perl-Storable-2.45-3.el7.x86_64 perl-File-Temp-0.23.01-3.el7.noarch perl-File-Path-2.09-2.el7.noarch perl-threads-shared-1.43-6.el7.x86_64 perl-threads-1.87-4.el7.x86_64 perl-Time-HiRes-1.9725-3.el7.x86_64 perl-Filter-1.49-3.el7.x86_64 perl-Getopt-Long-2.40-3.el7.noarch perl-5.16.3-297.el7.x86_64
创建gcc/目录,然后安装以下依赖包:
yumdownloader cpp-4.8.5-44.el7.x86_64
yumdownloader glibc-devel
yumdownloader libcpp-4.8.5-44.el7.x86_64
rm -rf glibc-devel-2.17-326.el7_9.i686.rpm
yumdownloader libgcc
rm -rf libgcc-4.8.5-44.el7.i686.rpm
yumdownloader libgomp
rm -rf libgomp-4.8.5-44.el7.i686.rpm
yumdownloader libmpc.so.3
yumdownloader libmpfr.so.4
zip -r -q -o apisix-dependence.zip apisix-dependence/
注意:unzip-6.0-24.el7_9.x86_64.rpm需要单独上传,安装之后才能解压zip包
rpm -ivh unzip-6.0-24.el7_9.x86_64.rpm
unzip apisix-dependence.zip
rpm -ivh python-chardet-2.2.1-3.el7.noarch.rpm
rpm -ivh python-kitchen-1.1.1-5.el7.noarch.rpm
rpm -ivh yum-utils-1.1.31-54.el7_8.noarch.rpm
rpm -ivh libxml2-2.9.1-6.el7_9.6.x86_64.rpm
rpm -ivh libxml2-python-2.9.1-6.el7_9.6.x86_64.rpm
rpm -ivh apache-apisix-repo-1.0-1.noarch.rpm
rpm -ivh openresty-zlib-1.2.12-1.el7.x86_64.rpm
rpm -ivh openresty-pcre-8.45-1.el7.x86_64.rpm
rpm -ivh openresty-openssl111-1.1.1s-1.el7.x86_64.rpm
rpm -ivh openresty-openssl111-devel-1.1.1s-1.el7.x86_64.rpm
rpm -ivh libcurl-7.29.0-59.el7_9.1.x86_64.rpm --replacefiles
rpm -ivh curl-7.29.0-59.el7_9.1.x86_64.rpm --replacefiles
rpm -ivh cyrus-sasl-lib-2.1.26-24.el7_9.x86_64.rpm --replacefiles
rpm -ivh cyrus-sasl-2.1.26-24.el7_9.x86_64.rpm
rpm -ivh cyrus-sasl-devel-2.1.26-24.el7_9.x86_64.rpm
rpm -ivh openldap-2.4.44-25.el7_9.x86_64.rpm --replacefiles
rpm -ivh openldap-devel-2.4.44-25.el7_9.x86_64.rpm
rpm -ivh apisix-base-1.21.4.1.3-0.el7.x86_64.rpm
rpm -ihv openresty-1.19.9.1-1.el7.x86_64.rpm --force --nodeps
rpm -ivh gcc-4.8.5-44.el7.x86_64.rpm --force --nodeps
rpm -ivh pcre-8.32-17.el7.x86_64.rpm
rpm -ivh pcre-devel-8.32-17.el7.x86_64.rpm
1、–nodeps – force
加上那两个参数的意义就在于,安装时不再分析包之间的依赖关系而直接安装,也就不会再提示error: Failed dependencies:这样的错误了
2、–replacefiles
安装提示软件冲突时,添加–replacefiles参数即可。
将etcd安装包复制到/home下,然后执行以下命令:
ETCD_VERSION='3.5.4'
tar -xvf etcd-v${ETCD_VERSION}-linux-amd64.tar.gz && cd etcd-v${ETCD_VERSION}-linux-amd64 && sudo cp -a etcd etcdctl /usr/bin/
nohup etcd >/tmp/etcd.log 2>&1 &
将luarocks安装包复制到/home下,然后执行以下命令:
tar -xf v3.8.0.tar.gz cd luarocks-3.8.0 OR_BIN=/usr/local/openresty/bin/openresty OPENRESTY_PREFIX=/usr/local/openresty LUAROCKS_VER=3.8.0 /usr/local/openresty/bin/openresty -v awk -F / '{print $2}' WITH_LUA_OPT=--with-lua=/usr/local/openresty/luajit ./configure --with-lua=/usr/local/openresty/luajit make build sudo make install luarocks -version luarocks --version mkdir /root/.luarocks OPENSSL_PREFIX=/usr/local/openresty/openssl OPENSSL_PREFIX=/usr/local/openresty/openssl111 FOUND_PATH=/usr/local/bin luarocks config variables.OPENSSL_LIBDIR /usr/local/openresty/openssl111/lib luarocks config variables.OPENSSL_INCDIR /usr/local/openresty/openssl111/include
安装perl目录下的依赖
rpm -ivh *.rpm --force --nodeps
rpm -ivh perl-5.16.3-299.el7_9.x86_64.rpm --force --nodeps
rpm -ivh gcc-4.8.5-44.el7.x86_64.rpm --force --nodeps
rpm -ivh *.rpm --force --nodeps
编译安装openresty1.19
[root@localhost openresty-1.19.9.1]# ./configure --with-luajit --with-poll_module --with-pcre-jit --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_v2_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_auth_request_module --with-http_secure_link_module --with-http_random_index_module --with-http_gzip_static_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-threads --with-compat --with-stream --with-http_ssl_module && make && make install
rpm -ivh zlib-1.2.7-20.el7_9.x86_64.rpm --replacefiles
rpm -ivh zlib-devel-1.2.7-20.el7_9.x86_64.rpm
将apisix安装包放到/home下,执行以下命令:
[root@localhost home]# unzip apisix-2.13-master.zip
[root@localhost home]# mv apisix-2.13-master/ apisix-2.13.1/
进入apisix-2.13.1目录:
[root@localhost home]# cd apisix-2.13.1/
在apisix根目录下执行:make install
[root@localhost apisix-2.13.1]# make install
执行apisix init:
[root@localhost apisix-2.13.1]# apisix init
启动apisix:
[root@localhost apisix-2.13.1]# apisix start
将dashboard的rpm包,放到/home下,然后执行以下命令:
[root@localhost home]# rpm -ivh apisix-dashboard-2.10.1-0.el7.x86_64.rpm
[root@localhost home]# cd /usr/local/apisix/dashboard/conf
[root@localhost conf]# vim conf.yaml
将allow_list中的IP改成0.0.0.0/0
启动dashboard:
[root@localhost conf]# sudo manager-api -p /usr/local/apisix/dashboard/ &
浏览器访问dashboard:
http://192.168.6.248:9000/
账号密码都是admin
[root@localhost apisix-dependence]# rpm -ivh libxml2-2.9.1-6.el7_9.6.x86_64.rpm
准备中... ################################# [100%]
file /usr/bin/xmlcatalog from install of libxml2-2.9.1-6.el7_9.6.x86_64 conflicts with file from package libxml2-2.9.1-6.el7_2.3.x86_64
file /usr/bin/xmllint from install of libxml2-2.9.1-6.el7_9.6.x86_64 conflicts with file from package libxml2-2.9.1-6.el7_2.3.x86_64
file /usr/lib64/libxml2.so.2.9.1 from install of libxml2-2.9.1-6.el7_9.6.x86_64 conflicts with file from package libxml2-2.9.1-6.el7_2.3.x86_64
解决方案:
上面提醒,说明软件冲突,安装时,添加–replacefiles参数即可。
[root@localhost apisix-dependence]# rpm -ivh libxml2-2.9.1-6.el7_9.6.x86_64.rpm --replacefiles
[root@localhost openresty-1.19.9.1]# ./configure --with-luajit --with-poll_module --with-pcre-jit --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_v2_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_auth_request_module --with-http_secure_link_module --with-http_random_index_module --with-http_gzip_static_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-threads --with-compat --with-stream --with-http_ssl_module
/usr/bin/env: perl: 没有那个文件或目录
[root@localhost apisix-dependence]# rpm -ivh perl-5.16.3-299.el7_9.x86_64.rpm 错误:依赖检测失败: libperl.so()(64bit) 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(Carp) 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(Cwd) 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(Exporter) 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(File::Path) 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(File::Spec) 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(File::Spec::Functions) 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(File::Spec::Unix) 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(File::Temp) 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(Filter::Util::Call) 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(Getopt::Long) 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(Pod::Simple::Search) 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(Pod::Simple::XHTML) 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(Scalar::Util) 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(Scalar::Util) >= 1.10 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(Socket) 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(Socket) >= 1.3 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(Storable) 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(Time::HiRes) 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(Time::Local) 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(constant) 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(threads) 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl(threads::shared) 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl-libs 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl-libs = 4:5.16.3-299.el7_9 被 perl-4:5.16.3-299.el7_9.x86_64 需要 perl-macros 被 perl-4:5.16.3-299.el7_9.x86_64 需要
[root@localhost openresty-1.19.9.1]# ./configure --with-luajit --with-poll_module --with-pcre-jit --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_v2_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_auth_request_module --with-http_secure_link_module --with-http_random_index_module --with-http_gzip_static_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-threads --with-compat --with-stream --with-http_ssl_module platform: linux (linux) cp -rp bundle/ build cd build cd LuaJIT-2.1-20210510 Can't exec "cc": 没有那个文件或目录 at ./configure line 719. gmake TARGET_STRIP=@: CCDEBUG=-g XCFLAGS='-DLUAJIT_ENABLE_LUA52COMPAT' CC=cc PREFIX=/usr/local/openresty/luajit ==== Building LuaJIT 2.1.0-beta3 ==== gmake -C src gmake[1]: cc:命令未找到 gmake[1]: 进入目录“/home/apisix-dependence/openresty-1.19.9.1/build/LuaJIT-2.1-20210510/src” gmake[1]: cc:命令未找到 Makefile:274: *** Unsupported target architecture。 停止。 gmake[1]: 离开目录“/home/apisix-dependence/openresty-1.19.9.1/build/LuaJIT-2.1-20210510/src” gmake: *** [default] 错误 2 ERROR: failed to run command: gmake TARGET_STRIP=@: CCDEBUG=-g XCFLAGS='-DLUAJIT_ENABLE_LUA52COMPAT' CC=cc PREFIX=/usr/local/openresty/luajit
platform: linux (linux)
cp -rp bundle/ build
cd build
cd LuaJIT-2.1-20210510
gmake TARGET_STRIP=@: CCDEBUG=-g XCFLAGS='-DLUAJIT_ENABLE_LUA52COMPAT' CC=cc PREFIX=/usr/local/openresty/luajit
==== Building LuaJIT 2.1.0-beta3 ====
gmake -C src
/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/cc1: error while loading shared libraries: libmpc.so.3: cannot open shared object file: No such file or directory
/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/cc1: error while loading shared libraries: libmpc.so.3: cannot open shared object file: No such file or directory
gmake[1]: 进入目录“/home/apisix-dependence/openresty-1.19.9.1/build/LuaJIT-2.1-20210510/src”
Makefile:274: *** Unsupported target architecture。 停止。
gmake[1]: 离开目录“/home/apisix-dependence/openresty-1.19.9.1/build/LuaJIT-2.1-20210510/src”
gmake: *** [default] 错误 2
ERROR: failed to run command: gmake TARGET_STRIP=@: CCDEBUG=-g XCFLAGS='-DLUAJIT_ENABLE_LUA52COMPAT' CC=cc PREFIX=/usr/local/openresty/luajit
没有找到libmpc的路径,需要添加如下环境变量
export LD_LIBRARY_PATH=“/usr/lib”
error while loading shared libraries: libmpc.so.3: cannot open shared object file: No such file or directory
platform: linux (linux)
cp -rp bundle/ build
cd build
cd LuaJIT-2.1-20210510
gmake TARGET_STRIP=@: CCDEBUG=-g XCFLAGS='-DLUAJIT_ENABLE_LUA52COMPAT' CC=cc PREFIX=/usr/local/openresty/luajit
==== Building LuaJIT 2.1.0-beta3 ====
gmake -C src
/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/cc1: error while loading shared libraries: libmpc.so.3: wrong ELF class: ELFCLASS32
/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/cc1: error while loading shared libraries: libmpc.so.3: wrong ELF class: ELFCLASS32
解决方案:
安装mpfr-3.1.1-4.el7.x86_64.rpm
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/limits.h:168:61: 致命错误:limits.h:没有那个文件或目录
#include_next <limits.h> /* recurse down to the real one */
^
编译中断。
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/syslimits.h:7:0,
from /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/limits.h:34,
from luaconf.h:12,
from lua.h:16,
from lj_arch.h:9:
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/limits.h:168:61: 致命错误:limits.h:没有那个文件或目录
#include_next <limits.h> /* recurse down to the real one */
[root@localhost apisix-2.13.1]# apisix start
/usr/local/openresty/luajit/bin/luajit ./apisix/cli/apisix.lua start
local DNS is empty
解决方案:
1、编辑DNS配置文件
vim /etc/resolv.conf
2、添加DNS配置信息(随便添加一个,apisix就不会报错了):
nameserver 1.1.1.1
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。