Centos7.6系统下Zabbix监控平台部署
**
Centos7.6系统下Zabbix监控平台部署
**
环境准备
OS:CentOS 7.6
一、服务端部署步骤
1.关闭selinux和防火墙
[[email protected] ~]# systemctl stop firewalld.service
[[email protected] ~]# setenforce 0
2.安装Zabbix rpm包仓库
[[email protected] ~]# rpm -vhi http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
3.安装zabbix-server-mysql和zabbix-web-mysql
[[email protected] ~]# yum install -y zabbix-server-mysql zabbix-web-mysql
4.安装并且启动mysql5.6及初始化数据库信息
[[email protected] ~]# rpm -ivh http://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/mysql-community-release-el6-5.noarch.rpm
[[email protected] ~]# yum install -y mysql-community-server
[[email protected] ~]# systemctl start mysqld
[[email protected] ~]# /sbin/chkconfig mysqld on #开机启动
[[email protected] ~]# mysql_secure_installation #初始化数据库信息
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we’ll need the current
password for the root user. If you’ve just installed MySQL, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
Sorry, passwords do not match.
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables…
… Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
… Success!
Normally, root should only be allowed to connect from ‘localhost’. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
… Success!
By default, MySQL comes with a database named ‘test’ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
• Dropping test database…
ERROR 1008 (HY000) at line 1: Can’t drop database ‘test’; database doesn’t exist
… Failed! Not critical, keep moving…
• Removing privileges on test database…
… Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
… Success!
All done! If you’ve completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
5.创建zabbix数据库,创建zabbix账号
[[email protected] ~]# mysql -uroot -p
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbix.* to ‘zabbix’@‘localhost’ identified by ‘zabbix’; #注意后面密码带引号
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> Ctrl-C – exit!
6.导入默认的zabbix数据库信息
[[email protected] ~]# cd /usr/share/doc/zabbix-server-mysql-3.0.31/
[[email protected] zabbix-server-mysql-3.0.31]# zcat create.sql.gz | mysql zabbix -uzabbix -pzabbix
7.修改zabbix_server.conf的配置文件
[[email protected] ~]# vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
8.修改配置文件/etc/httpd/conf.d/zabbix.conf,时区改成 Asia/Shanghai
[[email protected] ~]# vi /etc/httpd/conf.d/zabbix.conf
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
9.启动apache/zabbix-server服务并设置为开机启动
[[email protected] ~]# systemctl start httpd
[[email protected] ~]# systemctl enable httpd
[[email protected] ~]# systemctl start zabbix-server
[[email protected] ~]# systemctl enable zabbix-server
10.访问网站,例如:http://本机IP/zabbix,如下图所示:
在检测信息时,可查看具体的报错信息进行不同的解决
选择mysql数据库,输入密码即可
host与port不需要修改,name自定义
确认信息,正确点击下一步
安装完成、点击finsh
进入登陆界面,账号Admin密码zabbix,注意A大写
二、客户端主机安装zabbix-agent
1.Linux下安装Zabbix agent
安装Zabbix rpm包仓库
[[email protected] ~]# rpm -vhi http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
Yum install -y zabbix-agent
vim /etc/zabbix/zabbix_agentd.conf
Server=127.0.0.1改为实际服务端地址
systemctl start zabbix-agent.service
登陆zabbix-server Web界面,Configuration–>Hosts–>Create host
点击Templates 设置关联模板Template OS Linux 并add。
现在去Configuration–> Hosts中查看刚刚新加的主机,availability已经变成绿色了,代表成功了。如下:
2.Windows下安装Zabbix agent
下载Windows版本的Zabbix agent安装包:
https://www.zabbix.com/cn/download_agents#tab:40LTS
下载和Zabbix server版本一致msi格式的Zabbix agent安装包:
注意:安装时需要正确填写Zabbix服务器的Host name和IP地址
Host name需要和Zabbix服务端Web页面上设置的主机名称一致
登陆zabbix-server Web界面,Configuration–>Hosts–>Create host,和上面linux的类似,点击Templates 设置关联模板Template OS Windows 并add。
默认安装好的路径是:C:\Program Files\Zabbix Agent\,里面有配置文件和日志文件
三、交换机监控配置
1.交换机需开启SNMP
2.zabbix web端配置,填写交换机地址
3.添加模板,选择Template SNMP Device
4.添加
5.查看SNMP颜色为绿色时表示配置成功
四、配置smtp外部邮箱实现邮件报警
- 配置报警媒介类型
2.配置接受报警的用户
3.配置报警内容
4.配置触发报警的条件
5.配置发送报警的持续时间
五、Zabbix中文图乱码
1、从Window服务器找到相应的字休复制到zabbix Server服务器上:
控制面板–>字体–>选择一种中文字库例如“楷体”(simkai.ttf)
2、将我们选择的字体文件上传到zabbix web服务,/usr/share/zabbix/fonts目录下(rpm安装目录)
3、修改此/usr/share/zabbix/include/defines.inc.php文件中字体的配置,将里面关于字体设置从graphfont替换成simkai
4、再次打开刚开的界面,发现乱码已经解决了,如下图所示: