1. 程式人生 > 實用技巧 >CentOS 7.5下,基於docker安裝zabbix

CentOS 7.5下,基於docker安裝zabbix

#配置阿里源
[root@server ~]# yum install -y wget
[root@server ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@server ~]# yum clean all
[root@server ~]# yum makecache

#配置映象加速
[root@server ~]# echo { "registry-mirrors": ["http://hub-mirror.c.163.com"] } >>/etc/docker/daemon.json


#安裝docker
[root@server ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
[root@server ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@server ~]# yum makecache fast
[root@server ~]# yum install -y docker-ce
[root@server ~]# systemctl start docker
[root@server ~]# systemctl enable docker

#建立持久化儲存

[root@server ~]# mkdir -p /data/zabbix/mysql
[root@server ~]# groupadd mysql
[root@server ~]# useradd mysql -g mysql
[root@server ~]# chown -R mysql.mysql  /data/zabbix/mysql
[root@server ~]# mkdir -p /data/zabbix/nginx
[root@server ~]# mkdir -p /data/zabbix/zabbix


[root@server ~]# docker run --name mysql-server -t \
      --restart=always  \
      -e MYSQL_DATABASE="zabbix" \
      -e MYSQL_USER="zabbix" \
      -e MYSQL_PASSWORD="zabbix_pwd" \
      -e MYSQL_ROOT_PASSWORD="root_pwd" \
      -v /data/zabbix/mysql:/var/lib/mysql \
      -d mysql:5.7
	  
#啟動ZABBIX-JAVA-GATEWAY
[root@server ~]# docker run --name zabbix-java-gateway -t -d zabbix/zabbix-java-gateway:latest

[root@server ~]# docker run --name zabbix-server-mysql -t \ --restart=always \ -e DB_SERVER_HOST="mysql-server" \ -e MYSQL_DATABASE="zabbix" \ -e MYSQL_USER="zabbix" \ -e MYSQL_PASSWORD="zabbix_pwd" \ -e MYSQL_ROOT_PASSWORD="root_pwd" \ --link mysql-server:mysql \ -p 10051:10051 \ -v /data/zabbix/zabbix/etc/localtime:/etc/localtime:ro \ -v /data/zabbix/zabbix/data/docker/zabbix/alertscripts:/usr/lib/zabbix/alertscripts \ -v /data/zabbix/zabbix/data/docker/zabbix/externalscripts:/usr/lib/zabbix/externalscripts \ -d zabbix/zabbix-server-mysql:latest \ --character-set-server=utf8 --collation-server=utf8_bin [root@server ~]# docker run --name zabbix-web-nginx-mysql -t \ --restart=always \ -e DB_SERVER_HOST="mysql-server" \ -e MYSQL_DATABASE="zabbix" \ -e MYSQL_USER="zabbix" \ -e MYSQL_PASSWORD="zabbix_pwd" \ -e MYSQL_ROOT_PASSWORD="root_pwd" \ --link mysql-server:mysql \ --link zabbix-server-mysql:zabbix-server \ -p 80:80 \ -d zabbix/zabbix-web-nginx-mysql:latest

192.168.22.8上安裝agent [root@agent ~]# docker run --name zabbix-agent \ -e ZBX_HOSTNAME="harbor.qa.com" \ -e ZBX_SERVER_HOST="192.168.22.200" \ -e ZBX_METADATA="harbor" \ -p 10050:10050 \ --privileged -d zabbix/zabbix-agent:latest