zabbix监控
两台虚拟机分别:ip192.168.72.4(A)监控端 和ip192.168.72.5(B)被监控端
1.关掉防火墙 AB
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
2.安装时间同步的命令 AB
[root@localhost ~]# yum -y install ntpdate
测试网络能否ping通
[root@localhost ~]# ping baidu.com
清理yum源
[root@localhost ~]# yum clean all
时间同步AB
[root@localhost ~]# ntpdate pool.ntp.org
3.传zabbix.repo yum源 A
上传到/etc/yum.repos.d里
传到B里
[root@localhost yum.repos.d]# scp zabbix.repo 192.168.72.5:/etc/yum.repos.d/ (Bip)
zabbix.repo的内容
[root@localhost yum.repos.d]# cat zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=http://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/$basearch/debuginfo/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=0
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://mirrors.aliyun.com/zabbix/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=0
[root@localhost yum.repos.d]#
4.安装zabbix相关组件A
[root@localhost yum.repos.d]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent mariadb mariadb-server
5.设置数据库为开机自启,启动数据库A
[root@localhost yum.repos.d]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@localhost yum.repos.d]# systemctl start mariadb
6.创建zabbix库A
create database zabbix创建数据库
character set utf8设置数据库的字符集
collate数据库的校对规则
进入数据库
[root@localhost yum.repos.d]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.65-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
创建zabbix库
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
7.创建授权本地用户登入A
MariaDB [(none)]> grant all on zabbix.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
8.刷新授权表A
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
9.导入zabbix初始数据库A
[root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql-4.4.10/create.sql.gz | mysql -uzabbix -pzabbix zabbix
[root@localhost ~]#
查看表是否导入进入
MariaDB [(none)]> use zabbix;
MariaDB [zabbix]> show tables;
10.编辑zabbix-server的配置文件 A
[root@localhost ~]# yum -y install vim
[root@localhost ~]# vim /etc/zabbix/zabbix_server.conf [root@localhost ~]# cat /etc/zabbix/zabbix_server.conf | grep -v "^#" | sed '/^$/d' | grep DB
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
[root@localhost ~]#
11.开启三个服务 A
[root@localhost ~]# systemctl enable httpd zabbix-server zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@localhost ~]# systemctl start httpd zabbix-server zabbix-agent
[root@localhost ~]#
12.查看端口号
10050是zabbix_agentd
10051是zabbix_server
[root@localhost ~]# yum -y install net-tools
[root@localhost ~]# netstat -lptnu | egrep "80|10050|10051"
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 7594/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 7595/zabbix_server
tcp6 0 0 :::10050 :::* LISTEN 7594/zabbix_agentd
tcp6 0 0 :::10051 :::* LISTEN 7595/zabbix_server
tcp6 0 0 :::80 :::* LISTEN 7589/httpd
[root@localhost ~]#
13.浏览器访问A/zabbix点Next step A
解决报错:Time zone for PHP is not set (configuration parameter “date.timezone”).
设置时间戳:date.timezone = Asia/Shanghai亚洲上海
[root@localhost ~]# vim /etc/php.ini
[root@localhost ~]# cat /etc/php.ini | grep -v "^;" | grep date.timezonedate.timezone = Asia/Shanghai
[root@localhost ~]# systemctl restart httpd
再访问A/zabbix