自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

聊聊Apisix從安裝到放棄的辛路歷程

開發(fā) 項(xiàng)目管理
對(duì)于安裝。我本人是比較偏向于,源碼或者二進(jìn)制手動(dòng)安裝。在安裝APISIX時(shí),其他都準(zhǔn)備就緒了,就在安裝APISIX時(shí),很多代碼拉不下來。導(dǎo)致我從源碼安裝到放棄。最終選擇Docker方式。

?最近,有幾個(gè)老項(xiàng)目需要做一些限流、安全、灰度發(fā)布等這些方面的升級(jí)。由于項(xiàng)目中也一直在用Nginx做請(qǐng)求轉(zhuǎn)發(fā)。所以在在OpenResty,Kong、APISIX三者之間初步對(duì)比了一下。從性能、功能和易用性的角度考慮,最終初步選擇APISIX這玩意。

對(duì)于安裝。我本人是比較偏向于,源碼或者二進(jìn)制手動(dòng)安裝。在安裝APISIX時(shí),其他都準(zhǔn)備就緒了,就在安裝APISIX時(shí),很多代碼拉不下來。導(dǎo)致我從源碼安裝到放棄。最終選擇Docker方式

安裝etcd

去Githubhttps://github.com/etcd-io/etcd/releases/下載編譯好的二進(jìn)制.

先創(chuàng)建好配置文件。

mkdir -p /etc/etcd/
cd /etc/etcd/
vim etcd.yaml

復(fù)制一下內(nèi)容

# 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"
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 & #后臺(tái)啟動(dòng)etcd

安裝Docker

添加阿里鏡像源

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

安裝Docker

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

啟動(dòng)Docker服務(wù)

systemctl start docker

設(shè)置Docker開機(jī)自動(dòng)啟動(dòng)

systemctl enable docker

Docker compose安裝

下載并安裝

curl -SL https://github.com/docker/compose/releases/download/v2

上面這個(gè)地址非常慢,有時(shí)候直接連不通,具體原因,大家肯定都知道。所以下載用國(guó)內(nèi)的鏡像地址吧

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進(jìn)入到example目錄

由于etcd我是以二進(jìn)制方式安裝,那么apisix_conf和dashboard_conf里面的etcd配置信息改為實(shí)際地址和端口。

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,刪除下面這段

depends_on:
- etcd

接下來執(zhí)行啟動(dòng)命令docker-compose -f docker-compose-arm64.yml -p docker-apisix up -d

這樣,APISIX便搭建好了

我們使用dashboard_conf文件夾中conf.yaml文件里的users屬性來登錄APISIX.

創(chuàng)建APISIX服務(wù)

上游類型可以是,固定維護(hù)的節(jié)點(diǎn)或者是服務(wù)注冊(cè)

服務(wù)注冊(cè)中心支持目前比較主流的注冊(cè)中心

這里我們選擇的是節(jié)點(diǎn)方式

這時(shí)候,我們就可以去訪問9080端口的/web1/路徑

刷新一下頁(yè)面。請(qǐng)求會(huì)轉(zhuǎn)發(fā)到另外一個(gè)服務(wù)上

APISIX初步安裝完成,基本功能我們可以基于web UI界面配置完成,還可以借助插件來保護(hù)我們的服務(wù),讓服務(wù)更加穩(wěn)定、安全。接下來就是進(jìn)一步的探究APISIX提供的插件。

責(zé)任編輯:武曉燕 來源: 今日頭條
相關(guān)推薦

2022-01-19 22:14:36

Apache APIAPI 網(wǎng)關(guān)插件

2021-05-18 06:11:55

QtUbuntuC++

2021-05-20 07:47:49

數(shù)據(jù)庫(kù)MySQL 數(shù)據(jù)庫(kù)安裝

2010-04-21 13:30:24

Linux rpm命令

2022-12-05 16:45:57

模型方法

2022-11-22 14:39:40

CPU單核多核

2023-02-10 09:34:42

人工智能駕駛

2023-12-15 09:57:13

微服務(wù)鏈路服務(wù)

2012-03-19 21:06:52

Android

2019-07-02 14:17:18

API網(wǎng)關(guān)網(wǎng)關(guān)流量

2020-03-25 09:57:29

Python數(shù)據(jù)工具

2024-12-30 09:55:44

2017-05-23 16:36:06

程序程序員

2024-04-26 08:17:09

GoGoogle項(xiàng)目

2022-07-01 08:26:22

區(qū)塊鏈去中心化以太坊

2025-04-22 02:00:00

芯片晶圓光刻機(jī)

2017-03-25 20:30:15

2014-11-06 13:35:03

負(fù)載均衡應(yīng)用交付

2009-07-17 08:58:25

IT運(yùn)維網(wǎng)管軟件游龍科技

2010-12-24 09:36:37

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)