centos7搭建zabbix3.4
zabbix安装环境要求:
zabbix安装要求
安装 前置操作 关闭selinux
1 sudo sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
升级yum
切换iptables防火墙 查看防火墙状态
关闭防火墙
1 systemctl stop firewalld.service
禁止开机启动启动防火墙
1 systemctl disable firewalld.service
iptables设置 安装iptables服务
1 yum install iptables-services
开启iptables防火墙
1 systemctl start iptables.service
开启特定端口: 编辑文件:/etc/sysconfig/iptables,加入想要开放的端口即可,例如开放10051端口:
1 -A INPUT -p tcp -m tcp --dport 8090 -j ACCEPT
保存退出,重启防火墙:
1 systemctl restart iptables.service
安装MySQL 下载源包:
1 wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
安装mysql源:
1 yum localinstall mysql57-community-release-el7-8.noarch.rpm
检查是否安装成功:
1 yum repolist enabled | grep "mysql.*-community.*"
1 2 3 mysql-connectors-community/x86_64 MySQL Connectors Community 51 mysql-tools-community/x86_64 MySQL Tools Community 63 mysql57-community/x86_64 MySQL 5.7 Community Server 267
可以修改源配置,安装你喜欢的版本:
1 vim /etc/yum.repos.d/mysql-community.repo
只需要把对应的enable改成1即可。安装
1 yum install mysql-community-server
启动服务
1 2 systemctl start mysqld systemctl status mysqld #查看状态
配置开机启动
1 2 systemctl enable mysqld systemctl daemon-reload
修改root密码 查看默认密码:
1 grep 'temporary password' /var/log/mysqld.log
修改密码很简单,mysql -uroot -p进入控制台,修改:
1 ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourpwd';
修改权限:
1 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'pwd' WITH GRANT OPTION;
配置防火墙,开放3306端口,即可在windows使用工具连接数据库。
安装Apache 1 2 3 sudo yum -y install httpd systemctl start httpd.service #启动 systemctl enable httpd.service #开机启动
安装php
安装php扩展 1 sudo 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
1 sudo 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
修改一些配置 设置MySQL参数
在文件最后添加以下内容(8G内存为例,根据自己配置适当修改)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 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
注:原则上 innodb_buffer_pool_size 需要设置为主机内存的 80%,如果主机内存不是 8GB,以上参数可依据相应比例进行调整,例如主机内存为 16GB,则 innodb_buffer_pool_size 建议设置为 12GB,innodb_log_buffer_size 建议设置为 32M,innodb_log_file_size 建议设置为 128M,以此类推。请注意innodb_buffer_pool_size的值必须是整数,例如主机内存是4G,那么innodb_buffer_pool_size可以设置为3G,而不能设置为3.2G
重启MySQL
1 systemctl restart mysqld
创建zabbix数据库用户 进入mysql控制台
1 2 3 4 5 create database zabbix character set utf8; create user zabbix@'%' identified by 'yourpwd'; GRANT ALL PRIVILEGES ON *.* TO 'zabbix'@'%' IDENTIFIED BY 'yourpwd' WITH GRANT OPTION; flush privileges; exit;
安装zabbix源 1 sudo rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
安装zabbix 1 sudo yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-java-gateway zabbix-web
配置zabbix 导入zabbix所需信息 1 2 cd /usr/share/doc/zabbix-server-mysql-3.4.3 zcat create.sql.gz | mysql -uroot zabbix -p
配置zabbix参数 1 sudo vim /etc/zabbix/zabbix_server.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 DBPassword=yourpwd (125行左右) CacheSize=512M (在385行左右) HistoryCacheSize=128M (在410行左右) HistoryIndexCacheSize=128M (在419行左右) TrendCacheSize=128M (在428行左右) ValueCacheSize=256M (在438行左右) Timeout=30 (在448行左右)
配置Apache中的php参数 1 2 3 4 5 6 7 8 9 sudo vim /etc/httpd/conf.d/zabbix.conf 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/Shanghai
启动zabbix 1 sudo systemctl restart httpd && systemctl restart zabbix-server
在浏览器中输入http://your_IP/zabbix
,进入zabbix页面进行初始化配置,单击两次next step
,填写正确数据库信息,继续next step
,填写zabbix detail(相当于起名字),端口不变!!!然后finish
,完成安装。
设置中文 第一次登录zabbix监控系统,默认用户为admin
,默认密码zabbix
,正确登录系统。 选择Administrator –> Users –> Admin
,在Language
栏选择Chinese(zh_CN)
完成汉化。
OVER!
参考链接
centos7安装zabbix3.4
官网教程