下载安装脚本

1
curl -fsSL https://get.docker.com -o get-docker.sh

设置安装版本(nightly / test / stable)

1
export CHANNEL=stable

设置下载镜像源

具体参考安装机器的 repo

阿里云公网

1
export DOWNLOAD_URL=https://mirrors.aliyun.com/docker-ce

阿里云内网

1
export DOWNLOAD_URL=http://mirrors.cloud.aliyuncs.com/docker-ce

设置 repo 文件名

1
export REPO_FILE=docker-ce.repo

安装

1
sh get-docker.sh

配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
mkdir -p /etc/docker
cat <<EOF > /etc/docker/daemon.json
{
"exec-opts": [
"native.cgroupdriver=systemd"
],
"registry-mirrors": [
"http://f1361db2.m.daocloud.io"
],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
]
}
EOF

运行

1
2
3
4
systemctl enable docker.service
systemctl start docker.service

docker version

其他

腾讯云镜像 repo 内地址仍是 download.docker.com ,所以使用该脚本没有效果,但是可以使用阿里云公网下载完成后替换镜像源

1
2
# 替换为腾讯云内网
sed -i 's|https://mirrors.aliyun.com|http://mirrors.tencentyun.com|' /etc/yum.repos.d/docker-ce.repo

创建 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