[root@os3 ~]# cat /etc/redhat-release CentOS Linux release 7.7.1908 (Core)
关闭selinux
[root@os3 ~]# setenforce 0 setenforce: SELinux is disabled
[root@os3 ~]# getenforce Disabled
安装zabbix server
rpm -i https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
yum install zabbix-server-mysql zabbix-get -y
yum install zabbix-web-mysql -y
zabbix的几个重要组件
zabbix-server-mysql 提供zabbix-server服务 zabbix-proxy-mysql 提供zabbix的代理服务,可以实现分布式监控,减轻zabbix-server的压力 zabbix-web-mysql 提供httpd服务 zabbix-get 提供检查是否能正确获取到zabbix的监控脚本key的监控值 zabbix-agent 提供zabbix-agent服务
安装完zabbix server后,会有以下文件:
[root@os3 ~]# rpm -ql zabbix-server-mysql
/etc/logrotate.d/zabbix-server
/etc/zabbix/zabbix_server.conf
/usr/lib/systemd/system/zabbix-server.service
/usr/lib/tmpfiles.d/zabbix-server.conf
/usr/lib/zabbix/alertscripts
/usr/lib/zabbix/externalscripts
/usr/sbin/zabbix_server_mysql
/usr/share/doc/zabbix-server-mysql-3.0.31
/usr/share/doc/zabbix-server-mysql-3.0.31/AUTHORS
/usr/share/doc/zabbix-server-mysql-3.0.31/COPYING
/usr/share/doc/zabbix-server-mysql-3.0.31/ChangeLog
/usr/share/doc/zabbix-server-mysql-3.0.31/NEWS
/usr/share/doc/zabbix-server-mysql-3.0.31/README
/usr/share/doc/zabbix-server-mysql-3.0.31/create.sql.gz
/usr/share/man/man8/zabbix_server.8.gz
/var/log/zabbix /var/run/zabbix
配置数据库
systemctl start mysqld
systemctl enable mysqld.service//开机自启
gunzip /usr/share/doc/zabbix-server-mysql-3.0.31/create.sql.gz //解压create.sql.gz包
mysql_secure_installation //初始化数据库信息 首先是设置密码,会提示先输入密码.。
Enter current password for root (enter for none):<–初次运行直接回车 设置密码
Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
New password: <– 设置root用户的密码
Re-enter new password: <– 再输入一次你设置的密码 其他配置
Remove anonymous users? [Y/n] <– 是否删除匿名用户,回车
Disallow root login remotely? [Y/n] <–是否禁止root远程登录,回车,
Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车
Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车
初始化MariaDB完成;
登录数据库
mysql -uroot -p密码 //上面设置的密码
mysql> create database zabbix charset 'utf8';
Query OK, 1 row affected (0.00 sec)
mysql> grant all on zabbix.* to zabbix@'localhost' identified by '123123';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
[root@os3 ~]# rpm -ql zabbix-server-mysql
/etc/logrotate.d/zabbix-server
/etc/zabbix/zabbix_server.conf
/usr/lib/systemd/system/zabbix-server.service
/usr/lib/tmpfiles.d/zabbix-server.conf
/usr/lib/zabbix/alertscripts
/usr/lib/zabbix/externalscripts
/usr/sbin/zabbix_server_mysql
/usr/share/doc/zabbix-server-mysql-3.0.31
/usr/share/doc/zabbix-server-mysql-3.0.31/AUTHORS
/usr/share/doc/zabbix-server-mysql-3.0.31/COPYING
/usr/share/doc/zabbix-server-mysql-3.0.31/ChangeLog
/usr/share/doc/zabbix-server-mysql-3.0.31/NEWS
/usr/share/doc/zabbix-server-mysql-3.0.31/README
/usr/share/doc/zabbix-server-mysql-3.0.31/create.sql.gz
/usr/share/man/man8/zabbix_server.8.gz /var/log/zabbix /var/run/zabbix
进入到/usr/share/doc/zabbix-server-mysql-3.0.31
这个目录下面上面解压了create.sql.gz包
[root@os3 zabbix-server-mysql-3.0.31]# ls AUTHORS ChangeLog COPYING create.sql NEWS README
执行命令建表
mysql -uroot -p -Dzabbix < create.sql
Enter password: //输入数据库密码
查看表
[root@os3 ~]# mysql -uroot -p123456
mysql> mysql> show databases;
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| zabbix |
+--------------------+
4 rows in set (0.01 sec)
切换数据库
mysql> use zabbix;
Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A
查看表
Database changed mysql> show tables;
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
| autoreg_host |
| conditions |
| config |
| dbversion |
| dchecks |
| dhosts |
| drules |
| dservices |
| escalations |
| events |
| expressions |
| functions |
| globalmacro |
| globalvars |
| graph_discovery |
| graph_theme |
| graphs |
| graphs_items |
| group_discovery |
| group_prototype |
| groups |
| history |
| history_log |
| history_str |
| history_text |
| history_uint |
| host_discovery |
| host_inventory |
| hostmacro |
| hosts |
| hosts_groups |
| hosts_templates |
| housekeeper |
| httpstep |
| httpstepitem |
| httptest |
| httptestitem |
| icon_map |
| icon_mapping |
| ids |
| images |
| interface |
| interface_discovery |
| item_application_prototype |
| item_condition |
| item_discovery |
| items |
| items_applications |
| maintenances |
| maintenances_groups |
| maintenances_hosts |
| maintenances_windows |
| mappings |
| media |
| media_type |
| opcommand |
| opcommand_grp |
| opcommand_hst |
| opconditions |
| operations |
| opgroup |
| opinventory |
| opmessage |
| opmessage_grp |
| opmessage_usr |
| optemplate |
| profiles |
| proxy_autoreg_host |
| proxy_dhistory |
| proxy_history |
| regexps |
| rights |
| screen_user |
| screen_usrgrp |
| screens |
| screens_items |
| scripts |
| service_alarms |
| services |
| services_links |
| services_times |
| sessions |
| slides |
| slideshow_user |
| slideshow_usrgrp |
| slideshows |
| sysmap_element_url |
| sysmap_url |
| sysmap_user |
| sysmap_usrgrp |
| sysmaps |
| sysmaps_elements |
| sysmaps_link_triggers |
| sysmaps_links |
| timeperiods |
| trends |
| trends_uint |
| trigger_depends |
| trigger_discovery |
| triggers |
| users |
| users_groups |
| usrgrp |
| valuemaps |
+----------------------------+
113 rows in set (0.00 sec)
mysql>
ctrl +c 退出数据库
编辑zabbix配置文件/etc/zabbix/zabbix_server.conf
文件中都有需要将前面注释去掉
ListenPort=10051 //zabbix服务端监听的端口默认
LogType=file //file表示使用指定文件作为日志输出,console表示将日志发往控制台
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=50 //日志文件达到多大时自动转储,单位MB
DBHost=localhost //主机部署,配置
localhost DBName=zabbix //zabbix server所使用数据库的名字
DBUser=zabbix //zabbix server登陆数据库使用的用户名
DBPassword=123123 //zabbix server登陆数据库的密码
DBPort=3306 //zabbix server登陆数据库使用的端口号
DBSocket=/var/lib/mysql/mysql.sock //zabbix server登陆数据库用的socket文件
zabbix-server端配置完成,启动zabbix-server,设置开机自启
systemctl enable zabbix-server
systemctl start zabbix-server
下面配置zabbix-web安装的时候依赖包都装上了,检查一下
yum install httpd php php-mysql php-mbstring php-gd php-bcmath php-ldap php-xml
yum install zabbix-web-mysql zabbix-web
vi /etc/httpd/conf.d/zabbix.conf
修改配置文件/etc/httpd/conf.d/zabbix.conf
修改时区为东八区
php_value date.timezone Asia/Shanghai
启动访问设置开机自启
systemctl start httpd.service systemctl enable httpd.service
zabbix初始化配置
浏览器访问http://ip地址/zabbix
基本上没有问题下一步下一步即可
初始化MySQL数据库时,创建了zabbix数据库,配置数据库名和用户名为zabbix,因MySQL安装在本地所以是localhost(不需要更改)
这里填zabbix server的信息,端口配置文件里面写的是10051,不做更改 name名:可随意
检查配置页面,查看配置无误直下一步即可
点击finish即可
默认登录账号为admin 密码为zabbix
安装zabbix agent
被监控服务器需要安装agent
rpm -i https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
yum install zabbix-agent zabbix-sender
编辑配置文件
vim /etc/zabbix/zabbix_agentd.conf
Server=zabbix服务端地址 //安装完整zabbix主机
ServerActive=zabbix服务端地址 //安装完整zabbix主
Hostname=zabbix添加主机时使用的名字 //新添加被监控的主机名称
启动zabbix-agent服务,设置开机自启
systemctl start zabbix-agent
systemctl enable zabbix-agent
登录web管理页面
点击配置----主机---点击启用
刚安装完为英文界面,需要更改为中文的话;
点击右上角标记
修改为中文
点击update即可;