CentOS6.5安装zabbix3.0
Server端 搭建LAMP(Linux+Apache+Mysql+PHP)环境
1、安装MySQL
1 #安装地址:https://dev.mysql.com/downloads/repo/yum/ 2 yum install -y mysql-server mysql-devel
1 service mysqld start 2 grep 'temporary password' /var/log/mysqld.log 3 mysql_secure_installation #MySQL安全配置向导 4 Enter current password for root (enter for none): <–初次运行直接回车 5 Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车 6 Remove anonymous users? [Y/n] <– 是否删除匿名用户,生产环境建议删除,所以直接回车 7 Disallow root login remotely? [Y/n] <–是否禁止root远程登录,根据自己的需求选择Y/n并回车,建议禁止 8 Remove test database and access to it? [Y/n] <– 是否删除test数据库,直接回车 9 Reload privilege tables now? [Y/n] <– 是否重新加载权限表,直接回车
1 mysql -uroot -p 2 mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin; 3 mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbix'; 4 mysql> flush privileges; 5 mysql> show databases;
2、安装PHP5.6
1 rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm 2 yum install php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldap 3 vim /etc/php.ini 4 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以上版本时,引起服务不能正常启动,所以推荐使用源码安装,避免此问题。
1 tar -zxf zabbix-3.0.8.tar.gz 2 cd zabbix-3.0.8 3 ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 4 make && make install
3.1 拷贝服务启动脚本到/etc/init.d/目录
1 cp misc/init.d/fedora/core/zabbix_server /etc/init.d/ 2 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文件
1 php_value max_execution_time 300 2 php_value memory_limit 128M 3 php_value post_max_size 32M 4 php_value upload_max_filesize 2M 5 php_value max_input_time 300 6 php_value always_populate_raw_post_data -1 7 php_value date.timezone Asia/Shanghai
6、配置zabbix_server.conf文件
1 cat /etc/zabbix/zabbix_server.conf | egrep -v "^$|^#" 2 3 LogFile=/var/log/zabbix/zabbix_server.log 4 LogFileSize=0 5 DebugLevel=3 6 PidFile=/var/run/zabbix/zabbix_server.pid 7 8 ##DB的地址或计算机名 9 DBHost=localhost 10 11 DBName=zabbix 12 DBUser=zabbix 13 DBPassword=zabbix 14 StartPollers=40 15 StartPollersUnreachable=20 16 StartTrappers=8 17 StartPingers=8 18 StartDiscoverers=8 19 StartHTTPPollers=8 20 SNMPTrapperFile=/var/log/snmptrap/snmptrap.log 21 HousekeepingFrequency=1 22 CacheSize=128M 23 StartDBSyncers=8 24 HistoryCacheSize=32M 25 HistoryIndexCacheSize=32M 26 TrendCacheSize=8M 27 ValueCacheSize=128M 28 Timeout=30 29 TrapperTimeout=120 30 AlertScriptsPath=/usr/lib/zabbix/alertscripts 31 ExternalScripts=/usr/lib/zabbix/externalscripts 32 LogSlowQueries=3000
/etc/init.d/zabbix-server start
Agent端
1 yum -y install zabbix zabbix-agent zabbix-sender #安装必要软件 2 3 vim /etc/zabbix/zabbix_agentd.conf 4 Server=172.16.209.130 #zabbix_server的IP地址
重启服务
/etc/init.d/zabbix_agent restart
同理推荐源码安装
1 tar zxvf zabbix-3.0.8.tar.gz 2 cd zabbix-3.0.8 3 ./configure --prefix=/usr/local/zabbix_agent --enable-agent 4 make && make install 5 cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
6BASEDIR=
/usr/local/zabbix ### vim /etc/init.d/zabbix_agent
7 service zabbix_agentd start