实验环境
zabbix-server(zabbix的核心) | ip:10.10.251.48 |
zabbix-mysql(存放zabbix-server,zabbix-web产生的数据) | ip:10.10.251.49 |
zabbix-web(PhP+apache,web前端) | ip:10.10.251.47 |
说明:通常情况下这三个角色可以搭建在同一个主机上,在这个实验里是分开部署。
为了实验先全部关闭防火墙和selinux,否则会报很多错误。
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config 永久关闭
setenforce 0 临时关闭
systemctl stop firewalld.service && systemctl disable firewalld.service 关闭防火墙
一.在zabbix-server端上安装源码库配置部署包。这个部署包包含了yum配置文件。
(1)# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm 源码安装包地址
(2)# yum install zabbix-server-mysql zabbix-web-mysql -y
二.在zabbix-mysql端安装mysql数据库
(1)rpm -ivh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
(2)yum install mysql mysql-server -y
编辑 mysql my.cnt
vi /etc/my.cnt 添加以下文件
innodb_file_per_table = 1 innodb_status_file = 1 innodb_buffer_pool_size = 6G innodb_flush_log_at_trx_commit = 2 innodb_log_buffer_size = 16M innodb_log_file_size = 64M innodb_support_xa = 0 default-storage-engine = innodb bulk_insert_buffer_size = 8M join_buffer_size = 16M max_heap_table_size = 32M tmp_table_size = 32M max_tmp_tables = 48 read_buffer_size = 32M read_rnd_buffer_size = 16M key_buffer_size = 32M thread_cache_size = 32 innodb_thread_concurrency = 8 innodb_flush_method = O_DIRECT innodb_rollback_on_timeout = 1 query_cache_size = 16M query_cache_limit = 16M collation_server = utf8_bin character_set_server = utf8
(3)systemctl enable mysqld && systemctl start mysqld 启动mysql
(4)grep 'temporary password' /var/log/mysqld.log 获取初始密码
(5)mysql_secure_installation 需要输入刚才获取的初始密码,建立新的root密码(推荐密码:Aa123456,.)密码不能设置太简单,然后根据提示,自己设置。
(6)然后进入数据库导入
mysql -u root -p
Aa123456,. 进入数据库
create database zabbix character set utf8 collate utf8_bin;
mysql>
mysql>GRANT ALL ON zabbix.* TO 'zabbix'@'10.10.251.%' IDENTIFIED BY 'Aa123456,.
'; 允许用户名为zabbix,密码为
Aa123456,.,ip为10.10.251.网段访问,
mysql>FLUSH PRIVILEGES;
mysql>quit;
(7)systemctl restart mysqld 重启数据库
三 在zabbixweb上布置apache+php
(1)yum -y install httpd 安装apache
vim /etc/httpd/conf.d/zabbix.conf (确认并且修改apache中php参数)
php_value max_execution_time 600
php_value memory_limit 256M
php_value post_max_size 32M
php_value upload_max_filesize 32M
php_value max_input_time 600
php_value always_populate_raw_post_data -1
date.timezone Asia/
Shan
ghai
去掉注释符号#,并将值修改为
Asia/
Shan
ghai
(2)yum install php 安装php和php扩展
yum install php-mysqlnd php-gd libjpeg* php-snmp php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash php-common php-ctype php-xml php-xmlreader php-xmlwriter php-session php-mbstring php-gettext php-ldap php-mysqli --skip-broken
yum install wget telnet net-tools python-paramiko gcc gcc-c++ dejavu-sans-fonts python-setuptools python-devel sendmail mailx net-snmp net-snmp-devel net-snmp-utils freetype-devel libpng-devel perl unbound libtasn1-devel p11-kit-devel OpenIPMI unixODBC
systemctl enable httpd.service && systemctl start httpd.service 重启apache服务
浏览器输入http:10.10.251.47/zabbix 并且根据提示完成设置,默认用户Admin 密码zabbix,
看到上图zabbix基础环境就就已经搭成功了,
本次搭建完才写的文档,很多细节没有写到,仅供参考,李姐万岁。
本次参考https://www.centos.bz/2017/11/centos-7%E5%AE%89%E8%A3%85zabbix-3-4/