腾讯云Centos9使用docker的方式安装APISIX

2024-01-05 08:36

本文主要是介绍腾讯云Centos9使用docker的方式安装APISIX,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

  1. 在虚拟机中安装Docker、Docker-compose
    1. 安装Docker
      1. 清除旧版本的docker

yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

      1. 安装docker的依赖

yum install -y yum-utils device-mapper-persistent-data lvm2

1.1.3 安装gcc

yum install -y gcc gcc-c++

      1. 添加软件源国内镜像

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

1.1.5 更新yum索引

yum makecache

1.1.6 安装docker-ce

yum install docker-ce docker-ce-cli containerd.io

1.1.7 启动docker,并设置开机启动

systemctl start docker

systemctl enable docker

1.1.8 验证docker的安装是否成功

docker version

1.2 安装Docker-compose

1.2.1下载docker-compose的二进制文件

1.2.1.1 查询虚拟机内核名和计算机硬件架构

1.2.1.2 下载地址

https://github.com/docker/compose/releases/tag/v2.21.0

1.2.1.3 将其迁移到/usr/local/bin目录下,并授予读写权限

chmod -R 777 /usr/local/bin/docker-compose

1.2.1.4 验证docker-compose的安装是否成功

docker-compose version

2、安装apisix

2.1 下载 apisix-docker仓库

git clone https://github.com/apache/apisix-docker.git

2.2 进入拉取的目录中

cd apisix-docker/example

2.3 修改docker-compose.yml文件内容

# Licensed to the Apache Software Foundation (ASF) under one or more

# contributor license agreements.  See the NOTICE file distributed with

# this work for additional information regarding copyright ownership.

# The ASF licenses this file to You under the Apache License, Version 2.0

# (the "License"); you may not use this file except in compliance with

# the License.  You may obtain a copy of the License at

#

#     http://www.apache.org/licenses/LICENSE-2.0

#

# 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.

#

version: "3"

services:

  apisix:

    image: apache/apisix:${APISIX_IMAGE_TAG:-3.7.0-debian}

    restart: always

    volumes:

      - ./apisix_conf/config.yaml:/usr/local/apisix/conf/config.yaml:ro

    depends_on:

      - etcd

    ##network_mode: host

    ports:

      - "9180:9180/tcp"

      - "9080:9080/tcp"

      - "9091:9091/tcp"

      - "9443:9443/tcp"

      - "9092:9092/tcp"

    networks:

      apisix:

  etcd:

    image: bitnami/etcd:3.4.15

    restart: always

    volumes:

      - etcd_data:/bitnami/etcd

    environment:

      ETCD_ENABLE_V2: "true"

      ALLOW_NONE_AUTHENTICATION: "yes"

      ETCD_ADVERTISE_CLIENT_URLS: "http://43.139.54.145:2379"

      ETCD_LISTEN_CLIENT_URLS: "http://0.0.0.0:2379"

    ports:

      - "2379:2379/tcp"

    networks:

      apisix:

  web1:

    image: nginx:1.19.0-alpine

    restart: always

    volumes:

      - ./upstream/web1.conf:/etc/nginx/nginx.conf

    ports:

      - "9081:80/tcp"

    environment:

      - NGINX_PORT=80

    networks:

      apisix:

  web2:

    image: nginx:1.19.0-alpine

    restart: always

    volumes:

      - ./upstream/web2.conf:/etc/nginx/nginx.conf

    ports:

      - "9082:80/tcp"

    environment:

      - NGINX_PORT=80

    networks:

      apisix:

  prometheus:

    image: prom/prometheus:v2.25.0

    restart: always

    volumes:

      - ./prometheus_conf/prometheus.yml:/etc/prometheus/prometheus.yml

    ports:

      - "9090:9090"

    networks:

      apisix:

  grafana:

    image: grafana/grafana:7.3.7

    restart: always

    ports:

      - "3000:3000"

    volumes:

      - "./grafana_conf/provisioning:/etc/grafana/provisioning"

      - "./grafana_conf/dashboards:/var/lib/grafana/dashboards"

      - "./grafana_conf/config/grafana.ini:/etc/grafana/grafana.ini"

    networks:

      apisix:

networks:

  apisix:

    driver: bridge

volumes:

  etcd_data:

driver: local

修改etcd的IP地址

43.139.54.145是腾讯云外网ip

2.4 使用docker-compose启用 APISIX

```

docker-compose -p docker-apisix up -d

2.5 查看apisix安装的情况

docker ps -a

3、安装apisix-dashboard

3.1 拉取apisix-dashboard镜像

docker pull apache/apisix-dashboard

3.2、在/root路径下,添加dashboard的配置文件conf.yaml

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.

  allow_list:       # If we don't set any IP list, then any IP access is allowed by default.

  etcd:

    endpoints:      # supports defining multiple etcd host addresses for an etcd cluster

      - 10.0.12.9:2379

  ## username: "root"  #如果没开启授权,可以注掉

  ## password: "root" #如果没开启授权,可以注掉

authentication:

  secret:

    zQ5w5jkLDh3jZpywJ3sskrw6Yv633ruq

  expire_time: 3600     # jwt token expire time, in second

  users:                # yamllint enable rule:comments-indentation

    - username: admin

      password: password

    - username: user

      password: password

10.0.12.9是腾讯云内网ip

3.3 启动容器

cd /root

docker run -it -p 9000:9000 -v ./conf.yaml:/usr/local/apisix-dashboard/conf/conf.yaml apache/apisix-dashboard

3.4 查看容器启动情况

docker ps -a

4、测试

4.1 访问dashboard页面

访问地址:http://43.139.54.145:9000,账号密码为conf.yaml文件中的

4.2 访问到grafana的页面

Grafana,账号密码均为admin

4.3 访问prometheus页面

http://43.139.54.145:9090

5、防火墙

5.1 虚拟机防火墙

5.2 腾讯云服务器防火墙

这篇关于腾讯云Centos9使用docker的方式安装APISIX的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/572282

相关文章

Python使用Tenacity一行代码实现自动重试详解

《Python使用Tenacity一行代码实现自动重试详解》tenacity是一个专为Python设计的通用重试库,它的核心理念就是用简单、清晰的方式,为任何可能失败的操作添加重试能力,下面我们就来看... 目录一切始于一个简单的 API 调用Tenacity 入门:一行代码实现优雅重试精细控制:让重试按我

Python安装Pandas库的两种方法

《Python安装Pandas库的两种方法》本文介绍了三种安装PythonPandas库的方法,通过cmd命令行安装并解决版本冲突,手动下载whl文件安装,更换国内镜像源加速下载,最后建议用pipli... 目录方法一:cmd命令行执行pip install pandas方法二:找到pandas下载库,然后

MySQL中EXISTS与IN用法使用与对比分析

《MySQL中EXISTS与IN用法使用与对比分析》在MySQL中,EXISTS和IN都用于子查询中根据另一个查询的结果来过滤主查询的记录,本文将基于工作原理、效率和应用场景进行全面对比... 目录一、基本用法详解1. IN 运算符2. EXISTS 运算符二、EXISTS 与 IN 的选择策略三、性能对比

SpringBoot多环境配置数据读取方式

《SpringBoot多环境配置数据读取方式》SpringBoot通过环境隔离机制,支持properties/yaml/yml多格式配置,结合@Value、Environment和@Configura... 目录一、多环境配置的核心思路二、3种配置文件格式详解2.1 properties格式(传统格式)1.

Oracle数据库定时备份脚本方式(Linux)

《Oracle数据库定时备份脚本方式(Linux)》文章介绍Oracle数据库自动备份方案,包含主机备份传输与备机解压导入流程,强调需提前全量删除原库数据避免报错,并需配置无密传输、定时任务及验证脚本... 目录说明主机脚本备机上自动导库脚本整个自动备份oracle数据库的过程(建议全程用root用户)总结

使用Python构建智能BAT文件生成器的完美解决方案

《使用Python构建智能BAT文件生成器的完美解决方案》这篇文章主要为大家详细介绍了如何使用wxPython构建一个智能的BAT文件生成器,它不仅能够为Python脚本生成启动脚本,还提供了完整的文... 目录引言运行效果图项目背景与需求分析核心需求技术选型核心功能实现1. 数据库设计2. 界面布局设计3

使用IDEA部署Docker应用指南分享

《使用IDEA部署Docker应用指南分享》本文介绍了使用IDEA部署Docker应用的四步流程:创建Dockerfile、配置IDEADocker连接、设置运行调试环境、构建运行镜像,并强调需准备本... 目录一、创建 dockerfile 配置文件二、配置 IDEA 的 Docker 连接三、配置 Do

Android Paging 分页加载库使用实践

《AndroidPaging分页加载库使用实践》AndroidPaging库是Jetpack组件的一部分,它提供了一套完整的解决方案来处理大型数据集的分页加载,本文将深入探讨Paging库... 目录前言一、Paging 库概述二、Paging 3 核心组件1. PagingSource2. Pager3.

python使用try函数详解

《python使用try函数详解》Pythontry语句用于异常处理,支持捕获特定/多种异常、else/final子句确保资源释放,结合with语句自动清理,可自定义异常及嵌套结构,灵活应对错误场景... 目录try 函数的基本语法捕获特定异常捕获多个异常使用 else 子句使用 finally 子句捕获所

Debian系和Redhat系防火墙配置方式

《Debian系和Redhat系防火墙配置方式》文章对比了Debian系UFW和Redhat系Firewalld防火墙的安装、启用禁用、端口管理、规则查看及注意事项,强调SSH端口需开放、规则持久化,... 目录Debian系UFW防火墙1. 安装2. 启用与禁用3. 基本命令4. 注意事项5. 示例配置R