> CentOS > CentOS教程 >

centos7安装zabbix2.0

安装环境的准备
1  系统环境
[root@localhost ~]# cat /etc/centos-release
CentOS Linux release 7.0.1406 (Core)

[root@localhost ~]# uname -r
3.10.0-123.el7.x86_64

2  关闭防火墙与selinux
[root@localhost bin]# systemctl  status  iptables
iptables.service - IPv4 firewall with iptables
   Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled)
   Active: inactive (dead) since Fri 2015-07-17 10:58:54 EDT; 16s ago

[root@localhost bin]# systemctl  status  firewalld
firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled)
   Active: inactive (dead)

[root@localhost bin]# getenforce
Permissive
3  程序运行环境
源码包准备:

源码安装mysql:
[root@localhost bin]# ./mysql --version
./mysql  Ver 14.14 Distrib 5.6.16, for Linux (x86_64) using  EditLine wrapper

yum安装http php:
[root@localhost bin]# apachectl  -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Mar 12 2015 15:07:19
[root@localhost bin]# php -v
PHP 5.4.16 (cli) (built: Jun 23 2015 21:17:27)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
http php mysql相关组件安装方法(安装php之前需要安装epel,参考phpMyAdmin安装文档):
[root@localhost bin]# yum install gcc gcc-c++ curl-devel autoconf httpd httpd-manual mod_ssl mod_perl mod_auth_mysql
[root@localhost bin]# yum install php  php-mysqlnd(php-mysql)  php-gd php-xml  php-mbstring php-ldap php-pear php-xmlrpc php-bcmath
[root@localhost bin]# yum install  mysql-connector-odbc mysql-devel libdbi-dbd-mysql net-snmp-devel

4  相关环境的配置
php环境
[root@localhost bin]# vi /etc/php.ini
date.timezone = Asia/Shanghai
max_execution_time = 300
post_max_size = 32M
max_input_time = 300
memory_limit = 128M
mbstring.func_overload = 2

5 http mysql开启
[root@localhost bin]# systemctl start httpd
[root@localhost bin]# systemctl enable httpd
[root@localhost bin]# /etc/init.d/mysql start
[root@localhost bin]# chkconfig  mysql on
Zabbix源码安装与配置
6  安装
[root@localhost zabbix-2.0.3]# tar zxvf /root/7.17/zabbix-2.0.3.tar.gz
[root@localhost zabbix-2.0.3]# cd zabbix-2.0.3/
[root@localhost local]# ./configure  --prefix=/usr/local/zabbix --enable-server --enable-proxy --enable-agent --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl
[root@localhost local]# make
[root@localhost local]# make install
7  添加zabbix到系统服务文件
[root@localhost local]# vi /etc/services
zabbix-agent    10050/tcp               # Zabbix Agent
zabbix-agent    10050/udp               # Zabbix Agent
zabbix-trapper  10051/tcp               # Zabbix Trapper
zabbix-trapper  10051/udp               # Zabbix Trapper

8  导入zabbix数据库
[root@localhost local]# /usr/local/mysql/bin/mysql -uroot -p
Enter password:
mysql> create database zabbix character set utf8;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbix.* to "zabbix"@"localhost" identified by"zabbix";
Query OK, 0 rows affected (0.02 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye

[root@localhost zabbix]# cd /usr/local/zabbix-2.0.3/
[root@localhost zabbix-2.0.3]# /usr/local/mysql/bin/mysql -uzabbix -pzabbix zabbix < ./database/mysql/schema.sql
Warning: Using a password on the command line interface can be insecure.
[root@localhost zabbix-2.0.3]# /usr/local/mysql/bin/mysql -uzabbix -pzabbix zabbix < ./database/mysql/images.sql
Warning: Using a password on the command line interface can be insecure.
[root@localhost zabbix-2.0.3]# /usr/local/mysql/bin/mysql -uzabbix -pzabbix zabbix < ./database/mysql/data.sql
Warning: Using a password on the command line interface can be insecure.

9  创建zabbix配置文件与执行文件软链接
[root@localhost zabbix-2.0.3]# ln -s /usr/local/zabbix/etc   /etc/zabbix
[root@localhost zabbix-2.0.3]# mkdir /var/log/zabbix
[root@localhost zabbix-2.0.3]# chown zabbix.zabbix /var/log/zabbix/
[root@localhost zabbix-2.0.3]# ln -s /usr/local/zabbix/bin/*   /usr/bin/
[root@localhost zabbix-2.0.3]# ln -s /usr/local/zabbix/sbin/*   /usr/sbin/

[root@localhost zabbix-2.0.3]# vi /etc/init.d/zabbix_server  
BASEDIR=/usr/local/zabbix
[root@localhost zabbix-2.0.3]# vi /etc/init.d/zabbix_agentd
BASEDIR=/usr/local/zabbix

10  修改zabbix_server.conf文件
[root@localhost zabbix-2.0.3]# vi /etc/zabbix/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

11  配置被监测主机文件(由于zabbix-server也属于被监控范围,故修改此文件)
[root@localhost zabbix-2.0.3]# vi /etc/zabbix/zabbix_agentd.conf
Server=127.0.0.1   #被动模式连接的zabbix-server
ServerActive=127.0.0.1:20051  #主动模式连接的zabbix-server及端口号
LogFile=/tmp/zabbix_agentd.log
UnsafeUserParameters=1 #启用自定义脚本功能,自定义key时需开启,加上自定义配置文件时,在该变量后追加:
Include=/etc/zabbix/filename.conf

12  复制页面文件
[root@localhost zabbix-2.0.3]# cp -r frontends/php/ /var/www/html/zabbix
[root@localhost zabbix-2.0.3]# chown -R apache.apache  /var/www/html/zabbix

13  开启服务
[root@localhost zabbix-2.0.3]# chkconfig  zabbix_server on
[root@localhost zabbix-2.0.3]# chkconfig  zabbix_agentd  on
[root@localhost zabbix-2.0.3]# /etc/init.d/zabbix_server  start
Starting zabbix_server (via systemctl):                    [  OK  ]
[root@localhost zabbix-2.0.3]# /etc/init.d/zabbix_agentd  start
Starting zabbix_agentd (via systemctl):                    [  OK  ]



web界面下配置zabbix
14  登陆
在浏览器地址栏输入IP/zabbix


15  账号登陆
账号:admin 密码:zabbix

至此zabbix安装完成,详细配置与优化将于近期制作 (责任编辑:IT)