写在前面
关于监控的重要性、多样化,我就不介绍了,这里推荐一篇zabbix介绍的文章,我觉得这位大佬写的蛮好的。
zabbix 安装
1. 环境如下
[root@zabbix ~]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@zabbix ~]# uname -r
3.10.0-514.el7.x86_64
2. 添加zabbix仓库
[root@zabbix ~]# rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
[root@zabbix ~]# yum -y install yum-utils
[root@zabbix ~]# yum-config-manager --enable rhel-7-server-optional-rpms
3. 安装zabbix相关软件
[root@zabbix ~]# yum install -y zabbix-server-mysql zabbix-web-mysql httpd php zabbix-agent zabbix-get mariadb-server
4. 修改配置
a) 指定zabbix数据库密码
[root@zabbix ~]# vim /etc/zabbix/zabbix_server.conf
DBPassword=zabbix
b) 修改时区
[root@zabbix ~]# vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
5. 启动数据库,创建zabbix库并授权
[root@zabbix ~]# systemctl start mariadb.service
[root@zabbix ~]# systemctl enable mariadb.service
# 默认数据库密码为空,修改密码
[root@zabbix ~]# mysqladmin -uroot -p password
[root@zabbix ~]# mysql -uroot -p
# 此处密码和zabbix_server.conf配置文件中的一致
MariaDB [(none)]> grant all on zabbix.* to zabbix@localhost identified by 'zabbix';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> q
# 在zabbix库中导入相关表信息。
[root@zabbix ~]# zcat /usr/share/doc/zabbix-server-mysql-4.0.9/create.sql.gz | mysql -uzabbix -p zabbix
Enter password:
6. 启动zabbix服务
[root@zabbix ~]# systemctl start zabbix-server.service httpd.service
[root@zabbix ~]# systemctl enable zabbix-server.service httpd.service
[root@zabbix ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 9332/mysqld
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 987/sshd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 9611/zabbix_server
tcp6 0 0 :::80 :::* LISTEN 9609/httpd
tcp6 0 0 :::22 :::* LISTEN 987/sshd
tcp6 0 0 :::10051 :::* LISTEN 9611/zabbix_server
7. 接下来就是zabbix图形化配置,上图~。(进入网页端需要在IP地址后面加上/zabbix的后缀哟)







8. 登入zabbix web后,发现首页有个告警信息,如下:

# 因为我在本机也安装zabbix-agent但是没有启动,所以报警,启动就好了。
[root@zabbix ~]# systemctl start zabbix-agent.service

写作不易,转载请注明出处,谢谢~~