zabbix server端安装

2/13/2017来源:经验技巧人气:2017

1.准备工作 安装好CentOS 6.5操作系统 关闭iptables和selinux 设置好IP地址

2.安装LAMP环境

安装软件包

yum -y groupinstall "Development Tools" yum -y install httpd MySQL mysql-server mysql-devel php php-mysql php-common php-mbstring php-gd php-odbc php-pear curl curl-devel net-snmp net-snmp-devel perl-DBI php-xml ntpdate php-bcmath

启动httpd及mysql服务

/etc/init.d/httpd start /etc/init.d/mysqld start chkconfig httpd on chkconfig mysqld on

配置PHP参数 注意‘=’号之前有一个空格,否则会修改失败,后面的php配置检查页面有的项目会显示failed

cp /etc/php.ini/etc/php.ini.bak_20160226 sed -i "[email protected];date.timezone = @date.timezone = Asia/[email protected]" /etc/php.ini sed -i "[email protected]_execution_time = [email protected]_execution_time = [email protected]" /etc/php.ini sed -i "[email protected]_max_size = [email protected]_max_size = [email protected]" /etc/php.ini sed -i "[email protected]_input_time = [email protected]_input_time = [email protected]" /etc/php.ini sed -i "[email protected]_limit = [email protected]_limit = [email protected]" /etc/php.ini sed -i "[email protected];mbstring.func_overload = [email protected]_overload = [email protected]" /etc/php.ini

修改httpd服务FQDN错误

echo "ServerName localhost:80" >> /etc/httpd/conf/httpd.conf /etc/init.d/httpd restart

3.安装zabbix server端

添加zabbix系统用户

groupadd zabbix useradd -r -g zabbix -s /sbin/nologin zabbix

下载并编译zabbix

wget https://jaist.dl.sourceforge.net/PRoject/zabbix/ZABBIX%20Latest%20Stable/2.4.5/zabbix-2.4.5.tar.gz cd /usr/src tar zxvf /root/zabbix-2.4.5.tar.gz ./configure --prefix=/usr/local/zabbix --enable-server --enable-proxy --enable-agent --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl make && make install

4.创建zabbix数据库及相关表

创建mysql数据库,mysql用户,并赋权。

mysql -e"create database zabbix default charset utf8;" mysql -e"grant all privileges on zabbix.* to [email protected]'%' identified by 'zabbixpass';” mysql -e"flush privileges;"

执行zabbix数据库初始化脚本

mysql -uzabbixuser -pzabbixpass zabbix < ./database/mysql/schema.sql mysql -uzabbixuser -pzabbixpass zabbix < ./database/mysql/images.sql mysql -uzabbixuser -pzabbixpass zabbix < ./database/mysql/data.sql

5.配置软链接及启动文件信息

mkdir /var/log/zabbix chown zabbix.zabbix /var/log/zabbix ln -s /usr/local/zabbix/etc/ /etc/zabbix ln -s /usr/local/zabbix/bin/* /usr/bin/ ln -s /usr/local/zabbix/sbin/* /usr/sbin/ cp /usr/src/zabbix-2.4.5/misc/init.d/fedora/core/zabbix_* /etc/init.d/ chmod 755 /etc/init.d/zabbix_*

修改/etc/init.d下zabbix_seraver及zabbix_agentd启动文件

sed -i "[email protected]=/usr/[email protected]=/usr/local/[email protected]" /etc/init.d/zabbix_server sed -i "[email protected]=/usr/[email protected]=/usr/local/[email protected]" /etc/init.d/zabbix_agentd

修改/etc/zabbix/zabbix_server.conf

修改mysql数据库中zabbix库的账号及密码信息 注意:# DBPassWord中间有个空格,否则修改的时候,无法把zabbix数据库用户的密码写入配置文件,zabbix server中会报错如下:

14878:20170211:163603.280 [Z3001] connection to database 'zabbix' failed: [1045] access denied for user 'zabbixuser'@'localhost' (using password: NO) 14878:20170211:163603.280 database is down: reconnecting in 10 seconds

后续通过网页登陆zabbix控制台后,会有如下提示: 这里写图片描述

sed -i "[email protected][email protected][email protected]" /etc/zabbix/zabbix_server.conf sed -i "[email protected]# [email protected][email protected]" /etc/zabbix/zabbix_server.conf sed -i "[email protected]# [email protected][email protected]" /etc/zabbix/zabbix_server.conf

修改/etc/zabbix/zabbix_agentd.conf

这里的IP地址写的是zabbix_server的IP地址,即10.10.10.220

sed -i "[email protected][email protected]=127.0.0.1,[email protected]" /etc/zabbix/zabbix_agentd.conf sed -i "[email protected][email protected]=10.10.10.220:[email protected]" /etc/zabbix/zabbix_agentd.conf sed -i "[email protected]/[email protected]/log/zabbix/[email protected]" /etc/zabbix/zabbix_agentd.conf sed -i "[email protected]^#[email protected]=1\[email protected]" /etc/zabbix/zabbix_agentd.conf

复制zabbix站点文件到/var/www/html/

cp -r /usr/src/zabbix-2.4.5/frontends/php/ /var/www/html/zabbix/ chown -R apache.apache /var/www/html/zabbix/ chkconfig zabbix_server on chkconfig zabbix_agentd on /etc/init.d/zabbix_server start /etc/init.d/zabbix_agentd start

通过web界面配置zabbix

安装界面:在浏览器输入:10.10.10.220/zabbix/setup.php 这里写图片描述

PHP配置检查界面,结果是OK表示正常,如果是fail状态,请修改相关的php配置参数,并重启httpd服务 这里写图片描述

填写数据库相关信息端口及zabbix授权用户及密码 这里写图片描述

填写zabbix的server地址,我这里填写的是本机的IP地址10.10.10.220 这里写图片描述 最后配置结果预览 这里写图片描述 安装完成 这里写图片描述

访问zabbix web管理界面

安装完成后通过http://10.10.10.220/zabbix/index.php就能直接访问zabbix管理界面

默认用户名:admin密码:zabbix