关于12.1服务器的配置.md 8.29 KB
Newer Older
王进波's avatar
王进波 committed
1 2 3 4 5 6 7 8 9 10 11 12
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**  *generated with [DocToc](https://github.com/thlorenz/doctoc)*

- [关于12.1服务器的配置](#%E5%85%B3%E4%BA%8E121%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9A%84%E9%85%8D%E7%BD%AE)
  - [服务器](#%E6%9C%8D%E5%8A%A1%E5%99%A8)
  - [Zabbix 监控](#zabbix-%E7%9B%91%E6%8E%A7)
    - [Administration - General - Regular expression - Network interface for discovery wohi](#administration---general---regular-expression---network-interface-for-discovery-wohi)
    - [Configuration - Discovery](#configuration---discovery)
    - [Configuration - Actions - Discovery](#configuration---actions---discovery)
    - [Configuration - Aciton - Auto registration](#configuration---aciton---auto-registration)
    - [监控模板](#%E7%9B%91%E6%8E%A7%E6%A8%A1%E6%9D%BF)
王进波's avatar
王进波 committed
13 14 15 16 17
  - [SINOPIA ——私有NPM仓库](#sinopia-%E7%A7%81%E6%9C%89npm%E4%BB%93%E5%BA%93)
    - [Docker run](#docker-run)
    - [Backups](#backups)
    - [Restore](#restore)
  - [L2TP-VPN-SERVER](#l2tp-vpn-server)
王进波's avatar
王进波 committed
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

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# 关于12.1服务器的配置

edit-by:王进波 2018.08.12

> IP : 192.168.12.1
>
> Mac Address : e0:d5:5e:51:64:48
>
> LSB Version:    :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
>
> Distributor ID: CentOS
>
> Description:    CentOS Linux release 7.5.1804 (Core) 
>
> Release:        7.5.1804
>
> Codename:       Core



## 服务器

王进波's avatar
王进波 committed
43
12.1是代码服务器,用 Docker 运行了 Gitlab-server 。
王进波's avatar
王进波 committed
44

王进波's avatar
王进波 committed
45 46 47
除此之外,Docker中还运行着 Zabbix 监控服务器,Sinopia(私有npm仓库),l2tp-vpn-server

查看正在运行的容器的本地image镜像,命令如下:
王进波's avatar
王进波 committed
48 49 50 51 52

```shell
[gitlab@gitlabserver ~]$ sudo docker image ls
```

王进波's avatar
王进波 committed
53
查看正在运行的Docker容器,命令如下:
王进波's avatar
王进波 committed
54 55 56 57 58 59 60

```shell
[gitlab@gitlabserver ~]$ sudo docker ps
```

其中,Gitlab-server 只使用了一个Docker容器,gitlab(ID:f14446b77bae ),这个容器包含了Gitlab-server运行所需的全部服务。

王进波's avatar
王进波 committed
61 62
Gitlab-server的Docker容器在删除并重新Run以后882端口失效的问题可以看这里 [Gitlab 8822端口失效问题](./Gitlab 8822端口失效问题.md) 

王进波's avatar
王进波 committed
63 64 65 66 67 68 69 70 71 72
Zabbix 监控服务的部署使用了3个Docker容器,分别是zabbixserver(ID:9d2e28d10ae4),zabbix-web-nginx-mysql(ID:8eb1ecab6adf),mysql(ID:dbc1348c8c51 ),zabbixserver是监控服务,zabbix-web-nginx-mysql是web前端配置界面,mysql是zabbix数据库,也可以为其他服务提供基础存储服务



从Image镜像启动容器的脚本如下

gitlab(f14446b77bae)

```shell
sudo docker run --detach \
王进波's avatar
王进波 committed
73
    --hostname gitlab.wohitech.com \
王进波's avatar
王进波 committed
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
    --publish 443:443 \
    --publish 80:80 \
    --publish 22:22 \
    --publish 8880:8880 \
    --publish 8443:8443 \
    --publish 8822:8822 \
    --name gitlab \
    --restart always \
    --volume /srv/gitlab/config:/etc/gitlab \
    --volume /srv/gitlab/logs:/var/log/gitlab \
    --volume /srv/gitlab/data:/var/opt/gitlab \
    registry.docker-cn.com/gitlab/gitlab-ce:latest
```

mysql (dbc1348c8c51),启动参数中关于zabbix的内容是让mysql容器启动时为zabbix监控服务创建数据库

```shell
sudo docker run --name mysql \
--restart always \
-v /srv/mysql/data:/var/lib/mysql \
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD=000000 \
-e MYSQL_DATABASE='zabbix' \
-e MYSQL_USER='zabbix' \
-e MYSQL_PASSWORD='zabbix' \
-d registry.docker-cn.com/library/mysql:5.7
```

zabbixserver(9d2e28d10ae4)

```shell
sudo docker run --name zabbixserver \
王进波's avatar
王进波 committed
106
--restart always \
王进波's avatar
王进波 committed
107 108 109 110 111 112 113 114 115 116 117 118 119
-p 10051:10051 \
-e DB_SERVER_HOST="192.168.12.1" \
-e MYSQL_ROOT_PASSWORD="000000" \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix" \
-d registry.docker-cn.com/zabbix/zabbix-server-mysql:latest
```

zabbix-web-nginx-mysql(8eb1ecab6adf)

```shell
sudo docker run --name zabbix-web-nginx-mysql \
王进波's avatar
王进波 committed
120
--restart always \
王进波's avatar
王进波 committed
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
-p 8000:80 \
-p 8043:443 \
-e DB_SERVER_HOST="192.168.12.1" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix" \
-e ZBX_SERVER_HOST="10051" \
-e PHP_TZ="Asia/Shanghai" \
-d registry.docker-cn.com/zabbix/zabbix-web-nginx-mysql:latest
```



## Zabbix 监控

Zabbix监控服务有一个可配置的Web前端,发布在http://192.168.12.1:8000,管理员帐号为 Admin/zabbix

还原配置的重要参考如下

### Administration - General - Regular expression - Network interface for discovery wohi

需要在网络设备相关的正则表达式中增加一项,用于过滤无关网络设备,如图

王进波's avatar
王进波 committed
143
![1534067140704](../imgs/1534067140704.png)
王进波's avatar
王进波 committed
144 145 146



王进波's avatar
王进波 committed
147
![1534067221480](../imgs/1534067221480.png)
王进波's avatar
王进波 committed
148 149 150 151 152 153 154 155 156 157 158

新增正则表达式,为假

```shell
^(window|kinboy|RAS|VMware|TeamViewer|WAN|Microsoft|TAP-Windows|4G|Apple|Bluetooth)|(.*Pseudo-Interface.*|.*QoS.*|.*Bandwidth.*|.*WFP.*|.*Native.*|.*Virtual.*)
```

### Configuration - Discovery

新增发现规则,按图配置即可

王进波's avatar
王进波 committed
159
![1534067337404](../imgs/1534067342232.png)
王进波's avatar
王进波 committed
160 161 162 163 164 165 166



### Configuration - Actions - Discovery

新增自动发现Action,按图配置即可

王进波's avatar
王进波 committed
167
![1534067541218](../imgs/1534067541218.png)
王进波's avatar
王进波 committed
168

王进波's avatar
王进波 committed
169
![1534067457401](../imgs/1534067465322.png)
王进波's avatar
王进波 committed
170

王进波's avatar
王进波 committed
171
![1534067498971](../imgs/1534067498971.png)
王进波's avatar
王进波 committed
172 173 174 175 176 177 178





### Configuration - Aciton - Auto registration

王进波's avatar
王进波 committed
179
![1534067622183](../imgs/1534067622183.png)
王进波's avatar
王进波 committed
180

王进波's avatar
王进波 committed
181
![1534067646320](../imgs/1534067646320.png)
王进波's avatar
王进波 committed
182

王进波's avatar
王进波 committed
183
![1534067668076](../imgs/1534067675693.png)
王进波's avatar
王进波 committed
184 185 186 187 188



### 监控模板

王进波's avatar
王进波 committed
189
监控模板可以导入导出,我导出的模板文件在 [这里](https://civgit.vicp.net:8443/wangjinbo/Svn-to-Git/blob/master/%E5%B7%A5%E5%85%B7/zbx_export_templates.xml)。 下载后在导入界面导入即可,导入成功后还需要增加一项监控项原型。
王进波's avatar
王进波 committed
190 191 192

Configuration - Template - Template OS Windows Wohi - Discovery roles - Network interface discovery - item prototypes,如图

王进波's avatar
王进波 committed
193
![1534068051823](../imgs/1534068051823.png)
王进波's avatar
王进波 committed
194 195 196

新增一项

王进波's avatar
王进波 committed
197
![1534068106605](../imgs/1534068106605.png)
王进波's avatar
王进波 committed
198

王进波's avatar
王进波 committed
199
![1534068146056](../imgs/1534068146056.png)
王进波's avatar
王进波 committed
200 201 202 203 204 205 206

上图中 key 值如下,该项用于获取服务器的网卡名称

```shell
wmi.get["root\cimv2","select macaddress from Win32_NetworkAdapter where Name = '{#IFNAME}'"]
```

王进波's avatar
王进波 committed
207 208 209 210 211 212




## SINOPIA ——私有NPM仓库

王进波's avatar
王进波 committed
213 214 215 216
访问地址:192.168.12.1:4873

### Docker run

王进波's avatar
王进波 committed
217 218 219 220
```shell
sudo docker run --name sinopia -d -p 4873:4873 keyvanfatehi/sinopia:latest
```

王进波's avatar
王进波 committed
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
### Backups

```
docker run --volumes-from sinopia -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /opt/sinopia
```

Alternatively, host path for /opt/sinopia can be determined by running:

```
docker inspect sinopia
```

### Restore

```
docker stop sinopia
docker rm sinopia
docker run --name sinopia -d -p 4873:4873 keyvanfatehi/sinopia:latest
docker stop sinopia
docker run --volumes-from sinopia -v $(pwd):/backup ubuntu tar xvf /backup/backup.tar
docker start sinopia
王进波's avatar
王进波 committed
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
```



## L2TP-VPN-SERVER

```shell
docker run \
    --name ipsec-server \
    --env-file ./vpn.env \
    --restart=always \
    -p 500:500/udp \
    -p 4500:4500/udp \
    -v /lib/modules:/lib/modules:ro \
    -d --privileged \
    hwdsl2/ipsec-vpn-server
```

王进波's avatar
王进波 committed
260 261 262 263 264 265 266 267 268 269 270
vpn.env配置文件

```shell
# Define your own values for these variables
# - DO NOT put "" or '' around values, or add space around =
# - DO NOT use these special characters within values: \ " '
VPN_IPSEC_PSK=civvpn.vicp.net
VPN_USER=wohitech
VPN_PASSWORD=wohitech
```

王进波's avatar
王进波 committed
271 272 273 274 275 276 277 278 279 280 281 282
查看状态

```shell
docker exec -it ipsec-vpn-server ipsec status
```

查看连接

```shell
docker exec -it ipsec-vpn-server ipsec whack --trafficstatus
```

王进波's avatar
王进波 committed
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
## Calibre-web

参考地址:https://github.com/Technosoft2000/docker-calibre-web

```shell
docker create --name=calibre-web --restart=always \
-v /srv/calibre/books:/books \
-v /srv/calibre/config:/calibre-web/config \
-e USE_CONFIG_DIR=true \
-e SET_CONTAINER_TIMEZONE=true \
-e CONTAINER_TIMEZONE=Asia/Shanghai \
-e PGID=1000 -e PUID=1000 \
-p 8083:8083 \
technosoft2000/calibre-web
```

然后

```shell
docker start calibre-web
```

王进波's avatar
王进波 committed
305 306 307 308 309 310 311 312 313 314 315 316 317
### WordPress

```shell
sudo docker run \
--name wordpress \
--restart always \
-p 808:80 \
-e WORDPRESS_DB_HOST='192.168.12.38' \
-e WORDPRESS_DB_USER='root' \
-e WORDPRESS_DB_PASSWORD='000000' \
-d wordpress
```

王进波's avatar
王进波 committed
318 319 320 321 322 323 324 325 326 327 328 329
### PHPMyAdmin

```shell
sudo docker run \
--name phpmyadmin \
-d \
-e PMA_HOST=192.168.12.38 \
-e MYSQL_ROOT_PASSWORD=000000 \
-p 809:80 \
phpmyadmin/phpmyadmin
```