centos6.8上yum安装zabbix3.2

 

 

centos6.8上yum安装zabbix3.2

 

zabbix3.2安装文档:https://www.zabbix.com/documentation/3.2/manual/installation/install_from_packages/server_installation_with_mysql

 

zabbix-3.2.6-el6.tar下载地址:http://pan.baidu.com/s/1boLsCyj


1、yum安装
做centos6的yum源
1、把所有rpm包放到/tmp/packages/目录下
ll /tmp/packages/
total 17028
drwxr-xr-x 2 root root    4096 May 23 17:14 repodata
-rw-r--r-- 1 root root  345004 May 23 17:13 zabbix-agent-3.2.6-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 4644164 May 23 17:13 zabbix-debuginfo-3.2.6-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  241540 May 23 17:13 zabbix-get-3.2.6-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  737848 May 23 17:13 zabbix-java-gateway-3.2.6-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  647752 May 23 17:13 zabbix-proxy-mysql-3.2.6-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  647780 May 23 17:13 zabbix-proxy-pgsql-3.2.6-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  631564 May 23 17:13 zabbix-proxy-sqlite3-3.2.6-1.el6.x86_64.rpm
-rw-r--r-- 1 root root  252328 May 23 17:13 zabbix-sender-3.2.6-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 1840552 May 23 17:13 zabbix-server-mysql-3.2.6-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 1839560 May 23 17:13 zabbix-server-pgsql-3.2.6-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 5489008 May 23 17:13 zabbix-web-3.2.6-1.el6.noarch.rpm
-rw-r--r-- 1 root root    5648 May 23 17:13 zabbix-web-japanese-3.2.6-1.el6.noarch.rpm
-rw-r--r-- 1 root root    5208 May 23 17:13 zabbix-web-mysql-3.2.6-1.el6.noarch.rpm
-rw-r--r-- 1 root root    5220 May 23 17:13 zabbix-web-pgsql-3.2.6-1.el6.noarch.rpm


2、执行下面--add-repo会添加tmp_packages_.repo源
yum install -y  yum-utils 
yum-config-manager --add-repo=file:///tmp/packages/
ll
total 12
-rw-r--r-- 1 root root 1399 May 24 14:04 CentOS-Base.repo
-rw-r--r-- 1 root root  220 May 24 14:04 CentOS-Epel.repo
-rw-r--r-- 1 root root   97 May 24 14:18 tmp_packages_.repo


3、添加gpgcheck=0
echo 'gpgcheck=0' >> /etc/yum.repos.d/tmp_packages_.repo 

4、cat tmp_packages_.repo 
[tmp_packages_]
name=added from: file:///tmp/packages/
baseurl=file:///tmp/packages/
enabled=1

 

yum install  -y  epel-release
yum install  -y  zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-java-gateway  zabbix-get  zabbix-web  zabbix-server  
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
yum install -y php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64  php56w-xml  php56w-xmlrpc php56w-bcmath


2、改zabbix端口为9672,清空zabbix.conf文件,再复制下面内容

按 Ctrl+C 复制代码
按 Ctrl+C 复制代码

 



3、安装mysql
安装步骤省略
注意:做一个软链接
mkdir -p /var/lib/mysql
ln -s /data/mysql/mysql3306/tmp/mysql.sock /var/lib/mysql/mysql.sock




4、在 MySQL上创建zabbix数据库.
mysql -uroot   -p'123456'  -S /data/mysql/mysql3306/tmp/mysql.sock  -e " create database zabbix character set utf8 collate utf8_bin;"
mysql -uroot   -p'123456'  -S /data/mysql/mysql3306/tmp/mysql.sock -e "grant all privileges on zabbix.* to zabbix@'%' identified by 'zabbix'; "




5、导入表结构和数据.
#查看当前zabbix版本导入相应版本sql脚本
rpm -q zabbix-server-mysql  
gzip -d   /usr/share/doc/zabbix-server-mysql-3.2.6/create.sql.gz
mysql -uzabbix -pzabbix  -S  /data/mysql/mysql3306/tmp/mysql.sock  --default-character-set=utf8 zabbix </usr/share/doc/zabbix-server-mysql-3.2.6/create.sql





6、配置zabbix_server.conf里面的数据库信息
vi /etc/zabbix/zabbix_server.conf
DBHost=localhost   
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/data/mysql/mysql3306/tmp/mysql.sock
DBPort=3306





7、设置php.ini
sed -i 's/^;date.timezone =/date.timezone = Asia\/Shanghai /' /etc/php.ini
sed -i 's/^expose_php = On/expose_php = Off/' /etc/php.ini
sed -i 's/^max_execution_time = 30/max_execution_time = 300/' /etc/php.ini
sed -i 's/^post_max_size = 8M/post_max_size = 32M/' /etc/php.ini
sed -i 's/^max_input_time = 60/max_input_time = 300/' /etc/php.ini
sed -i 's/^display_errors = Off/display_errors =on/' /etc/php.ini
sed -i 's/^;always_populate_raw_post_data = -1/always_populate_raw_post_data = -1/' /etc/php.ini
在/etc/httpd/conf/httpd.conf  加入
grep  9672  /etc/httpd/conf/httpd.conf  || sed -i '/Listen 80/a\Listen 9672'  /etc/httpd/conf/httpd.conf
sed -i '/AddType application\/x-gzip \.gz \.tgz/a\AddType application/x-httpd-php .php'  /etc/httpd/conf/httpd.conf
修改权限
chmod -R 755 /etc/zabbix/web/
chmod -R 755  /usr/share/zabbix/include/
chown -R apache:apache /etc/zabbix/web/



/usr/sbin/apachectl -t
/etc/init.d/httpd restart






8、 安装zabbix
/etc/init.d/zabbix-server restart
/etc/init.d/zabbix-agent restart

地址:http://122.152.212.203:9672/zabbix
默认用户名/密码: Admin/zabbix
数据库用户名/密码:zabbix/zabbix
zabbix名称:ZBXSERVER

配置完毕后会生成/etc/zabbix/web/zabbix.conf.php
Configuration file
"/etc/zabbix/web/zabbix.conf.php"
created: OK




9、设置开启自动启动
chkconfig httpd on
chkconfig mysql on
chkconfig zabbix-server on
chkconfig zabbix-agent on
/etc/init.d/zabbix-server start



10、禁用guest用户,修改Admin的密码
administration-》user groups-》点击guests这个组-》点击disable
administration-》users-》点击Admin-》点击change password-》输入两次密码-》update
用户名/密码: Admin/1qaz2wsx





11、配置zabbix服务器上的zabbix agent
vi /etc/zabbix/zabbix_agentd.conf
Server=127.0.0.1   
ServerActive=127.0.0.1     
Hostname=Zabbix server   
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
# ListenPort=10050
# HostnameItem=system.hostname   
# Include=/etc/zabbix_agentd.userparams.conf
# Include=/etc/zabbix_agentd.conf.d/

其他都删掉,只保留上面几行

service zabbix-agent start






apache+php+mysql+zabbix yum zabbix 后访问报500错误
http://blog.sina.com.cn/s/blog_6311af050102vr6i.html
http://knowledge92.blog.51cto.com/7143076/1702892

apache+php+mysql+zabbix
这个是apache里的错误日志
[Sun May 17 10:09:09 2015] [error] [client 192.168.6.9] PHP Warning:  require_once(/etc/zabbix/web/maintenance.inc.php): failed to open stream: Permission denied in /usr/share/zabbix/include/classes/core/ZBase.php on line 292
[Sun May 17 10:09:09 2015] [error] [client 192.168.6.9] PHP Fatal error:  require_once(): Failed opening required '/etc/zabbix/web/maintenance.inc.php' (include_path='.:/usr/share/pear:/usr/share/php') in /usr/share/zabbix/include/classes/core/ZBase.php on line 292
 
原因是apache的启动用户对该目录  /etc/zabbix/web/maintenance.ini.php和/usr/share/zabbix/include/classes/core/ZBase.php 没有访问权限,把这两个目录的属组改为apache的启动用户即可



Fatal error: require_once(): Failed opening required '/etc/zabbix/web/maintenance.inc.php' (include_path='.:/usr/share/pear:/usr/share/php') in /usr/share/zabbix/include/classes/core/ZBase.php on line 269



修改权限
chmod -R 755 /etc/zabbix/web/
chmod -R 755  /usr/share/zabbix/include/


zabbix日志位置

/var/log/zabbix/zabbix_server.log

ll
total 76
-rw-rw-r-- 1 zabbix zabbix  2021 May 25 14:17 zabbix_agentd.log
-rw-rw-r-- 1 zabbix zabbix   310 Dec  1 03:35 zabbix_agentd.log-20161201.gz
-rw-rw-r-- 1 zabbix zabbix   619 Jan  1 03:40 zabbix_agentd.log-20170101.gz
-rw-rw-r-- 1 zabbix zabbix   370 Feb  1 03:47 zabbix_agentd.log-20170201.gz
-rw-rw-r-- 1 zabbix zabbix   313 Mar  1 03:12 zabbix_agentd.log-20170301.gz
-rw-rw-r-- 1 zabbix zabbix 51728 May 25 14:25 zabbix_server.log

 


连接不上zabbix数据库的解决方法

https://serverfault.com/questions/582526/zabbix-not-connecting-to-mysql-database

 

3805:20170525:145152.001 database is down: reconnecting in 10 seconds
3805:20170525:145202.002 [Z3001] connection to database 'zabbix' failed: [0] server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
could not send startup packet: Broken pipe

 

1、注释掉DBSocket
vi /etc/zabbix/zabbix_server.conf
#DBSocket=/data/mysql/mysql3306/tmp/mysql.sock

 

2、删除zabbix-server-pgsql,pgsql端口是5432,不然会不停连接5432端口连接pgsql

yum remove -y zabbix-server-pgsql

posted @ 2018-05-22 11:11  滴滴滴  阅读(1226)  评论(0编辑  收藏  举报