[经验分享] CentOS 6.4x64安装部署zabbix-2.4.5 [复制链接]

一.部署环境  

    系统:CentOS 6.4x64 最小化安装  

    Server:192.168.3.28

    Client:192.168.3.29

二.基础软件包安装

    在server安装基础软件包,这里的环境使用yum安装,如果使用源码安装也是可以的。

1
[iyunv@zabbix-server ~]# yum -y install wget vim tree gcc gcc-c++ autoconf httpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-bcmath mysql-connector-odbc mysql-devel libdbi-dbd-mysql net-snmp net-snmp-devel curl-devel



    启动httpd、mysql并设置成开机自动启动

1
2
3
4
[iyunv@zabbix-server ~]# service httpd start
[iyunv@zabbix-server ~]# service mysqld start
[iyunv@zabbix-server ~]# chkconfig httpd on
[iyunv@zabbix-server ~]# chkconfig mysqld on



    在iptables中放行80,10050,10051端口。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[iyunv@zabbix-server ~]# iptables -I INPUT -p tcp -m multiport --destination-port 80,10050:10051 -j ACCEPT

#查看防火墙结果
[iyunv@zabbix-server ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           multiport dports 80,10050:10051
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22
REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

#保存iptables规则
[iyunv@zabbix-server ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]



三.配置PHP参数

    zabbix的运行需要特定的php参数支持,修改如下

1
2
3
4
5
6
[iyunv@zabbix-server ~]# sed -i "s@;date.timezone [email protected] = Asia/Shanghai@g" /etc/php.ini
[iyunv@zabbix-server ~]# sed -i "s@max_execution_time = 30@max_execution_time = 300@g" /etc/php.ini
[iyunv@zabbix-server ~]# sed -i "s@post_max_size = 8M@post_max_size = 32M@g" /etc/php.ini
[iyunv@zabbix-server ~]# sed -i "s@max_input_time = 60@max_input_time = 300@g" /etc/php.ini
[iyunv@zabbix-server ~]# sed -i "s@memory_limit = 128M@memory_limit = 128M@g" /etc/php.ini
[iyunv@zabbix-server ~]# sed -i "s@;mbstring.func_overload = [email protected]_overload = 2@g" /etc/php.ini



    修改httpd的FQDN错误,重启httpd服务

1
2
3
4
[iyunv@zabbix-server ~]# echo "ServerName localhost:80" >>/etc/httpd/conf/httpd.conf
[iyunv@zabbix-server ~]# /etc/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]



四.下载zabbix-2.4.5.tar.gz

1
[iyunv@zabbix-server ~]# wget http://jaist.dl.sourceforge.net/ ... zabbix-2.4.5.tar.gz



五.添加zabbix用户和组

1
2
[iyunv@zabbix-server ~]# groupadd -g 201 zabbix
[iyunv@zabbix-server ~]# useradd -g zabbix -u 201 -s /sbin/nologin zabbix



六.安装zabbix-server端

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
[iyunv@zabbix-server ~]# tar xf zabbix-2.4.5.tar.gz
[iyunv@zabbix-server ~]# cd zabbix-2.4.5
[iyunv@zabbix-server zabbix-2.4.5]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-proxy --enable-agent --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl
[iyunv@zabbix-server zabbix-2.4.5]# make && make install

#创建zabbix数据库以及相关表
[iyunv@zabbix-server zabbix-2.4.5]# mysql -e "create database zabbix default charset utf8;"
[iyunv@zabbix-server zabbix-2.4.5]# mysql -e "grant all on zabbix.* to zabbix@localhost identified by 'zabbix';"
[iyunv@zabbix-server zabbix-2.4.5]# mysql -uzabbix -pzabbix zabbix<./database/mysql/schema.sql
[iyunv@zabbix-server zabbix-2.4.5]# mysql -uzabbix -pzabbix zabbix<./database/mysql/images.sql
[iyunv@zabbix-server zabbix-2.4.5]# mysql -uzabbix -pzabbix zabbix<./database/mysql/data.sql

#配置软连接和启动文件信息
[iyunv@zabbix-server zabbix-2.4.5]# mkdir /var/log/zabbix
[iyunv@zabbix-server zabbix-2.4.5]# chown zabbix.zabbix /var/log/zabbix
[iyunv@zabbix-server zabbix-2.4.5]# ln -s /usr/local/zabbix/etc/ /etc/zabbix
[iyunv@zabbix-server zabbix-2.4.5]# ln -s /usr/local/zabbix/bin/* /usr/bin/
[iyunv@zabbix-server zabbix-2.4.5]# ln -s /usr/local/zabbix/sbin/* /usr/sbin/
[iyunv@zabbix-server zabbix-2.4.5]# cp /root/zabbix-2.4.5/misc/init.d/fedora/core/zabbix_* /etc/init.d
[iyunv@zabbix-server zabbix-2.4.5]# chmod 755 /etc/init.d/zabbix_*

#修改/etc/init.d目录下的zabbix_server和zabbix_agentd启动文件
[iyunv@zabbix-server zabbix-2.4.5]# sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" /etc/init.d/zabbix_server
[iyunv@zabbix-server zabbix-2.4.5]# sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" /etc/init.d/zabbix_agentd

#修改/etc/zabbix/zabbix_server.conf
[iyunv@zabbix-server zabbix-2.4.5]# sed -i "s@DBUser=root@DBUser=zabbix@g" /etc/zabbix/zabbix_server.conf
[iyunv@zabbix-server zabbix-2.4.5]# sed -i "s@#DBPassword=@DBPassword=zabbix@g" /etc/zabbix/zabbix_server.conf
[iyunv@zabbix-server zabbix-2.4.5]# sed -i "s@# DBPassword=@DBPassword=zabbix@g" /etc/zabbix/zabbix_server.conf

#修改/etc/zabbix/zabbix_agentd.conf,这里的IP地址写的是zabbix_server的IP地址,即192.168.3.28
[iyunv@zabbix-server zabbix-2.4.5]# sed -i "s@Server=127.0.0.1@Server=127.0.0.1,192.168.3.28@g" /etc/zabbix/zabbix_agentd.conf
[iyunv@zabbix-server zabbix-2.4.5]# sed -i "s@ServerActive=127.0.0.1@ServerActive=$IP:10051@g" /etc/zabbix/zabbix_agentd.conf
[iyunv@zabbix-server zabbix-2.4.5]# sed -i "s@tmp/zabbix_agentd.log@var/log/zabbix/zabbix_agentd.log@g" /etc/zabbix/zabbix_agentd.conf
[iyunv@zabbix-server zabbix-2.4.5]# sed -i "s@^# UnsafeUserParameters=0@UnsafeUserParameters=1\n@g" /etc/zabbix/zabbix_agentd.conf

#复制zabbix站点的文件到/var/www/html目录下
[iyunv@zabbix-server zabbix-2.4.5]# cp -r /root/zabbix-2.4.5/frontends/php/ /var/www/html/zabbix/
[iyunv@zabbix-server zabbix-2.4.5]# chown -R apache.apache /var/www/html/zabbix/

[iyunv@zabbix-server zabbix-2.4.5]# chkconfig zabbix_server on
[iyunv@zabbix-server zabbix-2.4.5]# chkconfig zabbix_agentd on
[iyunv@zabbix-server zabbix-2.4.5]# service zabbix_server start
Starting zabbix_server:                                    [  OK  ]
[iyunv@zabbix-server zabbix-2.4.5]# service zabbix_agentd start
Starting zabbix_agentd:                                    [  OK  ]




七.通过web站点配置zabbix
    以上步骤配置完后通过http://192.168.3.28/zabbix/setup.php网页端进行后续配置

    1.安装界面


你可能感兴趣的:(zabbix)