0%

Zabbix(1)监控搭建

Zabbix是一款能够监控各种网络参数以及服务器健康性、完整性的分布式监控软件;

系统环境
Centos 7.3.1611
Selinux off
Iptables off
Firewalld off
软件环境
Zabbix 3.4.2
Httpd 2.4.6
Php 5.4.16
MariaDB 10.2.7

使用部署包安装zabbix

安装zabbix server

1
2
rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
yum install zabbix-server-mysql zabbix-web-mysql

配置数据库

1
2
3
4
5
6
vim /etc/yum.repos.d/MariaDB.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.3/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
1
2
3
4
5
6
7
8
9
10
11
12
yum install MariaDB-server MariaDB-client
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
systemctl start mariadb.service
systemctl enable mariadb.service
mysql_secure_installation
#初始化数据库,设置root密码
mysql -uroot -p<password>
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '<password>';
mysql> quit;
cd /usr/share/doc/zabbix-server-mysql-3.4.2
zcat create.sql.gz | mysql -uroot zabbix -p

配置zabbix_server.conf参数

vim /etc/zabbix/zabbix_server.conf

1
2
3
4
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

启动Zabbix Server

1
2
systemctl start zabbix-server
systemctl enable zabbix-server

编辑Zabbix前端的PHP配置

Zabbix前端的Apache配置文件位于 /etc/httpd/conf.d/zabbix.conf 。一些PHP设置已经完成了配置。

1
2
3
4
5
6
7
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

启动httpd

1
2
systemctl start httpd
systemctl enable httpd

配置zabbix前端

在浏览器中配置zabbix

Zabbix前端可以在浏览器中通过 http://zabbixserver/zabbix 进行访问。
zabbix_install

确认所有php参数都设置ok

zabbix_install

填写mysql数据库信息,用户名密码

zabbix_install
zabbix_install

确认所有配置信息正确

zabbix_install
zabbix_install

默认的用户名/密码为 Admin/zabbix

zabbix_install
zabbix_install

系统配置

配置中文界面

替换中文字体

在Windows系统里找一个中文字体(华文楷体)C:\Windows\Fonts\STKAITI.TTF上传到zabbix服务器替换掉默认的字体/usr/share/fonts/dejavu/DejaVuSans.ttf

开启中文支持

如果默认中文(zh_CN)支持被关闭,可以将zh_CN后边的false选项修改为true;

1
2
3
4
5
6
7
8
vim /usr/share/zabbix/include/locales.inc.php
function getLocales() {
return [
'en_GB' => ['name' => _('English (en_GB)'), 'display' => true],
'en_US' => ['name' => _('English (en_US)'), 'display' => true],
'bg_BG' => ['name' => _('Bulgarian (bg_BG)'), 'display' => false],
'zh_CN' => ['name' => _('Chinese (zh_CN)'), 'display' => true],
……

在web界面修改用户资料、语言

zabbix_install

启用zabbix server监控

安装zabbix agent

1
2
yum install zabbix-agent
systemctl start zabbix-agent

在配置-主机中启用zabbix server

zabbix_install

CentOS 6.x 安装Zabbix

CentOS 6.x 默认的php版本太低,需借助第三方源升级php;
建议PHP≥5.4 MySql≥5.6

1
2
3
4
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum -y install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-gd php-mysql php-bcmath php-ldap
rpm -ql zabbix-web | grep example.conf
cp /usr/share/doc/zabbix-web-3.4.8/httpd22-example.conf /etc/httpd/conf.d/zabbix.conf

zabbix_install
参考资料:
https://www.zabbix.com/documentation/3.4/zh/manual
http://www.rfyy.net/archives/1742.html
https://www.zabbix.com/documentation/3.4/manual/installation/install_from_packages/rhel_centos