[root@RHEL7-3 ~]# yum install wget -y #下载wget
[root@RHEL7-3 ~]# wget https://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
[root@RHEL7-3 ~]# rpm -ivh zabbix-release-3.2-1.el7.noarch.rpm
准备网络源
[root@RHEL7-3 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@RHEL7-3 ~]# sed -i 's/$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo
[root@RHEL7-3 ~]# yum install epel-release -y
[root@RHEL7-3 ~]# yum clean all
[root@RHEL7-3 ~]# yum install zabbix-get zabbix-server zabbix-web-mysql zabbix-web zabbix-agent -y
[root@RHEL7-3 ~]# yum install mariadb-server -y #安装数据库
[root@RHEL7-3 ~]# vim /etc/my.cnf #写入下面内容
[mysqld]
character-set-server=utf8
innodb_file_per_table=1
[root@RHEL7-3 ~]# systemctl start mariadb && systemctl enable mariadb #启动服务,并设置开机启动
[root@RHEL7-3 ~]# systemctl status mariadb |grep Acti #查看服务状态
Active: active (running) since Sun 2017-07-16 12:55:15 CST; 32s ago
[root@RHEL7-3 ~]# netstat -anput |grep 3306 #查看mysql端口监听状态
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2749/mysqld
[root@RHEL7-3 ~]# mysqladmin -uroot password yang #设置mysql数据库root密码为yang
[root@RHEL7-3 ~]# mysql -uroot -pyang #登录数据库
MariaDB [(none)]> create database zabbix character set utf8; #创建zabbix数据库,并设置字符集为utf8
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; #授权
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges; #刷新权限表
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit #退出数据库
Bye
[root@RHEL7-3 zabbix-server-mysql-3.2.6]# pwd
/usr/share/doc/zabbix-server-mysql-3.2.6
[root@RHEL7-3 zabbix-server-mysql-3.2.6]# gzip -d create.sql.gz #解压
[root@RHEL7-3 zabbix-server-mysql-3.2.6]# mysql -uzabbix -pzabbix zabbix < create.sql #导入数据
[root@RHEL7-3 zabbix-server-mysql-3.2.6]# mysql -uzabbix -pzabbix #登录数据库
MariaDB [(none)]> use zabbix #使用数据库
MariaDB [zabbix]> show tables; #查看数据表
MariaDB [zabbix]> show tables;
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
| autoreg_host |
| conditions |
| config |
| corr_condition |
| corr_condition_group |
| corr_condition_tag |
| corr_condition_tagpair |
| corr_condition_tagvalue |
| corr_operation |
| correlation |
| dbversion |
| dchecks |
| dhosts |
| drules |
| dservices |
| escalations |
| event_recovery |
| event_tag |
| events |
| expressions |
| functions |
| globalmacro |
| globalvars |
| graph_discovery |
| graph_theme |
| graphs |
| graphs_items |
| group_discovery |
| group_prototype |
| groups |
| history |
| history_log |
| history_str |
| history_text |
| history_uint |
| host_discovery |
| host_inventory |
| hostmacro |
| hosts |
| hosts_groups |
| hosts_templates |
| housekeeper |
| httpstep |
| httpstepitem |
| httptest |
| httptestitem |
| icon_map |
| icon_mapping |
| ids |
| images |
| interface |
| interface_discovery |
| item_application_prototype |
| item_condition |
| item_discovery |
| items |
| items_applications |
| maintenances |
| maintenances_groups |
| maintenances_hosts |
| maintenances_windows |
| mappings |
| media |
| media_type |
| opcommand |
| opcommand_grp |
| opcommand_hst |
| opconditions |
| operations |
| opgroup |
| opinventory |
| opmessage |
| opmessage_grp |
| opmessage_usr |
| optemplate |
| problem |
| problem_tag |
| profiles |
| proxy_autoreg_host |
| proxy_dhistory |
| proxy_history |
| regexps |
| rights |
| screen_user |
| screen_usrgrp |
| screens |
| screens_items |
| scripts |
| service_alarms |
| services |
| services_links |
| services_times |
| sessions |
| slides |
| slideshow_user |
| slideshow_usrgrp |
| slideshows |
| sysmap_element_url |
| sysmap_url |
| sysmap_user |
| sysmap_usrgrp |
| sysmaps |
| sysmaps_elements |
| sysmaps_link_triggers |
| sysmaps_links |
| task |
| task_close_problem |
| timeperiods |
| trends |
| trends_uint |
| trigger_depends |
| trigger_discovery |
| trigger_tag |
| triggers |
| users |
| users_groups |
| usrgrp |
| valuemaps |
+----------------------------+
127 rows in set (0.01 sec)
配置zabbix_server.conf
[root@RHEL7-3 ~]# vim /etc/zabbix/zabbix_server.conf
DBPassword=zabbix #只修改这一项就可以
[root@RHEL7-3 ~]# mkdir /etc/zabbix/{alertscripts,externalscriptscripts} #创建相关目录,后期可以使用到
[root@RHEL7-3 ~]# systemctl start zabbix-server && systemctl start httpd #启动zabbix-server和httpd服务
[root@RHEL7-3 ~]# systemctl enable zabbix-server && systemctl enable httpd #设置开机启动
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@RHEL7-3 ~]# netstat -anput |egrep "80|10051" #查看端口监听状态
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 2876/zabbix_server
tcp6 0 0 :::80 :::* LISTEN 2883/httpd
tcp6 0 0 :::10051 :::* LISTEN 2876/zabbix_server
[root@RHEL7-3 ~]# setenforce 0 && systemctl stop firewalld #关闭selinux 和防火墙
[root@RHEL7-3 ~]# vim /etc/php.ini
改
878 ;date.timezone =
为
date.timezone = Asia/Shanghai
改:
max_execution_time = 30
为:
max_execution_time = 300
改:
post_max_size = 8M
为:
post_max_size = 16M
memory_limit = 128M
改:
;mbstring.func_overload = 0
为:
mbstring.func_overload = 2
[root@RHEL7-3 ~]# vim /etc/httpd/conf.d/zabbix.conf #注在zabbix官方RPM中,这一步已经设置过了
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Require all granted
<IfModule mod_php5.c>
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
# php_value date.timezone Europe/Riga
</IfModule>
</Directory>
此时可以通过浏览器进行访问:
输入https://IP/zabbix
https://192.168.127.73/zabbix/setup.php