创建 Node-Exporter

  • https://github.com/prometheus/node_exporter
1
2
3
4
5
6
7
8
9
docker run -d \
--name node-exporter \
--restart always \
--net host \
--pid host \
-m 512m \
-v /:/host:ro,rslave \
prom/node-exporter:latest \
--path.rootfs=/host

创建 Prometheus

  • https://github.com/prometheus/prometheus
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# prometheus.yml
global:
scrape_interval: 30s
evaluation_interval: 60s
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets:
- "127.0.0.1:9090"
- job_name: "node"
static_configs:
- targets:
- "127.0.0.1:9100" # local
- "127.0.0.2:9100" # other
1
2
3
4
5
6
7
8
9
docker run -d \
--name prometheus \
--restart always \
--user root \
-p 9090:9090 \
-m 2048m \
-v /opt/docker/prometheus/config/prometheus.yml:/etc/prometheus/prometheus.yml \
-v /opt/docker/prometheus/data:/prometheus \
prom/prometheus:latest

创建 Grafana

  • https://github.com/grafana/grafana
1
2
3
4
5
6
7
docker run -d \
--name grafana \
--restart always \
--user root \
-p 3000:3000 \
-v /opt/docker/grafana:/var/lib/grafana \
grafana/grafana:latest

配置 Grafana

配置 DataSources

在地址 {$server_url}/datasources/new 选择 Prometheus,在 URL 处填写地址。

  • 如果使用 docker 部署 Grafana,需通过宿主机访问 Prometheus,所以地址可能是 http://172.17.0.1:9090

导入 Dashboard

  • https://grafana.com/grafana/dashboards/8919

这里推荐使用上面的模版,在地址 {$server_url}/dashboard/import 输入 id 8919 然后保存即可。

预览

预览

验证是否开启 ipv6

1
2
3
4
# ifconfig -a | grep inet6
inet6 fe80::42:b8ff:feb5:4214 prefixlen 64 scopeid 0x20<link>
inet6 fe80::5054:ff:fec3:d3bb prefixlen 64 scopeid 0x20<link>
inet6 ::1 prefixlen 128 scopeid 0x10<host>

出现 inet6 相关即为开启 ipv6

修改内核模块配置

编辑 /etc/default/grub 文件并在 GRUB_CMDLINE_LINUX 中添加 ipv6.disable=1

如果是 Ubuntu 可能还有 GRUB_CMDLINE_LINUX_DEFAULT,同样也需要添加 ipv6.disable=1

1
2
3
4
# cat /etc/default/grub
......
GRUB_CMDLINE_LINUX="crashkernel=auto console=ttyS0 console=tty0 panic=5 net.ifnames=0 biosdevname=0 intel_idle.max_cstate=1 intel_pstate=disable"
......

修改后为

1
2
3
4
# cat /etc/default/grub
......
GRUB_CMDLINE_LINUX="crashkernel=auto console=ttyS0 console=tty0 panic=5 net.ifnames=0 biosdevname=0 intel_idle.max_cstate=1 intel_pstate=disable ipv6.disable=1"
......

应用更改

1
2
3
4
# CentOS
grub2-mkconfig -o /boot/grub2/grub.cfg
# Ubuntu
update-grub

重启

1
shutdown -r now

部署

1
2
3
4
5
6
7
8
docker run -d \
--name teamspeak \
--restart always \
-p 9987:9987/udp \
-v /opt/docker/teamspeak:/var/ts3server \
-e TS3SERVER_LICENSE=accept \
-e TS3SERVER_SERVERADMIN_PASSWORD=PLACEHOLD \
teamspeak:latest

日志

使用以下命令查看 Query Admin Account 相关登录用户密码以及 Privilege Key

1
docker logs teamspeak

脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
~/.acme.sh/acme.sh \
--debug \
--issue \
--dns dns_dp \
-d *.starudream.cn

~/.acme.sh/acme.sh \
--debug \
--install-cert \
-d *.starudream.cn \
--fullchain-file '/usr/local/openresty/nginx/conf/ssl/*.starudream.cn.crt' \
--key-file '/usr/local/openresty/nginx/conf/ssl/*.starudream.cn.key' \
--reloadcmd 'service nginx reload'

nginx 配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
server {
listen 80;
listen [::]:80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /usr/local/openresty/nginx/conf/ssl/*.starudream.cn.crt;
ssl_certificate_key /usr/local/openresty/nginx/conf/ssl/*.starudream.cn.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_timeout 10m;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_buffer_size 1400;
add_header Strict-Transport-Security max-age=15768000;
ssl_stapling on;
ssl_stapling_verify on;
server_name test.starudream.cn;
access_log /data/wwwlogs/test.starudream.cn_nginx.log combined;
index index.html;
root /data/wwwroot/default;
if ($ssl_protocol = "") { return 301 https://$host$request_uri; }
}

参考

  • https://github.com/acmesh-official/acme.sh

首先需要在 GitHub 上建立两个仓库,一个 公有,一个 私有

公有 仓库用于存放 Hexo 生成的静态文件以部署 GitHub Pages

私有 仓库用于存放未经编译的 Hexo 文件。

示例:starudream/blog-page 为我的 公有 仓库,starudream/blog 是我的 私有 仓库。

然后在 https://github.com/settings/tokens 申请 PAT,并将其加入私有仓库的 Secrets

最后在 私有 仓库内创建文件 .github/workflows/deploy.yml,修改相应内容:

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
name: Deploy
on:
push:
branches:
- master
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Checkout Page
uses: actions/checkout@v2
with:
fetch-depth: 1
repository: starudream/blog-page
path: .deploy_git
token: ${{ secrets.PAGE_PAT }}
- name: Cache
uses: actions/cache@v1
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('**/package.json') }}
- name: Node
uses: actions/setup-node@v1
with:
node-version: 12
- name: Build
run: |
npm install hexo-cli -g && npm install && npm run build
- name: Deploy
run: |
rm -rf .deploy_git/* && cp -rf public/* .deploy_git/
git config --global user.name starudream
git config --global user.email justwangsheng@qq.com
message=$(git log -1 --pretty=format:%s)
cd .deploy_git
git add -A
git commit -m "$message"
git push