百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 技术文章 > 正文

APISIX从安装到放弃(安装axios命令)

nanshan 2025-03-19 00:39 15 浏览 0 评论

最近,有几个老项目需要做一些限流、安全、灰度发布等这些方面的升级。由于项目中也一直在用Nginx做请求转发。所以在在OpenRestyKongAPISIX三者之间初步对比了一下。从性能、功能和易用性的角度考虑,最终初步选择APISIX这玩意。

对于安装。我本人是比较偏向于,源码或者二进制手动安装。在安装APISIX时,其他都准备就绪了,就在安装APISIX时,很多代码拉不下来。导致我从源码安装到放弃。最终选择Docker方式

安装etcd

Github
https://github.com/etcd-io/etcd/releases/下载编译好的二进制.

先创建好配置文件。

1
2
3
mkdir -p /etc/etcd/
cd /etc/etcd/
vim etcd.yaml

复制一下内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# This is the configuration file for the etcd server.

# Human-readable name for this member.
name: 'etcd1'

# Path to the data directory.
data-dir:

# Path to the dedicated wal directory.
wal-dir:

# Number of committed transactions to trigger a snapshot to disk.
snapshot-count: 10000

# Time (in milliseconds) of a heartbeat interval.
heartbeat-interval: 100

# Time (in milliseconds) for an election to timeout.
election-timeout: 1000

# Raise alarms when backend size exceeds the given quota. 0 means use the
# default quota.
quota-backend-bytes: 0

# List of comma separated URLs to listen on for peer traffic.
listen-peer-urls: http://172.31.79.250:2380

# List of comma separated URLs to listen on for client traffic.
listen-client-urls: http://172.31.79.250:2379

# Maximum number of snapshot files to retain (0 is unlimited).
max-snapshots: 5

# Maximum number of wal files to retain (0 is unlimited).
max-wals: 5

# Comma-separated white list of origins for CORS (cross-origin resource sharing).
cors:

# List of this member's peer URLs to advertise to the rest of the cluster.
# The URLs needed to be a comma-separated list.
initial-advertise-peer-urls: http://172.31.79.250:2380

# List of this member's client URLs to advertise to the public.
# The URLs needed to be a comma-separated list.
advertise-client-urls: http://172.31.79.250:2379

# Discovery URL used to bootstrap the cluster.
discovery:

# Valid values include 'exit', 'proxy'
discovery-fallback: 'proxy'

# HTTP proxy to use for traffic to discovery service.
discovery-proxy:

# DNS domain used to bootstrap initial cluster.
discovery-srv:

# Initial cluster configuration for bootstrapping.
initial-cluster:

# Initial cluster token for the etcd cluster during bootstrap.
initial-cluster-token: 'etcd-cluster'

# Initial cluster state ('new' or 'existing').
initial-cluster-state: 'new'

# Reject reconfiguration requests that would cause quorum loss.
strict-reconfig-check: false

# Enable runtime profiling data via HTTP server
enable-pprof: true

# Valid values include 'on', 'readonly', 'off'
proxy: 'off'

# Time (in milliseconds) an endpoint will be held in a failed state.
proxy-failure-wait: 5000

# Time (in milliseconds) of the endpoints refresh interval.
proxy-refresh-interval: 30000

# Time (in milliseconds) for a dial to timeout.
proxy-dial-timeout: 1000

# Time (in milliseconds) for a write to timeout.
proxy-write-timeout: 5000

# Time (in milliseconds) for a read to timeout.
proxy-read-timeout: 0

client-transport-security:
  # Path to the client server TLS cert file.
  cert-file:

  # Path to the client server TLS key file.
  key-file:

  # Enable client cert authentication.
  client-cert-auth: false

  # Path to the client server TLS trusted CA cert file.
  trusted-ca-file:

  # Client TLS using generated certificates
  auto-tls: false

peer-transport-security:
  # Path to the peer server TLS cert file.
  cert-file:

  # Path to the peer server TLS key file.
  key-file:

  # Enable peer client cert authentication.
  client-cert-auth: false

  # Path to the peer server TLS trusted CA cert file.
  trusted-ca-file:

  # Peer TLS using generated certificates.
  auto-tls: false

# The validity period of the self-signed certificate, the unit is year.
self-signed-cert-validity: 1

# Enable debug-level logging for etcd.
log-level: debug

logger: zap

# Specify 'stdout' or 'stderr' to skip journald logging even when running under systemd.
log-outputs: [stderr]

# Force to create a new one member cluster.
force-new-cluster: false

auto-compaction-mode: periodic
auto-compaction-retention: "1"
1
2
3
4
5
wget https://github.com/etcd-io/etcd/releases/download/v3.5.7/etcd-v3.5.7-linux-amd64.tar.gz
tar -xvf etcd-v3.5.7-linux-amd64.tar.gz
cd etcd-v3.5.7-linux-amd64
cp -a etcd etcdctl /usr/bin/
nohup etcd --config-file /etc/etcd/etcd.yaml >/tmp/etcd.log 2>&1 &   #后台启动etcd

安装Docker

添加阿里镜像源

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


安装
Docker

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

启动Docker服务

1
systemctl start docker

设置Docker开机自动启动

1
systemctl enable docker

Docker compose安装

下载并安装

1
curl -SL https://github.com/docker/compose/releases/download/v2.16.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose

上面这个地址非常慢,有时候直接连不通,具体原因,大家肯定都知道。所以下载用国内的镜像地址吧

1
sudo curl -L https://get.daocloud.io/docker/compose/releases/download/v2.16.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose

去下载源码
https://github.com/apache/apisix-docker.git
cd apisix-docker/example进入到example目录

由于etcd我是以二进制方式安装,那么apisix_confdashboard_conf里面的etcd配置信息改为实际地址和端口。

1
2
3
4
5
etcd:
  host:                           # it's possible to define multiple etcd hosts addresses of the same etcd cluster.
    - "http://172.31.79.250:2379"          # multiple etcd address
  prefix: "/apisix"               # apisix configurations prefix
  timeout: 30                     # 30 seconds

另外docker-compose-arm64.yml里面的ETCD去掉,再去掉depends_on,删除下面这段

1
2
depends_on:
  - etcd

接下来执行启动命令docker-compose -f docker-compose-arm64.yml -p docker-apisix up -d

这样,APISIX便搭建好了

我们使用dashboard_conf文件夹中conf.yaml文件里的users属性来登录APISIX.

创建APISIX服务

上游类型可以是,固定维护的节点或者是服务注册

服务注册中心支持目前比较主流的注册中心

这里我们选择的是节点方式



这时候,我们就可以去访问
9080端口的/web1/路径


刷新一下页面。请求会转发到另外一个服务上

APISIX初步安装完成,基本功能我们可以基于web UI界面配置完成,还可以借助插件来保护我们的服务,让服务更加稳定、安全。接下来就是进一步的探究APISIX提供的插件。

相关推荐

轻量级分析利器再升级:解读 DuckDB 1.3.0 新特性

DuckDB团队近日正式发布了最新版本——DuckDB1.3.0,代号“Ossivalis”。此次版本以金眼鸭的远古祖先BucephalaOssivalis命名,象征项目在演化和成长过...

C++跨平台编译的终极奥义:用Docker把环境差异按在地上摩擦

"代码在本地跑得飞起,一上服务器就coredump?"——每个C++程序员都经历过的《编译器的复仇》事件!大家好,我是Henry,废话少说,今天来简单谈一下跨平台编译的那些事儿,...

全网最全-Version Script以及__asm__((".symver xxx"))使用总结

首先提醒一点,一切的前提建立在你的名字必须要mangling,不然无论你写的versionscript还是__asm__都不会起任何效果VersionScript简单用法:这是一个典型例子,这个例...

Ubuntu 25.04 Beta发布:Linux 6.14内核

IT之家3月28日消息,Canonical昨日(3月27日)放出了Beta版Ubuntu25.04系统镜像,代号“PluckyPuffin”,稳定版预估将于2025年...

不同平台CRT的区别?什么是UCRT?如何看libc源代码?

若文章对您有帮助,欢迎关注程序员小迷。助您在编程路上越走越好!CRT运行时库C标准规定例如输入输出函数、字符串函数、内存操作等接口,一般采用C运行时库实现。微软的CRT微软有两套CRT,早期的MS...

信创力量,中兴绽放——中兴新支点桌面操作系统安装与使用全攻略

原文链接:「链接」Hello,大家好啊,今天给大家带来一篇中兴新支点桌面操作系统安装使用的文章,欢迎大家分享点赞,点个在看和关注吧!中兴新支点桌面操作系统是一款基于Linux内核、面向政企和信创环...

Linux下安装常用软件都有哪些?做了一个汇总列表,你看还缺啥?

1.安装列表MySQL5.7.11Java1.8ApacheMaven3.6+tomcat8.5gitRedisNginxpythondocker2.安装mysql1.拷贝mysql安装文件到...

一篇文章解决Linux系统安全问题排查,另配实操环境

实操地址:https://www.skillup.host/1/linux/safe/command.md#Linux安全检查排查指南##1.系统账户安全检查###1.1检查异常账户``...

程序员必备的学习笔记《TCP/IP详解(一)》

为什么会有TCP/IP协议在世界上各地,各种各样的电脑运行着各自不同的操作系统为大家服务,这些电脑在表达同一种信息的时候所使用的方法是千差万别。就好像圣经中上帝打乱了各地人的口音,让他们无法合作一样...

《Linux常用命令》(linux的常用命令总结)

一、文件与目录操作1.目录导航pwd:显示当前工作目录路径示例:pwd关键词:当前路径、工作目录cd:切换目录示例:cd/home/user#切换到绝对路径cd..#...

Kubernetes 教程之跟着官方文档从零搭建 K8S

前言本文将带领读者一起,参照者Kubernetes官方文档,对其安装部署进行讲解.Kubernetes更新迭代很快,书上、网上等教程可能并不能适用于新版本,但官方文档能.阅读这篇文章你...

电脑网卡坏了怎么修复(电脑网卡坏了怎么修复win7系统)

当电脑网卡出现故障时,无论是有线网络还是无线网络,都可能无法正常连接。下面从软件、硬件等方面,分步骤为你介绍排查与修复的解决方案。一、初步排查:锁定问题源头检查网络环境将手机、平板等其他设备连接至同一...

如何查询电脑/手机的物理地址(如何找手机的物理地址)

一、要查询电脑的物理地址(也称为MAC地址),可以按照以下步骤进行操作:1.打开命令提示符(Windows)或终端(Mac):-在Windows上,点击“开始”按钮,搜索“命令提示符”,然后点击打...

IPv4 无网络访问权限全流程解决方案

当设备出现IPv4无网络访问权限问题时,多由网络配置错误、连接故障或服务异常导致。以下提供系统化的排查步骤与解决方案,帮助用户快速定位并修复问题。一、基础故障快速检查1.物理连接确认有线网络:检...

Python教程(十九):文件操作(python操作文件夹)

昨天,我们学习了列表推导式,掌握了Python中最优雅的数据处理方式。今天,我们将学习文件操作—Python中读写文件的基础技能。文件操作是编程中的核心技能,无论是读取配置文件、保存用户数据,还是...

取消回复欢迎 发表评论: