一、安装虚拟机
虚拟机配置:
1核2G,20G硬盘
安装时选择的服务包:
在base system中选择base、large systems performance、legacy unix compatibility
database中选择mysql database client、mysql database server
desktops全选
languages中选择Chinese support
servers中选择server platform、system administration tools
system management中选择snmp support
web services中选择php support、web server、web servlet engine
二、配置yum源
安装epel源
[root@localhost ~]# yum -y install epel-release
- 1
安装webtatic源
[root@localhost ~]# rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
Retrieving http://mirror.webtatic.com/yum/el6/latest.rpm
warning: /var/tmp/rpm-tmp.LS63Uk: Header V4 DSA/SHA1 Signature, key ID cf4c4ff9: NOKEY
Preparing... ########################################### [100%]
1:webtatic-release ########################################### [100%]
- 1
- 2
- 3
- 4
- 5
- 6
配置zabbix源
vim /etc/yum.repos.d/zabbix.repo
[zabbix]
name=zabbix
baseurl=http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/
enabled=1
gpgcheck=0
[zabbix-deprecated]
name=zabbix-deprecated
baseurl=http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/deprecated/
enabled=1
gpgcheck=0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
清空yum cache,重建yum缓存
[root@localhost ~]# yum clean all
[root@localhost ~]# yum repolist
[root@localhost ~]# yum makecache
- 1
- 2
- 3
三、升级PHP版本
由于zabbix3.2版本需要PHP5.6以上版本才能支持,默认centos安装的php版本为5.3.3,因此需要升级php版本。
1、查看当前php版本
[root@localhost ~]# php -v
- 1
2、移除当前已经安装的php版本
[root@localhost ~]# yum remove php*
- 1
3、安装php5.6版本
[root@localhost ~]# yum install php56w php56w-devel php56w-common php56w-mysql php56w-pdo php56w-opacache php56w-xml
[root@localhost ~]# php -v
PHP 5.6.30 (cli) (built: Jan 19 2017 22:50:24)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
- 1
- 2
- 3
- 4
- 5
- 6
四、编辑mysql配置文件
1、编辑/etc/my.cnf,添加以下内容,防止中文乱码
[root@localhost ~]# vim /etc/my.cnf
#设置字符集为utf8
character-set-server=utf8
#让innodb的每个表文件单独存储
innodb_file_per_table=1
- 1
- 2
- 3
- 4
- 5
- 6
- 7
2、启动mysql服务,并设置开机自动启动
[root@localhost ~]# service mysqld start
[root@localhost ~]# chkconfig mysqld on
- 1
- 2
3、设置mysql服务root密码
[root@localhost ~]# mysqladmin -uroot password root
- 1
4、创建数据库和用户授权
[root@localhost ~]# mysql -uroot -proot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.71 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
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.00 sec)
mysql> grant all privileges on zabbix.* to zabbix@'192.168.159.%' identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
五、安装zabbix
1、yum安装zabbix
[root@localhost ~]# yum install zabbix-agent zabbix-get zabbix-java-gateway zabbix-proxy zabbix-proxy-mysql zabbix-release zabbix-sender zabbix-server zabbix-server-mysql zabbix-web zabbix-web-mysql
- 1
2、解压sql导入文件
[root@localhost ~]# cd /usr/share/doc/zabbix-server-mysql-3.2.4/
[root@localhost zabbix-server-mysql-3.2.4]# ls
AUTHORS ChangeLog COPYING create.sql.gz NEWS README
[root@localhost zabbix-server-mysql-3.2.4]# gunzip create.sql.gz
[root@localhost zabbix-server-mysql-3.2.4]# ls
AUTHORS ChangeLog COPYING create.sql NEWS README
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
3、将sql文件导入mysql
[root@localhost zabbix-server-mysql-3.2.4]# mysql -uzabbix -pzabbix
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.71 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use zabbix;
Database changed
mysql> source /usr/share/doc/zabbix-server-mysql-3.2.4/create.sql ;
mysql> show tables;
mysql> exit;
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
3、编辑/etc/zabbix/zabbix_server.conf
vim /etc/zabbix/zabbix_server.conf
DBPassword=zabbix
- 1
- 2
4、创建需要的目录
mkdir /etc/zabbix/alertscripts /etc/zabbix/externalscripts
- 1
5、启动zabbix服务
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
Permissive
[root@localhost ~]# service zabbix-server restart
Shutting down Zabbix server: [FAILED]
Starting Zabbix server: [ OK ]
[root@localhost ~]# service zabbix-server status
zabbix_server (pid 8693) is running...
[root@localhost ~]# chkconfig zabbix-server on
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
六、配置apache服务,并启动
1、编辑/etc/httpd/conf/httpd.conf,修改以下内容
vim /etc/httpd/conf/httpd.conf
ServerName localhost:80
- 1
- 2
2、启动httpd服务,并开机自动启动
[root@localhost ~]# service httpd start
Starting httpd: [ OK ]
[root@localhost ~]# chkconfig httpd on
- 1
- 2
- 3
3、其他配置
停止iptables
[root@localhost ~]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
将/usr/share/目录下的zabbix目录复制到/var/www/html/目录下
cp -r /usr/share/zabbix /var/www/html/
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
七、在浏览器中打开并继续配置zabbix
1、在浏览器中打开http://192.168.159.253/zabbix
2、点击下一步,此页为php的参数检测,如果不通过,就修改到通过为止,在php.ini那里修改,记得改完要重启httpd
3、修改php配置文件
[root@localhost ~]# vim /etc/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai
bcmath.scale = 1
always_populate_raw_post_data = -1
#修改以上参数后保存退出
#安装php插件bcmath、mbstring、gd
[root@localhost ~]# yum install -y php56w-gd php56w-bcmath php56w-mbstring
#重启httpd服务
[root@localhost ~]# service httpd restart
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
4、点击back,重新点击下一步检查
5、点击下一步,mysql数据库检测,用户名和密码填写刚才创建的zabbix
6、点击下一步,此页保持默认
7、信息总览
8、安装完毕,点击finish即可完成安装。
9、登录,默认用户名密码为admin/zabbix