yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum makecache fast
sudo yum -y install docker-ce
sudo systemctl start docker
docker run hello-world
修改或新增 /etc/docker/daemon.json
vi /etc/docker/daemon.json systemctl restart docker.service
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
mkdir -p /data/zabbix/mysql
chown -R mysql.mysql /data/zabbix/mysql
docker run -p 3306:3306 --name mysql-server \
--restart always -v /etc/localtime:/etc/localtime \
-v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs \
-v $PWD/data:/var/zabbix/mysql -e MYSQL_DATABASE=zabbix \
-e MYSQL_USER=zabbix -e MYSQL_PASSWORD=zabbix -e MYSQL_ROOT_PASSWORD=root \
-d mysql:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
docker cp ./my.cnf [容器id]:/etc/mysql/mysql.conf.d
docker run --name zabbix-java-gateway \
--restart always -t -d zabbix/zabbix-java-gateway:latest
docker run --name zabbix-server-mysql --restart always -t \
-e DB_SERVER_HOST="mysql-server" \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix" \
-e MYSQL_ROOT_PASSWORD="root" \
-e PHP_TZ="Asia/Shanghai" \
-v /etc/timezone:/etc/timezone \
-v /etc/localtime:/etc/localtime \
--link mysql-server:mysql \
-p 10051:10051 \
-d zabbix/zabbix-server-mysql:centos-4.2.0
>>>>>一下为可选参数
>>>>> -e ZBX_JAVAGATEWAY="zabbix-java-gateway" \
>>>>> --link zabbix-java-gateway:zabbix-java-gateway \
docker run --name zabbix-web-nginx-mysql --restart always -t \
-e DB_SERVER_HOST="mysql-server" \
-e MYSQL_DATABASE="zabbix" \
-e MYSQL_USER="zabbix" \
-e MYSQL_PASSWORD="zabbix" \
-e MYSQL_ROOT_PASSWORD="root" \
-e PHP_TZ="Asia/Shanghai" \
-v /etc/timezone:/etc/timezone \
-v /etc/localtime:/etc/localtime \
--link mysql-server:mysql \
--link zabbix-server-mysql:zabbix-server \
-p 80:80 \
-d zabbix/zabbix-web-nginx-mysql:centos-4.2.0
这里主要是监控Linux服务器
docker run --name zabbix-agent \
-e ZBX_HOSTNAME="Zabbix server" \
--restart always -e ZBX_SERVER_HOST="zabbix-server-mysql"\
--link zabbix-server-mysql:zabbix-server -p 10050:10050\
-d zabbix/zabbix-agent:latest
#192.168.17.130需要替换成自己的服务器地址
curl -s -XPOST -H "Content-Type: application/json-rpc" -d '{ "jsonrpc": "2.0", "method": "user.login", "params": { "user": "Admin", "password": "zabbix" }, "id": 1, "auth": null}'
http://192.168.17.130/zabbix/api_jsonrpc.php
# 上面官网的地址是有问题的
# 要去掉zabbix这个名字
curl -s -XPOST -H "Content-Type: application/json-rpc" -d '{ "jsonrpc": "2.0", "method": "user.login", "params": { "user": "Admin", "password": "zabbix" }, "id": 1, "auth": null}' http://192.168.17.130/api_jsonrpc.php