zabbix是一个基于WEB界面提供分布式系统监视以及网络监视功能的企业级的开源解决方案。--百度百科
zabbix主要有zabbix-server及zabbix-agent组成,zabbix-server是服务端,需要配置数据库;zabbix-agent相当于客户端,需要监控的服务器必须安装zabbix-agent,zabbix-server和zabbix-agent可以共存于同一台服务器。
-i 交互模式
-d 后端运行
-h 容器的hostname
--name 容器名称
--network 指定网卡
--ip 指定IP
-p 端口映射
-v /sys/fs/cgroup:/sys/fs/cgroup 解决mysql服务启动暂停的问题
--privileged=true与/usr/sbin/init 特权模式
[root@localhost ~]# docker run -i -d -h zabbix --name zabbix --network docker-br0 --ip 172.127.0.101 -p 3306:3306 -p 8080:80 --privileged=true -v /sys/fs/cgroup:/sys/fs/cgroup centos:7 /usr/sbin/init
[root@localhost ~]# docker exec -it zabbix /bin/bash
[root@zabbix /]# yum -y update
[root@zabbix /]# yum -y install vim zip unzip net-tools wget
[root@zabbix /]# mkdir Tools
[root@zabbix /]# cd Tools
[root@zabbix Tools]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
[root@zabbix Tools]# yum clean all
[root@zabbix Tools]# yum -y install zabbix-server-mysql
[root@zabbix Tools]# yum -y install centos-release-scl
[root@zabbix Tools]# vim /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
...
enabled=1
...
[root@zabbix Tools]# yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl
执行完rpm -ivh mysql57-community-release-el7-9.noarch.rpm
会在/etc/yum.repos.d/下生成两个文件
[root@zabbix Tools]# wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
[root@zabbix Tools]# rpm -ivh mysql57-community-release-el7-9.noarch.rpm
[root@zabbix Tools]# ll /etc/yum.repos.d/
mysql版本为5.7
[root@zabbix Tools]# cd /etc/yum.repos.d
[root@zabbix yum.repos.d]# mv mysql-community.repo mysql-community.repo.bak
[root@zabbix yum.repos.d]# vim mysql-community.repo
[root@zabbix yum.repos.d]# cat mysql-community.repo
[root@zabbix yum.repos.d]# rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
需在/etc/yum.repos.d路径下
[root@zabbix yum.repos.d]# yum -y install mysql-server
[root@zabbix yum.repos.d]# systemctl start mysqld # 启动服务
[root@zabbix yum.repos.d]# systemctl restart mysqld # 重启服务
[root@zabbix yum.repos.d]# systemctl stop mysqld # 停止服务
[root@zabbix yum.repos.d]# systemctl status mysqld # 查看状态
[root@zabbix yum.repos.d]# grep 'temporary password' /var/log/mysqld.log
[root@zabbix yum.repos.d]# mysql -uroot -p'kLop*uggJ0L6'
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Yangxiao214.';
user表中host的值为 % 代表任意的客户端,可替换成具体IP地址。
mysql> show databases;
mysql> use mysql
mysql> show tables
mysql> desc user;
mysql> select host,user from user;
mysql> update user set host='%' where user='root';
mysql> flush privileges;
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@localhost identified by 'Yangxiao214.';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> quit
[root@zabbix yum.repos.d]# cd /Tools/
[root@zabbix Tools]# wget https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.21.tar.gz
[root@zabbix Tools]# ll
[root@zabbix Tools]# tar -zxvf zabbix-5.0.21.tar.gz
[root@zabbix Tools]# cd zabbix-5.0.21/database/mysql/
[root@zabbix mysql]# mysql -uzabbix -p'Yangxiao214.'
mysql> use zabbix
mysql> source /Tools/zabbix-5.0.21/database/mysql/schema.sql;
mysql> source /Tools/zabbix-5.0.21/database/mysql/images.sql;
mysql> source /Tools/zabbix-5.0.21/database/mysql/data.sql;
mysql> quit;
/set nu 显示行号
/set nu! 取消显示行号
[root@zabbix mysql]# vim /etc/zabbix/zabbix_server.conf
[root@zabbix mysql]# grep ^DB /etc/zabbix/zabbix_server.conf
DBHost=localhost // 91行
DBName=zabbix // 100行
DBUser=zabbix // 116行
DBPassword=Yangxiao214. // 124行
[root@zabbix mysql]# vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
[root@zabbix mysql]# systemctl start zabbix-server httpd rh-php72-php-fpm # 启动
[root@zabbix mysql]# systemctl restart zabbix-server httpd rh-php72-php-fpm # 重启
[root@zabbix mysql]# systemctl stop zabbix-server httpd rh-php72-php-fpm # 停止
[root@zabbix mysql]# systemctl status zabbix-server httpd rh-php72-php-fpm # 查看
[root@zabbix mysql]# systemctl enable zabbix-server httpd rh-php72-php-fpm # 开机自启
[root@zabbix mysql]# cd Tools
[root@zabbix Tools]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
[root@zabbix Tools]# yum clean all
[root@zabbix Tools]# cd zabbix-5.0.21/database/mysql
[root@zabbix mysql]# yum -y install zabbix-agent
[root@zabbix mysql]# vim /etc/zabbix/zabbix_agentd.conf
DenyKey=system.run[*] // 85 行
Server=172.127.0.101 // 117 行,zabbix-server 的ip
ServerActive=172.127.0.101 // 158 行,zabbix-server 的ip
Hostname=zabbix // 169 行,zabbix-agent的hostname
[root@zabbix mysql]# systemctl start zabbix-agent # 启动
[root@zabbix mysql]# systemctl restart zabbix-agent # 重启
[root@zabbix mysql]# systemctl stop zabbix-agent # 停止
[root@zabbix mysql]# systemctl status zabbix-agent # 查看
[root@zabbix mysql]# systemctl enable zabbix-agent # 开机自启
[root@zabbix mysql]# firewall-cmd --zone=public --add-port=3306/tcp --permanent # 开放3306 端口
[root@zabbix mysql]# firewall-cmd --zone=public --list-ports # 查看开放列表
[root@zabbix mysql]# firewall-cmd --reload # 重载
http:ip:端口/zabbix,默认端口80,httpd服务端口
默认登录用户 Admin ,密码 zabbix
手机扫一扫
移动阅读更方便
你可能感兴趣的文章