Linux下apisix离线安装教程

一、首先需要安装etcd:

解压缩etcd后执行以下命令:
tar -xvf etcd-v3.5.4-linux-amd64.tar.gz && \
cd etcd-v3.5.4-linux-amd64 && \
sudo cp -a etcd etcdctl /usr/bin/
nohup etcd >/tmp/etcd.log 2>&1 &

二、通过rpm离线安装apisix

通过 RPM 包离线安装:
将 APISIX 离线 RPM 包下载到 apisix 文件夹:

sudo mkdir -p apisix
sudo yum install -y https://repos.apiseven.com/packages/centos/apache-apisix-repo-1.0-1.noarch.rpm
sudo yum clean all && yum makecache
sudo yum install -y --downloadonly --downloaddir=./apisix apisix

将apisix文件夹复制到目标主机到root文件夹下并运行以下命令:
Apisix文件夹下的内容。
image-20231204105602292.png
执行以下命令:
sudo yum install ./apisix/*.rpm
如果提示缺少包依赖,则执行:
rpm -Uvh ./apisix/*.rpm --nodeps --force

三、启动apisix

APISIX 安装完成后,你可以运行以下命令初始化 NGINX 配置文件和 etcd:
apisix init
使用以下命令启动 APISIX:
apisix start

四、安装apisix-dashboard

1、安装

sudo yum install -y apisix-dashboard-3.0.1-0.el7.x86_64.rpm

2、更改dashboard登录账号名和密码

在/usr/local/apisix/dashboard/conf/conf.yaml下

#1、修改监听地址
conf:
  listen:
     host: 0.0.0.0     # the address on which the `Manager API` should listen.
                          # The default value is 0.0.0.0, if want to specify, please enable it.
                          # This value accepts IPv4, IPv6, and hostname.
    port: 9000            # The port on which the `Manager API` should listen.
 
#2、设置允许访问的地址段
  allow_list:             # If we don't set any IP list, then any IP access is allowed by default.
    - 0.0.0.0          # The rules are checked in sequence until the first match is found.
    - ::1
 
 
#3、修改etcd连接信息
  etcd:
    endpoints:            
      - 10.2.20.77:2379 #Apisix与Apisix-dashboard要使用同一个etcd
 
#4、修改dashboard登录账户及密码
authentication:
  secret:
    secret              # secret for jwt token generation.
                        # NOTE: Highly recommended to modify this value to protect `manager api`.
                        # if it's default value, when `manager api` start, it will generate a random string to replace it.
  expire_time: 3600     # jwt token expire time, in second
  users:                # yamllint enable rule:comments-indentation
    - username: adminaaa   # username and password for login `manager api`
      password: 123456
#    - username: user
#      password: user

3、运行

以下两种方式选一种,建议第二种
#run dashboard in the shell:
sudo manager-api -p /usr/local/apisix/dashboard/
#or run dashboard as a service:
systemctl start apisix-dashboard

五、root用户安装,非root用户启动

APISIX解决:使用root用户安装,非root用户启动问题,使用root用户RPM包安装完成后,执行如下操作即可:
修改属主属组:

chown -R cfae:cfae /usr/local/apisix/
chmod -R 775 /usr/local/apisix/
chown -R cfae:cfae /usr/local/openresty/
chmod -R 775 /usr/local/openresty/

六、Apisix报错汇总

最大文件数报错

原因:系统open files设置太少

执行ulimit -n 65536能暂时解决问题。

永久设置最大文件数

vim /etc/security/limits.conf 

在limits.conf追加两行:

soft nofile 65536
hard nofile 65536

再次启动apisix即可。

DNS is Empty

1、编辑DNS配置文件

vim /etc/resolv.conf

2、添加DNS配置信息:

  nameserver 47.106.30.119

3、然后执行重启

systemctl restart network

某些生产环境的DNS配置文件是由脚本生成,无法永久修改并生效。
解决方案:直接修改配置文件,不重启network服务,临时修改完成后,直接执行sudo apisix init 即可。

DNS服务配置有问题,导致域名解析有误,所以需要重新配置dns服务器

在用vim编辑该文件时会提示W10: Warning: Changing a readonly file错误,用root也不行
然后去修改文件权限:

chmod +w /etc/resolv.conf

会报如下错误:

chmod changing permissions of `etc/resolv.conf': Operation not permitted

主要原因是文件元信息有i属性,文件被设置成i属性 防止系统中某个关键文件被修改。用chattr执行改变文件或目录的属性,可执行lsattr指令查询其属性。
查看文件属性 lsattr /etc/resolv.conf
删除i属性 chattr -i /etc/resolv.conf
增加i 属性 chattr +i /etc/resolv.conf
如果查询到具有i属性就可以执行上面的删除操作:

[root@root]# lsattr /etc/resolv.conf 
----i--------e-- /etc/resolv.conf

这样操作后就可以修改文件权限,进行增删改查了

chattr -i /etc/resolv.conf
[root@root]# lsattr /etc/resolv.conf
-------------e-- /etc/resolv.conf

修改文件以后再把文件权限还原

 [root@root]# chattr +i /etc/resolv.conf
  • 17
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Linux离线安装Redis,可以按照以下步骤进行操作: 1. 首先,确保已经安装了gcc-c++编译器。可以使用以下命令安装: ``` rpm -Uvh gcc-c++-<version>.rpm ``` \[1\] 2. 下载Redis的安装包,并解压缩: ``` tar -zxf redis-<version>.tar.gz ``` \[1\] 3. 进入Redis源代码目录,并进行编译: ``` cd redis-<version> make ``` \[1\] 4. 安装Redis到指定目录: ``` make PREFIX=/usr/local/redis install ``` \[2\] 5. 复制Redis的配置文件到/etc/目录: ``` cp redis.conf /etc/ ``` \[3\] 6. 修改Redis的配置文件: ``` vi /etc/redis.conf ``` \[3\] 7. 启动Redis服务: ``` redis-server /etc/redis.conf ``` \[3\] 这样,你就成功在Linux离线安装了Redis。请根据实际情况替换命令中的版本号和文件名。 #### 引用[.reference_title] - *1* *2* [Linux离线安装redis全教程(含资源)](https://blog.csdn.net/weixin_43464964/article/details/123847237)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [linux服务器上离线安装redis](https://blog.csdn.net/u011066470/article/details/119109215)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值