CentOS6.5安装zabbix3.0

Server端 搭建LAMP(Linux+Apache+Mysql+PHP)环境

1、安装MySQL

 #安装地址:https://dev.mysql.com/downloads/repo/yum/
yum install -y mysql-server mysql-devel
 service mysqld start
grep 'temporary password' /var/log/mysqld.log
mysql_secure_installation #MySQL安全配置向导
Enter current password for root (enter for none): <–初次运行直接回车
Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
Remove anonymous users? [Y/n] <– 是否删除匿名用户,生产环境建议删除,所以直接回车
Disallow root login remotely? [Y/n] <–是否禁止root远程登录,根据自己的需求选择Y/n并回车,建议禁止
Remove test database and access to it? [Y/n] <– 是否删除test数据库,直接回车
Reload privilege tables now? [Y/n] <– 是否重新加载权限表,直接回车
 mysql -uroot -p
mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbix';
mysql> flush privileges;
mysql> show databases;

2、安装PHP5.6

 rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
yum install php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldap
vim /etc/php.ini
date.timezone = Asia/Shanghai

3、安装依赖包、apache和zabbix-server相关包

  zabbix官网(www.zabbix.com)

1 yum -y install httpd libxml2-devel net-snmp-devel libcurl-devel OpenIPMI-libs fpingiksemel zabbix-server zabbix-web  zabbix-mysql zabbix-agent zabbix-web-mysql zabbix_get

3、源码包安装zabbix3.0

centos6有部分用户使用yum安装zabbix3.0以上版本时,引起服务不能正常启动,所以推荐使用源码安装,避免此问题。

 tar -zxf zabbix-3.0.8.tar.gz
cd zabbix-3.0.8
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
make && make install

3.1 拷贝服务启动脚本到/etc/init.d/目录

 cp misc/init.d/fedora/core/zabbix_server  /etc/init.d/
cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/

3.2 修改/etc/init.d/zabbix_server和/etc/init.d/zabbix_agent启动脚本,将

BASEDIR=/usr/local  --修改为-->  BASEDIR=/usr/local/zabbix

3.3 创建软链接

ln -s /usr/local/zabbix/etc /etc/zabbix

4、导入zabbix数据库

1 cd /usr/share/doc/zabbix-server-mysql/
2 gunzip create.sql.gz
3 mysql -uzabbix -pzabbix zabbix < create.sql

5、创建vhost.conf文件

 1 cd /etc/http/conf.d/
2 vim vhost.conf
3
4 # Zabbix monitoring system php web frontend
5 Alias /zabbix /usr/share/zabbix
6
7 <Directory "/usr/share/zabbix">
8 Options FollowSymLinks
9 AllowOverride None
10 Order allow,deny
11 Allow from all
12
13 <IfModule mod_php5.c>
14 php_value max_execution_time 300
15 php_value memory_limit 128M
16 php_value post_max_size 16M
17 php_value upload_max_filesize 2M
18 php_value max_input_time 300
19 php_value always_populate_raw_post_data -1
20 # php_value date.timezone Europe/Riga
21 </IfModule>
22 </Directory>
23
24 <Directory "/usr/share/zabbix/conf">
25 Order deny,allow
26 Deny from all
27 <files *.php>
28 Order deny,allow
29 Deny from all
30 </files>
31 </Directory>
32
33 <Directory "/usr/share/zabbix/app">
34 Order deny,allow
35 Deny from all
36 <files *.php>
37 Order deny,allow
38 Deny from all
39 </files>
40 </Directory>
41
42 <Directory "/usr/share/zabbix/include">
43 Order deny,allow
44 Deny from all
45 <files *.php>
46 Order deny,allow
47 Deny from all
48 </files>
49 </Directory>
50
51 <Directory "/usr/share/zabbix/local">
52 Order deny,allow
53 Deny from all
54 <files *.php>
55 Order deny,allow
56 Deny from all
57 </files>
58 </Directory>
/etc/init.d/httpd start  #启动服务

创建/etc/httpd/conf.d/zabbix.conf文件

 php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 32M
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

6、配置zabbix_server.conf文件

 cat /etc/zabbix/zabbix_server.conf | egrep -v "^$|^#"

 LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
DebugLevel=3
PidFile=/var/run/zabbix/zabbix_server.pid ##DB的地址或计算机名
DBHost=localhost DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
StartPollers=40
StartPollersUnreachable=20
StartTrappers=8
StartPingers=8
StartDiscoverers=8
StartHTTPPollers=8
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
HousekeepingFrequency=1
CacheSize=128M
StartDBSyncers=8
HistoryCacheSize=32M
HistoryIndexCacheSize=32M
TrendCacheSize=8M
ValueCacheSize=128M
Timeout=30
TrapperTimeout=120
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000 /etc/init.d/zabbix-server start

Agent端 

 yum -y install  zabbix zabbix-agent zabbix-sender    #安装必要软件

 vim /etc/zabbix/zabbix_agentd.conf
Server=172.16.209.130 #zabbix_server的IP地址 

重启服务

/etc/init.d/zabbix_agent restart

同理推荐源码安装 

 tar zxvf zabbix-3.0.8.tar.gz
cd zabbix-3.0.8
./configure --prefix=/usr/local/zabbix_agent --enable-agent
make && make install
5 cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
 BASEDIR=/usr/local/zabbix  ### vim /etc/init.d/zabbix_agent
service zabbix_agentd start
上一篇:安装zabbix3.0以及升级到5.0过程


下一篇:centos6.9 编译安装 zabbix-3.0.15