apisix安装过程和坑

参考资料:

  • https://blog.csdn.net/danielchan2518/article/details/115716139
  • https://blog.csdn.net/u013205984/article/details/107930841

1、安装依赖

$ wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
$ sudo rpm -ivh epel-release-latest-7.noarch.rpm

添加OpenResty源

$ sudo yum install yum-utils
$ sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo

安装OpenResty

$ sudo yum install -y openresty

2、安装etcd

方法一:apisix需要3.4的etcd。

yum installe etcd也可以安装,你需要yum list etcd 先看看是不是3.4以上。

方法二:自己找半成品部署。

如果你是x86/centos,需要安装amd64的版本。

$ wget https://github.com/etcd-io/etcd/releases/download/v3.4.15/etcd-v3.4.15-linux-arm64.tar.gz
$ tar -xvf etcd-v3.4.15-linux-amd64.tar.gz && \
    cd etcd-v3.4.15-linux-amd64 && \
    sudo cp -a etcd etcdctl /usr/bin/

安装完要启动etcd

$ systemctl start etcd

etcd默认端口是2379
如果起不来,那么你需要补etcd的配置和etcd.service,按照:
手动安装etcd和配置 来操作。
确保所需的所有端口(默认的 9080/9443/2379);可以通过

netstat -anp | grep 2379 

来查找端口占用情况,并停止对方,以方便etcd启动;如果对方不方便停止,那么就修改etcd的端口吧;

3、安装apisix

3.1、下载安装

$ sudo yum install -y https://github.com/apache/apisix/releases/download/2.5/apisix-2.5-0.x86_64.rpm

检查 APISIX 的版本号:

$ apisix version

启动 APISIX:
必须依赖etc>=3.4

$ apisix start

3.2、安装dashboard

dashboard需要比apisix高0.1个版本。apisix=2.5,那么dashboard就是2.6。

$ sudo yum install -y https://github.com/apache/apisix-dashboard/releases/download/v2.6/apisix-dashboard-2.6-0.x86_64.rpm

3.3、配置dashboard

进入dashboard目录

$ cd /usr/local/apisix/dashboard/conf

修改conf.yaml

$ vim conf.yaml

#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

conf:
 listen:
   host: 127.0.0.1     # `manager api` listening ip or host name
   port: 9000          # `manager api` listening port
 allow_list:           # If we don't set any IP list, then any IP access is allowed by 
   default.
   - 127.0.0.1/24

修改host为0.0.0.0并注释掉allow_list

conf:
  listen:
    host: 0.0.0.0     # `manager api` listening ip or host name
    port: 9000          # `manager api` listening port  
#allow_list:           # If we don't set any IP list, then any IP access is allowed by 
  #  default.
  #  - 127.0.0.1/24

3.4、启动dashboard

$ sudo nohup manager-api -p /usr/local/apisix/dashboard/ &

3.5、访问

在浏览器输入http://hostip:9000,默认登录用户密码均为admin

界面打开提示登录

登录成功进入主界面

3.6、运维

为了方便管理,写个脚本来启停:
start.sh

if [[ $1  == "start" ]];then
        nohup manager-api -p /usr/local/apisix/dashboard/ >> /tmp/apisix-dashboard.log 2>&1 &
        systemctl start etcd
elif [[ $1 == "kill" ]];then
        systemctl stop etcd
        ps -ef | grep "/usr/local/apisix/dashboard/" | grep manager-api | awk '{print $2}' | xargs kill -9 
        ps -ef | egrep "dashboard|etcd"
fi
ps -eo etime,pid,command | egrep "dashboard|etcd" | grep -v grep 

你可能感兴趣的:(apisix安装过程和坑)