zabbix3.4源码安装过程

   

系统:red hat 7.0
Nginx版本:nginx-1.6.0
PHP版本:php-5.5.14
数据库:mysql-5.6.19
zabbix版本:zabbix-3.4.2

1 安装PHP

# yum install php.x86_64 php-cli.x86_64 php-fpm php-gd php-json php-ldap php-mbstring php-mysqlnd php-xml php-xmlrpc php-opcache php-simplexml php-bcmath.x86_64 -y

2 数据库安装与配置

# yum install mariadb.x86_64 mariadb-devel.x86_64 mariadb-server.x86_64 -y
# systemctl start mariadb.service
# mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, 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): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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, MariaDB 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...
 ... Success!
 - 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!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

3 下载安装zabbix

#  wget https://excellmedia.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.9/zabbix-3.4.9.tar.gz
#  tar -zxvf zabbix-3.4.9.tar.gz
#  cd zabbix-3.4.9
#./configure --prefix=/usr/local/zabbix user=zabbix group=zabbix --enable-server --enable-agent --enable-proxy --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 
# make instal

4 数据库设置

# mysql -u root -p
mysql> show databases;
mysql>CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
mysql>GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY "password";
mysql>FLUSH PRIVILEGES;
mysql>exit;
# cd database/mysql
# mysql -uroot -p zabbix < schema.sql && mysql -uroot -p zabbix < images.sql && mysql -uroot -p zabbix < data.sql

5 编辑默认安装配置文件

# vim /usr/local/zabbix/etc/zabbix_server.conf
ListenPort=10051
DBHost=localhost 
DBName=Zabbix
DBUser=Zabbix
DBPassword=password

6 配置zabbix

# cd /usr/local/src/zabbix-3.4.9/misc/init.d/tru64
# cp -r zabbix_* /etc/init.d/
# groupadd zabbix
# useradd -g zabbix zabbix
# cp -r /usr/local/zabbix/sbin/zabbix_* /usr/local/sbin/
# chmod +x /etc/init.d/zabbix* 
# /etc/init.d/zabbix_server restart
# /etc/init.d/zabbix_agentd restart

7 拷贝zabbix到网站目录

# cd /usr/local/src/zabbix-3.4.9/frontends/
# mkdir -p /usr/local/nginx/html/zabbix
# cp -ra php/* /usr/local/nginx/html/zabbix

8 访问zabbix

8-1 zabbix欢迎页面
8-2 Check of pre-requisites

报错信息如下:

-Minimum required size of PHP post is 16M (configuration option "post_max_size").
 -Minimum required limit on execution time of PHP scripts is 300 (configuration option "max_execution_time").
-Minimum required limit on input parse time for PHP scripts is 300 (configuration option "max_input_time").
 -Time zone for PHP is not set (configuration parameter "date.timezone").

解决方案:

# vim /etc/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai
# systemctl restart nginx
# systemctl restart php-fpm

默认账号Admin,密码zabbix

9 启用agentd

# vim /usr/local/zabbix/etc/zabbix_agentd.conf
LogFile=/usr/local/zabbix/log/zabbix_agentd.log
EnableRemoteCommands=0
Server=192.168.10.100
ServerActive=192.168.10.100
Hostname=192.168.10.100
# /etc/init.d/zabbix_agentd restart

10 几个安装之后经常碰到的问题:

1)本机zabbix_agentd不可用故障,“Received empty response from Zabbix Agent at [127.0.0.1]. Assuming that agent dropped connection because of access permissions.”调整zabbix_agentd 配置文件,修改server ip 地址 及Hostname 名称(需与Web页面中的主机名称保持一致)

# vim /usr/local/zabbix/etc/zabbix_agentd.conf
Server=127.0.0.1
ServerActive=192.168.10.100
Hostname=192.168.10.100

2)Too many processes on Zabbix server

Configuration-->Templates找到Template OS Linux点该行的 Triggers选择
Too many processes on {HOSTNAME}
Too many processes running on {HOST.NAME}
修改对应的告警值,或者直接停用disabled

3)Zabbix agent on Zabbix server is unreachable for 5 minutes3)

查看日志,发现:
64989:20190607:215829.116 failed to accept an incoming connection: connection from "192.168.0.151" rejected, allowed hosts: "127.0.0.1"
# vim /usr/local/zabbix/etc/zabbix_agentd.conf
122 Server=127.0.0.1
# /etc/init.d/zabbix_agentd restart

发表评论