一、准备软件环境
安装相关组件:
首先关闭iptables和安装lnmp环境:
配置前先关闭iptables和SELINUX,避免安装过程中报错。 [root@zabbix ~]# service iptables stop [root@zabbix ~]# chkconfig iptables off [root@zabbix ~]# yum -y install gcc gcc-c++ autoconf [root@zabbix ~]# yum -y install mysql-server php-mysql mod_ssl mod-perl mod_auth_mysql php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc php-bcmath [root@zabbix ~]# yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql [root@zabbix ~]# yum -y install net-snmp-devel curl-devel unixODBC-devel OpenIPMI-devel java-devel [root@zabbix ~]# yum -y install libxml2 libxml2-devel openldap* libssh2*
二、创建zabbix用户
[root@zabbix ~]# groupadd zabbix [root@zabbix ~]# useradd zabbix -g zabbix -s /sbin/nologin
三、下载zabbix软件并安装
wget以下内容
http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.8/zabbix-2.2.8.tar.gz
[root@zabbix zabbix-2.2.8]# ./configure --prefix=/usr --sysconfdir=/etc/zabbix --enable-server --enable-proxy --enable-agent --enable-ipv6 --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi --with-unixodbc --with-ldap --with-ssh2 --enable-java
四、报错解决方案
报错1: checking for main in -lmysqlclient... no configure: error: Not found mysqlclient library 解决:[root@zabbix zabbix-2.0.6]# ln -s /usr/lib64/mysql/libmysqlclient.so.16 /usr/lib64/mysql/libmysqlclient.so 报错2: checking libxml2 install dir... no checking for xml2-config path... configure: error: xml2-config not found. Please check your libxml2 installation. 解决:检查是否安装了libxm包 [root@XKWB3403 php-5.3.8]# rpm -qa |grep libxml2 libxml2-2.6.26-2.1.12 libxml2-python-2.6.26-2.1.12 重新安装libxml2和libxml2-devel包 yum install libxml2 yum install libxml2-devel -y 报错3: checking for LDAP support... no configure: error: Invalid LDAP directory - unable to find ldap.h 解决:yum -y install openldap*
五、数据库操作:
mysql> create database zabbix character set utf8; mysql> grant all privileges on zabbix.* to zabbix@'%' identified by 'zabbix'; mysql> flush privileges; mysql> use zabbix; mysql> source /tmp/zabbix-2.4.3/database/mysql/schema.sql mysql> source /tmp/zabbix-2.4.3/database/mysql/data.sql; mysql> source /tmp/zabbix-2.4.3/database/mysql/images.sql;
六、创建日志文件
[root@zabbix zabbix-2.4.3]# mkdir /var/log/zabbix [root@zabbix zabbix-2.4.3]# chown zabbix.zabbix /var/log/zabbix/
七、创建自启动脚本
[root@zabbix zabbix-2.4.3]# cp misc/init.d/fedora/core/zabbix_* /etc/init.d/ [root@zabbix zabbix-2.4.3]# chmod 755 /etc/init.d/zabbix_* [root@zabbix zabbix-2.4.3]# sed -i "s#BASEDIR=/usr/local#BASEDIR=/usr/#g" /etc/init.d/zabbix_server [root@zabbix zabbix-2.4.3]# sed -i "s#BASEDIR=/usr/local#BASEDIR=/usr/#g" /etc/init.d/zabbix_agentd
八、配置zabbix_server.conf服务端的文件
[root@zabbix zabbix-2.4.3]# vi /etc/zabbix/zabbix_server.conf DBName=zabbix //数据库名称 DBUser=zabbix //数据库用户 DBPassword=zabbix //数据库密码 StartPollers=5 CacheSize=256M [root@zabbix zabbix-2.4.3]# mkdir /etc/zabbix/alertscripts /etc/zabbix/externalscripts
九、复制zabbix网页,并开启zabbix服务
root@zabbix zabbix-2.4.3]# cp -r frontends/php/ /usr/share/nginx/html/zabbix [root@zabbix zabbix-2.4.3]# service zabbix_server start Starting zabbix_server: [ OK ] [root@zabbix zabbix-2.4.3]# chkconfig zabbix_server on
十、配置zabbix.conf.php.example
[root@zabbix html]# cd zabbix/conf [root@zabbix conf]# ls maintenance.inc.php zabbix.conf.php.example [root@zabbix conf]# vi zabbix.conf.php.example <?php // Zabbix GUI configuration file. global $DB; $DB["TYPE"] = 'MYSQL'; $DB["SERVER"] = 'localhost'; $DB["PORT"] = '0'; $DB["DATABASE"] = 'zabbix'; $DB["USER"] = 'zabbix'; $DB["PASSWORD"] = 'zabbix'; // Schema name. Used for IBM DB2 and PostgreSQL. $DB["SCHEMA"] = ''; $ZBX_SERVER = 'localhost'; $ZBX_SERVER_PORT = '10051'; $ZBX_SERVER_NAME = ''; $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG; ?> "zabbix.conf.php.example" 19L, 420C written [root@zabbix conf]#
十一、支持中文服务
zabbix默认不支持中文,必须修改配置文件之后才能在语言修改页面显示支持中文 root@zabbix include]# vi locales.inc.php 'zh_CN' => array('name' => _('Chinese (zh_CN)'), 'display' => true), 将false改为true,支持中文
十二、检测安装环境
打开浏览器访问http://server_ip/zabbix/