Centos6.5 安装Zabbix3
Posted 梦徒
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos6.5 安装Zabbix3相关的知识,希望对你有一定的参考价值。
一.准备阶段:
1.>关闭防火墙
/etc/init.d/iptables stop
2.>关闭selinux
vim /etc/selinux/config SELINUX=disabled 或者 setenforce 0
二.安装zabbix所需软件并配置.
1.安装php
Zabbix 3.0对PHP的要求最低为5.4,而CentOS6默认为5.3.3,完全不满足要求,故需要利用第三方源,将PHP升级到5.4以上,注意,不支持PHP7
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 post_max_size = 32M max_execution_time = 300 max_input_time = 300 always_populate_raw_post_data = -1
2.安装MySQL
MySQL建议使用5.6版本,CentOS6默认为5.1,不建议使用,性能偏低
rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm yum install -y mysql-server mysql-devel vim /etc/my.cnf [mysqld] innodb_file_per_table #独立表空间模式 service mysqld start 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; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | zabbix | +--------------------+
3.安装Zabbix
yum install httpd libxml2-devel net-snmp-devel libcurl-devel groupadd -g 201 zabbix useradd -g zabbix -u 201 -m zabbix wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.0.3/zabbix-3.0.3.tar.gz tar zxvf zabbix-3.0.3.tar.gz cd zabbix-3.0.3 /usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql /usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql /usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql ./configure --prefix=/usr/local/zabbix --sysconfdir=/etc/zabbix/ --enable-server --enable-agent --with-net-snmp --with-libcurl --with-mysql --with-libxml2 make &&make install
编译 zabbix 如果报下面错误,就做以下操作
报错信息:configure: error: Not found mysqlclient library #find / -name libmysqlclient* ln -s /usr/lib64/mysql/libmysqlclient.so.18.1.0 /usr/lib64/mysql/libmysqlclient.so ln -s /usr/lib64/mysql/libmysqlclient_r.so.18.1.0 /usr/lib64/mysql/libmysqlclient_r.so
4.配置Zabbix
vim /etc/zabbix/zabbix_server.conf DBHost=localhost 数据库ip地址 DBName=zabbix DBUser=zabbix DBPassword=zabbix ListenIP=10.10.100.147 #zabbix server ip地址 ln -s /usr/local/zabbix/sbin/* /usr/sbin/ cp /soft/zabbix-3.0.3/misc/init.d/fedora/core/zabbix_* /etc/init.d/ chmod +x /etc/init.d/zabbix_* sed -i "s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix@g" /etc/init.d/zabbix_server
5.配置http WEB
vim /etc/httpd/conf/httpd.conf ServerName 127.0.0.1 DocumentRoot "/var/www/html" ServerName 10.10.100.147 mkdir -p /var/www/html/zabbix cp -r /soft/zabbix-3.0.3/frontends/php/* /var/www/html/zabbix/ chown -R apache.apache /var/www/html/zabbix/
6.启动服务
chkconfig zabbix_server on /etc/init.d/zabbix_server start service httpd restart
7.用浏览器访问http://10.10.100.147/zabbix/,并按照提示安装:
输入mysql密码,其他默认,继续
输入zabbix server信息,默认即可,继续
安装信息汇总,没问题就继续
提示安装成功了,点击完成进入登陆界面
终于看到Zabbix 3.0的新版登陆界面了,默认用户名/密码:Admin/zabbix,注意用户名也区分大小写
至此zabbix的安装完成!可以查看zabbix服务端日志:tail -100f /tmp/zabbix_server.log
号外:
zabbix server is running value no 解决方法:
1.关闭selinux 2.关闭防火墙 3.登录mysql数据库,查看是否可以登录. 4.打开 vim /var/www/html/zabbix/conf/zabbix.conf.php 将server改成ip地址 $DB[\'SERVER\'] = \'10.10.100.147\'; #ip为zabbix server端地址. $ZBX_SERVER = \'10.10.100.147\'; $ZBX_SERVER_NAME = \'本机的主机名\';
号外(如果界面还是出现如下错误):
可能是数据库的问题,对数据库进行授权.
mysql -uroot –p****** mysql> GRANT ALL PRIVILEGES ON *.* TO \'zabbix\'@\'192.168.153.128\' IDENTIFIED BY \'zabbix\' WITH GRANT OPTION; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
zabbix自动化安装脚本:
#!/bin/bash echo -n "stop SELinux..." setenforce 0 > /dev/null 2>&1 sed -i \'/^SELINUX=/s/=.*/=disabled/\' /etc/selinux/config && echo "OK" echo -n "stop iptables fire ……" /etc/init.d/iptables stop echo -n "upgrate php version,默认为5.3.3的版本..." 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 -y sed -i "s@;date.timezone =@date.timezone = Asia/Shanghai@g" /etc/php.ini sed -i "s@post_max_size = 8M@post_max_size = 32M@" /etc/php.ini sed -i "s@max_execution_time = 30@max_execution_time = 300@" /etc/php.ini sed -i "s@max_input_time = 60@max_input_time = 300@" /etc/php.ini sed -i "s@;always_populate_raw_post_data = -1@always_populate_raw_post_data = -1@" /etc/php.ini echo -n "升级MYSQL的版本,默认为5.1的版本" rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm yum install -y mysql-server mysql-devel -y echo -n "正在启动mysqld服务……" service mysqld start > /dev/null 2>&1 && echo "OK" echo -n "正在为mysql的root用户设置密码……" mysqladmin -uroot password "123456" && echo "OK" echo "正在执行mysql语句……" mysql -uroot -p123456 -e "CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;" && echo "sucess." mysql -uroot -p123456 -e "GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY \'zabbix\';" && echo "sucess." mysql -uroot -p123456 -e "flush privileges;" echo "安装Zabbix" groupadd -g 201 zabbix useradd -g zabbix -u 201 -m zabbix yum install httpd libxml2-devel net-snmp-devel libcurl-devel -y echo -n "正在下载zabbix源码包……" wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.0.3/zabbix-3.0.3.tar.gz echo -n "正在解压……" tar zxvf zabbix-3.0.3.tar.gz cd zabbix-3.0.3 /usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql /usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql /usr/bin/mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql ./configure --prefix=/usr/local/zabbix --sysconfdir=/etc/zabbix/ --enable-server --enable-agent --with-net-snmp --with-libcurl --with-mysql --with-libxml2 make &&make install
参考文档:
http://www.itnpc.com/news/web/146415869871556.html
http://www.cnblogs.com/enjoycode/p/zabbix_3_installation_on_centos_7.html
http://blog.csdn.net/zhaozuosui/article/details/48394409
http://yestreenstars.blog.51cto.com/1836303/1532665
以上是关于Centos6.5 安装Zabbix3的主要内容,如果未能解决你的问题,请参考以下文章