首页 > 代码库 > CentOS-6.5安装zabbix 3.0.4
CentOS-6.5安装zabbix 3.0.4
zabbix需要mysql5.6以上版本,删除旧的版本
[root@localhost /]# yum -y remove mysql* 下载MySQL5.6版本 [root@localhost /]# rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm [root@localhost /]# yum -y install mysql-server [root@localhost /]# yum list installed | grep mysql mysql-community-client.x86_64 5.6.32-2.el6 @mysql56-community mysql-community-common.x86_64 5.6.32-2.el6 @mysql56-community mysql-community-libs.x86_64 5.6.32-2.el6 @mysql56-community mysql-community-release.noarch mysql-community-server.x86_64 5.6.32-2.el6 @mysql56-community 修改mysql配置文件/etc/my.cnf,在[mysqld]中添加innodb_file_per_table=1 [root@localhost /]# vim /etc/my.cnf [root@localhost /]# /etc/init.d/mysqld start 这是强烈建议安全数据库和指定的“根”的帐户密码,删除匿名登录等。它是按照指令后MySQL安全安装完成。 root@localhost /]# mysql_secure_installation 登陆数据库 [root@localhost /]# mysql -u root -p #这里的root密码为123456 mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin; Query OK, 1 row affected (0.06 sec) mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY ‘zabbixpass‘; Query OK, 0 rows affected (0.02 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | zabbix | +--------------------+ 4 rows in set (0.03 sec) mysql> Zabbix 3需要PHP是至少5.4或更高版本。我们的CentOS 6.5库跟php 5.3.3因此我们需要安装一个新的。 [root@localhost /]# rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm 安装所需的包 [root@localhost /]# yum -y install httpd php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldap 修改php配置 [root@localhost /]# vim /etc/php.ini post_max_size = 16M max_execution_time = 300 max_input_time = 300 date.timezone = Asia/Shanghai always_populate_raw_post_data = -1 修改apache配置文件 [root@localhost /]# vim /etc/httpd/conf/httpd.conf ServerName 127.0.0.1 DirectoryIndex index.html index.html.var index.php 启动apache [root@localhost /]# /etc/init.d/httpd start Starting httpd: [ OK ] 在iptables上开放80端口 [root@localhost /]# iptables -I INPUT -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT [root@localhost /]# /etc/init.d/iptables save iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ] [root@localhost /]# cat /etc/sysconfig/iptables # Generated by iptables-save v1.4.7 on Mon Aug 29 21:58:54 2016 *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [67:6921] -A INPUT -p tcp -m tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT # Completed on Mon Aug 29 21:58:54 2016 [root@localhost /]# 创建zabbix用户 [root@localhost /]# groupadd zabbix [root@localhost /]# useradd -g zabbix zabbix 用于上传下载文件(由于直接在虚拟机里下载较慢、在此直接下载到本地主机用lrzsz上传至虚拟机) [root@localhost /]# yum -y install lrzsz zabbix3.0.4下载地址 [root@localhost /]# wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.4/zabbix-3.0.4.tar.gz 解压到当前目录根 [root@localhost /]# tar -zxvf zabbix-3.0.4.tar.gz [root@localhost /]# cd /zabbix-3.0.4/database/mysql/ [root@localhost mysql]# ls data.sql images.sql schema.sql [root@localhost mysql]# mysql -uroot -hlocalhost -p zabbix <schema.sql Enter password: #这里的root密码为123456 [root@localhost mysql]# mysql -uroot -hlocalhost -p zabbix <images.sql Enter password: [root@localhost mysql]# mysql -uroot -hlocalhost -p zabbix <data.sql Enter password: 安装依赖包 [root@localhost mysql]# yum -y install gcc mysql-community-devel libxml2-devel unixODBC-devel net-snmp-devel libcurl-devel libssh2-devel OpenIPMI-devel openssl-devel openldap-devel [root@localhost mysql]# cd /zabbix-3.0.4 编译 [root@localhost zabbix-3.0.4]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --with-ssh2 --with-openipmi --with-openssl --prefix=/usr/local/zabbix 安装 [root@localhost zabbix-3.0.4]# make install [root@localhost zabbix-3.0.4]# echo $? 0 [root@localhost zabbix-3.0.4]# cd conf/ [root@localhost conf]# ls zabbix_agentd zabbix_agentd.win.conf zabbix_server.conf zabbix_agentd.conf zabbix_proxy.conf [root@localhost conf]# pwd /zabbix-3.0.4/conf 修改zabbix_server的配置 [root@localhost etc]# vim /usr/local/zabbix/etc/zabbix_server.conf DBName=zabbix DBUser=zabbix DBPassword=zabbixpass 创建一个新的web前端文件 [root@localhost conf]# mkdir /var/www/html/zabbix 移动源到刚才创建目录下 [root@localhost conf]#cd /zabbix-3.0.4/frontends/php/ [root@localhost php]# cp -a . /var/www/html/zabbix/ 设置Apache作为Web用户接口文件的所有者。 [root@localhost php]# chown -R apache:apache /var/www/html/zabbix 添加权限给Zabbix Web界面执行文件 [root@localhost php]# chmod +x /var/www/html/zabbix/conf/ 添加Zabbix服务器和Zabbix代理启动脚本。 [root@localhost php]# cp /zabbix-3.0.4/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server [root@localhost php]# cp /zabbix-3.0.4/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd 添加Zabbix服务器和Zabbix代理服务 [root@localhost php]# chkconfig --add /etc/init.d/zabbix_server [root@localhost php]# chkconfig --add /etc/init.d/zabbix_agentd [root@localhost php]# chkconfig httpd on [root@localhost php]# chkconfig mysqld on [root@localhost php]# chkconfig zabbix_server on [root@localhost php]# chkconfig zabbix_agentd on 启动zabbix_server [root@localhost php]# /etc/init.d/zabbix_server start #报错 Starting zabbix_server: /etc/init.d/functions: line 546: /usr/local/sbin/zabbix_server: No such file or directory [FAILED] [root@localhost php]# vim /etc/init.d/zabbix_server BASEDIR=/usr/local/zabbix #更改下路径 [root@localhost php]# /etc/init.d/zabbix_server start Starting zabbix_server: [ OK ] [root@localhost php]# vim /etc/init.d/zabbix_agentd BASEDIR=/usr/local/zabbix #更改下路径 [root@localhost php]# /etc/init.d/zabbix_agentd start Starting zabbix_agentd: [ OK ] web界面安装 apache首页 http://192.168.161.133/ |
zabbix web安装界面
http://192.168.161.133/zabbix/setup.php
Username:Admin
Password :zabbix
登陆首页报错
上面提示zabbix_server服务未运行、到服务端检查zabbix_server是否运行
[root@localhost php]# /etc/init.d/zabbix_server status
zabbix_server (pid 2952) is running...
[root@localhost php]# netstat -anpt | grep zabbix #zabbix_server没有运行
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 2275/zabbix_agentd
tcp 0 0 :::10050 :::* LISTEN 2275/zabbix_agentd
查看zabbix的进程
[root@localhost php]#ps aux | grep zabbix
zabbix 2275 0.0 0.1 77020 1396 ? S 23:02 0:00 /usr/local/zabbix/sbin/zabbix_agentd
zabbix 2280 0.0 0.1 77020 1384 ? S 23:02 0:01 /usr/local/zabbix/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix 2281 0.0 0.1 77020 1968 ? S 23:02 0:00 /usr/local/zabbix/sbin/zabbix_agentd: listener #1 [waiting for connection]
zabbix 2282 0.0 0.1 77020 1968 ? S 23:02 0:00 /usr/local/zabbix/sbin/zabbix_agentd: listener #2 [waiting for connection]
zabbix 2283 0.0 0.1 77020 1968 ? S 23:02 0:00 /usr/local/zabbix/sbin/zabbix_agentd: listener #3 [waiting for connection]
zabbix 2284 0.0 0.2 77032 2080 ? S 23:02 0:00 /usr/local/zabbix/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
zabbix 2952 0.0 0.2 154964 2816 ? S 23:26 0:00 /usr/local/zabbix/sbin/zabbix_server
root 2981 0.0 0.0 103216 780 pts/0 S+ 23:28 0:00 grep zabbix
杀死这个进程
[root@localhost php]#kill 2952
[root@localhost php]# kill 2952
[root@localhost php]# kill 2952
-bash: kill: (2952) - 没有那个进程
在此确认zabbix_server这个进程是否存在
[root@localhost php]#ps aux | grep zabbix
zabbix 2275 0.0 0.1 77020 1396 ? S 23:02 0:00 /usr/local/zabbix/sbin/zabbix_agentd
zabbix 2280 0.0 0.1 77020 1384 ? S 23:02 0:01 /usr/local/zabbix/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix 2281 0.0 0.1 77020 1968 ? S 23:02 0:00 /usr/local/zabbix/sbin/zabbix_agentd: listener #1 [waiting for connection]
zabbix 2282 0.0 0.1 77020 1968 ? S 23:02 0:00 /usr/local/zabbix/sbin/zabbix_agentd: listener #2 [waiting for connection]
zabbix 2283 0.0 0.1 77020 1968 ? S 23:02 0:00 /usr/local/zabbix/sbin/zabbix_agentd: listener #3 [waiting for connection]
zabbix 2284 0.0 0.2 77032 2080 ? S 23:02 0:00 /usr/local/zabbix/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
root 2992 0.0 0.0 103216 780 pts/0 S+ 23:30 0:00 grep zabbix
查看zabbix_server日志
[root@localhost php]# find / -name zabbix_server.log #使用find命令找到zabbix_server日志的位置
/tmp/zabbix_server.log
[root@localhost php]# cat /tmp/zabbix_server.log
发现 访问被拒绝 没有密码
我们再去检查下zabbix_server.conf 密码配置那行检查下
[root@localhost php]#cd /usr/local/zabbix/
[root@localhost zabbix]# ls
bin etc lib sbin share
[root@localhost zabbix]# cd etc/
[root@localhost etc]# ls
zabbix_agentd.conf zabbix_server.conf
zabbix_agentd.conf.d zabbix_server.conf.d
[root@localhost etc]# vim zabbix_server.conf
DBPassword=zabbixpass #查找密码是否设置
发现vim zabbix_server.conf 中并没有配置DBPassword=zabbixpass
我们在这里添加上DBPassword=zabbixpass
启动zabbix_server服务
[root@localhost etc]# /etc/init.d/zabbix_server start
Starting zabbix_server: [ OK ]
[root@localhost etc]# netstat -anpt | grep zabbix #确认服务是否启动
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 2275/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 3148/zabbix_server
tcp 0 0 :::10050 :::* LISTEN 2275/zabbix_agentd
tcp 0 0 :::10051 :::* LISTEN 3148/zabbix_server
再去查看下日志
[root@localhost etc]# cat /tmp/zabbix_server.log
已经没有了拒绝访问的报错在最后以行发现本地主机没有被检测
再去zabbix web页面查看下是否正常
web页面也显示正常了
之前报错的原因 查看了下 history 发现原来是在配置zabbix_server.conf的时候修改的是
[root@localhost etc]# history
到上面那个操作错误的目录查看下
[root@localhost etc]# cd /zabbix-3.0.4
[root@localhost zabbix-3.0.4]# cd conf/
[root@localhost conf]# ls
zabbix_agentd zabbix_agentd.conf zabbix_agentd.win.conf zabbix_proxy.conf zabbix_server.con
查看下zabbix_server.conf这个文件确实是否是这里的问题
原来是之前子修改错配置文件所导致的
把web页面改为中文的
到这里已经把本机加入监控了
到日志里查看下
[root@localhost etc]# cat /tmp/zabbix_server.log
CentOS-6.5安装zabbix 3.0.4
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。