docker下安裝zabbix
一、安裝docker
yum install docker
service docker start
chkconfig docker on
docker images
二、清除既往數(shù)據(jù)
殺死所有正在運(yùn)行的容器
docker kill $(docker ps -a -q)
刪除所有已經(jīng)停止的容器
docker rm $(docker ps -a -q)
刪除所有鏡像
docker rmi $(docker images -q)
其他命令
docker stop mysql-server
docker rm mysql-server
docker ps
docker images
三、安裝mysql
https://hub.docker.com/r/mysql/mysql-server/
docker pull mysql/mysql-server:5.7.22-1.1.5
四、配置mysql
docker啟動(dòng)
docker run -it --name mysql-server -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_USER=zabbix -e MYSQL_PASSWORD=zabbix -e MYSQL_DATABASE=zabbix -d mysql/mysql-server:5.7.22-1.1.5 --character-set-server=utf8 --collation-server=utf8_general_ci
進(jìn)入shell
docker exec -it mysql-server bash
修改配置
yum install vim -y
vim /etc/my.cnf
[mysqld]
default_authentication_plugin=mysql_native_password
修改權(quán)限
select host, user from mysql.user;
GRANT ALL PRIVILEGES ON *.* TO 'zabbix'@'%';
flush privileges;
重啟
exit
docker restart mysql-server
修改密碼
docker exec -it mysql-server bash
mysqladmin -uroot -proot password root
mysqladmin -uzabbix -pzabbix password zabbix
五、確認(rèn)mysql
docker logs mysql-server
mysql -uzabbix -h 47.74.242.58 -pzabbix
六、安裝zabbix-server
https://hub.docker.com/r/zabbix/
docker pull zabbix/zabbix-server-mysql:centos-3.4.*
七、配置zabbix-server
docker run --name zabbix-server -p 10051:10051 -e DB_SERVER_HOST="47.74.242.58" -e MYSQL_USER="zabbix" -e MYSQL_PASSWORD="zabbix" -e MYSQL_DATABASE='zabbix' -d zabbix/zabbix-server-mysql:latest
八、確認(rèn)zabbix-server
docker ps
docker logs zabbix-server
docker exec -it zabbix-server bash
九、安裝zabbix-web
https://hub.docker.com/r/zabbix/zabbix-web-nginx-mysql/
docker pull zabbix/zabbix-web-nginx-mysql:centos-3.4-latest
十、配置zabbix-web
docker run --name zabbix-web -p 80:80 --link mysql-server:mysql-server --link zabbix-server:zabbix-server -e DB_SERVER_HOST="47.74.242.58" -e MYSQL_USER="zabbix" -e MYSQL_PASSWORD="zabbix" -e ZBX_SERVER_HOST="47.74.242.58" -e PHP_TZ="Asia/Shanghai" -d zabbix/zabbix-web-nginx-mysql:centos-3.4-latest
十一、登錄
Admin/zabbix
十二、客戶端配置
windows
下載
https://www.zabbix.com/download_agents
修改
zabbix_agentd.win.conf
Server=svn.wisq.cn(服務(wù)器)
ServerActive=svn.wisq.cn(服務(wù)器)
Hostname=127.0.0.1(最好是本機(jī)IP)
安裝服務(wù)
cd C:\zabbix
zabbix_agentd.exe -i -c zabbix_agentd.win.conf
啟動(dòng)服務(wù)
services.msc
10053錯(cuò)誤
linux
https://www.zabbix.com/download
rpm -i http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
yum install zabbix-agent
rpm -ql zabbix-agent
vim /etc/zabbix/zabbix_agentd.conf
配置防火墻
vi /etc/sysconfig/iptables
-A INPUT -s 58.48.186.194 -m state --state NEW -m tcp -p tcp --dport 10050:10051 -j ACCEPT
-A INPUT -s 58.48.186.194 -m state --state NEW -m udp -p udp --dport 10050:10051 -j ACCEPT
安裝中文語(yǔ)言包
yum reinstall kde-l10n-Chinese -y
yum reinstall glibc-common -y
localedef -c -f UTF-8 -i zh_CN zh_CN.utf8
locale -a
增加中文字體
從主機(jī)復(fù)制到容器sudo docker cp host_path containerID:container_path
從容器復(fù)制到主機(jī)sudo docker cp containerID:container_path host_path
docker cp msyh.ttf zabbix-web:/usr/share/zabbix/fonts
cd /usr/share/zabbix/fonts
vim /usr/share/zabbix/include/defines.inc.php
docker cp zabbix-web:/usr/share/zabbix/include/defines.inc.php defines.inc.php
拷貝出來替換如下兩處(DejaVuSans.ttf或graphfont.ttf)
define('ZBX_GRAPH_FONT_NAME','msyh'); // font file name
define('ZBX_FONT_NAME', msyh');
docker cp defines.inc.php zabbix-web:/usr/share/zabbix/include/defines.inc.php
安裝郵件告警
yum install sendmail -y
yum install mailx -y
service sendmail restart
service mailx restart
十三、備份及回復(fù)
docker ps
容器保存為鏡像
docker commit -p mysql-server mysql-server
docker commit -p zabbix-server zabbix-server
docker commit -p zabbix-web zabbix-web
docker images
鏡像保存到本地
docker save -o mysql-server.tar mysql-server
docker save -o zabbix-server.tar zabbix-server
docker save -o zabbix-web.tar zabbix-web
加載本地鏡像
docker load -i mysql-server.tar