etcd
1
2
3
4
5
6
| ETCD_VERSION='3.5.10'
wget https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/etcd-v${ETCD_VERSION}-linux-amd64.tar.gz
tar -xvf etcd-v${ETCD_VERSION}-linux-amd64.tar.gz && \
cd etcd-v${ETCD_VERSION}-linux-amd64 && \
sudo cp -a etcd etcdctl /usr/bin/
nohup etcd >/tmp/etcd.log 2>&1 &
|
etcd集群
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| nohup etcd --name infra0 --initial-advertise-peer-urls http://172.16.0.10:2380 \
--listen-peer-urls http://172.16.0.10:2380 \
--listen-client-urls http://172.16.0.10:2379,http://127.0.0.1:2379 \
--advertise-client-urls http://172.16.0.10:2379 \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster infra0=http://172.16.0.10:2380,infra1=http://172.16.0.11:2380 \
--initial-cluster-state new >etcd.log 2>&1 &
nohup etcd --name infra1 --initial-advertise-peer-urls http://172.16.0.11:2380 \
--listen-peer-urls http://172.16.0.11:2380 \
--listen-client-urls http://172.16.0.11:2379,http://127.0.0.1:2379 \
--advertise-client-urls http://172.16.0.11:2379 \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster infra0=http://172.16.0.10:2380,infra1=http://172.16.0.11:2380 \
--initial-cluster-state new >etcd.log 2>&1 &
|
apisix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| sudo yum install -y https://repos.apiseven.com/packages/centos/apache-apisix-repo-1.0-1.noarch.rpm
sudo yum-config-manager --add-repo https://repos.apiseven.com/packages/centos/apache-apisix.repo
sudo yum install -y apisix-3.2.2
apisix init
# 获取真实IP
vim /usr/local/apisix/conf/config-default.yaml
nginx_config:
http:
real_ip_header: X-Real-IP
real_ip_from:
- 0.0.0.0/0
- "unix:"
apisix start
|
apisix-Dashboard
golang
1
2
3
4
5
6
7
8
9
10
11
| wget https://golang.google.cn/dl/go1.17.linux-amd64.tar.gz
tar zxvf go1.17.linux-amd64.tar.gz
mv go /usr/local/
vim /etc/profile
#底部加上
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
source /etc/profile
go version
|
nodejs
1
2
3
4
5
6
| curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo yum install -y nodejs
sudo corepack enable yarn
node --version
npm --version
yarn -v
|
dashboard
1
2
3
4
5
6
7
8
9
| sudo yum install -y https://github.com/apache/apisix-dashboard/releases/download/v3.0.1/apisix-dashboard-3.0.1-0.el7.x86_64.rpm
vi /usr/local/apisix/dashboard/conf/conf.yaml
#allow_list值注释
#添加security,解决grafana被阻止问题
security:
content_security_policy: "frame-src *;"
systemctl start apisix-dashboard
|
file-logger
1
2
3
4
5
6
7
8
| {
"_meta": {
"disable": false
},
"include_req_body": true,
"include_resp_body": true,
"path": "/opt/apisix/logs/file.log"
}
|
limit-count
1
2
3
4
5
6
7
8
9
| {
"count": 60,
"time_window": 60,
"key_type": "var",
"rejected_code": 503,
"policy": "local",
"allow_degradation": false,
"show_limit_quota_header": true
}
|
api-breaker
1
2
3
4
5
6
7
8
9
10
11
12
| {
"break_response_code": 502,
"max_breaker_sec": 300,
"unhealthy": {
"http_statuses": [500],
"failures": 3
},
"healthy": {
"http_statuses": [200],
"successes": 3
}
}
|
jwt-auth(consumer)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| {
"username": "testJwtAuth",
"plugins": {
"jwt-auth": {
"_meta": {
"disable": false
},
"algorithm": "RS256",
"exp": 86400,
"key": "user-key",
"private_key": "-----BEGIN RSA PRIVATE KEY-----\n\n-----END RSA PRIVATE KEY-----",
"public_key": "-----BEGIN PUBLIC KEY-----\n\n-----END PUBLIC KEY-----"
}
}
}
|
prometheus
1
2
3
4
5
6
| {
"_meta": {
"disable": false
},
"prefer_name": true
}
|
prometheus
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| # 安装
cd /usr/local && \
wget https://github.com/prometheus/prometheus/releases/download/v2.45.1/prometheus-2.45.1.linux-amd64.tar.gz && \
tar -zxvf prometheus-2.45.1.linux-amd64.tar.gz && \
cd /usr/local/prometheus-2.45.1.linux-amd64/
# 修改配置
vi prometheus.yml
scrape_configs:
- job_name: "apisix"
scrape_interval: 15s
metrics_path: "/apisix/prometheus/metrics"
static_configs:
- targets: ["127.0.0.1:9091"]
# 启动
./prometheus --config.file=prometheus.yml --web.listen-address=:9094 --web.enable-lifecycle &
# 登录127.0.0.1:9094
|
grafana
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| # 安装
cd /usr/local && \
wget https://dl.grafana.com/enterprise/release/grafana-enterprise-10.2.0-1.x86_64.rpm && \
sudo yum -y install grafana-enterprise-10.2.0-1.x86_64.rpm
# 修改配置
vi /usr/share/grafana/conf/defaults.ini
allow_embedding = true
# 由于安全策略,设置为 true 时,浏览器才可以正确呈现 Grafana 页面。
#... 其他配置
[auth.anonymous]
# 启用匿名登录
enabled = true
# 启动
systemctl start grafana-server
# 登录http://127.0.0.1:3000 admin/admin
|
配置
- 登录 Grafana。单击 Add your first data source,选择 Prometheus,配置 URL 为 http://127.0.0.1:9094
- 单击左侧 + 号并选择 Import,单击 Upload JSON file 上传 APISIX Grafana Dashboard 元数据文件。上传后,单击 Import
文章作者
lim
上次更新
2024-11-21
(1dac9ff)
许可协议
CC BY-NC-ND 4.0