前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CentOS 7上yum安装Zabbix 3.0 (应用和数据库分离版)

CentOS 7上yum安装Zabbix 3.0 (应用和数据库分离版)

作者头像
Zabbix
发布2021-02-03 10:46:20
4040
发布2021-02-03 10:46:20
举报
文章被收录于专栏:Zabbix中国官方

写在前面

Zabbix安装虽然简单,但实践过程中却总是问题不断,上次分享过《CentOS 7上yum安装Zabbix 3.0(单机版)》(文末链接畅读),有人在前端和数据库部署在两台机器时遇到了问题

特此,川总又出佳作,可谓社区劳模~

CentOS 7上yum安装Zabbix 3.0

(应用和数据库分离版)

关于作者

关于 thinkc(社区川总)

某大型企业云计算架构师,多年Zabbix,Python,Linux使用经验,社区群活跃核心成员之一 。

原文链接:

https://www.jianshu.com/p/f745b2842772

数据库端

操作

01、最小化安装操作系统,推荐 x86_64 版本

02、升级系统组件到最新版本:

yum -y update

03、关闭 SELinux:

sed -i "s/SELINUX= enforcing/SELINUX= disabled/g" /etc/selinux/config

04、关闭防火墙:

systemctl stop firewalld.service && systemctl disable firewalld.service

05、开启端口(如果已执行了第4步,则第5步可忽略。如果有信息安全合规要求,不能直接关闭防火墙,则跳过第4步,执行第5步)

firewall-cmd --zone=public --list-interfaces firewall-cmd --zone=public --permanent --add-interface=eth0 firewall-cmd --zone=public --add-port=10050/tcp --permanent firewall-cmd --zone=public --add-port=10050/udp --permanent firewall-cmd --set-default-zone=public firewall-cmd --complete-reload

06、增加 nproc 和 nofile 的上限值

vi /etc/security/limits.conf,增加以下内容 * soft nproc 65535 * hard nproc 65535 * soft nofile 65535 * hard nofile 65535

07、修改 vm.swappiness 的值

vi /etc/sysctl.conf,增加以下内容 vm.swappiness = 1

08、安装 MariaDB 源

vi /etc/yum.repos.d/MariaDB.repo,增加以下内容 [mariadb] name = MariaDB baseurl =

http://mirrors.ustc.edu.cn/mariadb/yum/10.3/centos7-amd64/ gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck=1

09、安装 MariaDB

yum -y install ntsysv wget telnet net-tools python-paramiko python-setuptools python-devel MariaDB-server MariaDB-client MariaDB-devel MySQL-python vim epel-release xorg-x11-xauth tree

10、启动 MariaDB

systemctl enable mariadb && systemctl start mariadb

11、进行 MariaDB 安全配置,除了修改为自定义密码(第 13 步设置 MariaDB 参数时会用到),其它选项选择 y 即可

mysql_secure_installation

12、暂停 MariaDB

systemctl stop mariadb

13、设置 MariaDB 参数(以 8GB 内存为例)

vim /etc/my.cnf.d/server.cnf,在 [mysqld] 字段下增加以下内容 port = 3306 socket = /var/lib/mysql/mysql.sock user = mysql character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci character-set-client-handshake = 0 init_connect = 'SET NAMES utf8mb4'

max_connections = 1000 connect_timeout = 60 wait_timeout = 600 interactive_timeout = 600 lock_wait_timeout = 3600 skip_name_resolve = 1 skip_external_locking = 1 open_files_limit = 65535 explicit_defaults_for_timestamp = 1 pid_file = zabbix.pid log_error = zabbix.err slow_query_log = 1 slow_query_log_file = zabbix.slow key_buffer_size = 1M read_buffer_size = 4M read_rnd_buffer_size = 2M table_open_cache = 1024 table_definition_cache = 1024 table_open_cache_instances = 64 thread_cache_size = 512 sort_buffer_size = 4M join_buffer_size = 4M bulk_insert_buffer_size = 64M tmp_table_size = 32M max_heap_table_size = 32M query_cache_limit = 0 query_cache_size = 0 symbolic-links = 0 max_allowed_packet = 32M bind-address = 0.0.0.0 # 如果需要开启复制或搭建高可用,则以下 7 行内容需要启用,否则禁用 #log_bin = mariadb1-bin #binlog_format = ROW # 如果对数据完整性要求高,则

sync_binlog = 1 #sync_binlog = 0 #binlog_cache_size = 4M #max_binlog_cache_size = 1G #max_binlog_size = 1G #expire_logs_days = 7

innodb_buffer_pool_size = 6G innodb_buffer_pool_instances = 8 innodb_buffer_pool_load_at_startup = 1 innodb_buffer_pool_dump_at_shutdown = 1 innodb_log_file_size = 1G innodb_log_buffer_size = 32M innodb_log_files_in_group = 2 # 如果对数据完整性要求高,则 innodb_flush_log_at_trx_commit = 1 innodb_flush_log_at_trx_commit = 0 innodb_lock_wait_timeout = 10 innodb_autoinc_lock_mode = 2 innodb_doublewrite = 1 innodb_thread_concurrency = 8 innodb_flush_method = O_DIRECT innodb_io_capacity = 2000 innodb_io_capacity_max = 4000 innodb_write_io_threads = 8 innodb_read_io_threads = 8 innodb_purge_threads = 4 innodb_page_cleaners = 4 innodb_open_files = 65535 innodb_max_dirty_pages_pct = 50 innodb_lru_scan_depth = 4000 innodb_status_file = 1 innodb_change_buffer_max_size = 50

# 有性能监控要求的,则开启以下参数,否则禁用 performance_schema = 1 performance_schema_instrument = '%=on'

innodb_monitor_enable = "module_srv" innodb_monitor_enable = "module_os" innodb_monitor_enable = "module_lock" innodb_monitor_enable = "module_buffer" innodb_monitor_enable = "module_buf_page" innodb_monitor_enable = "module_trx" innodb_monitor_enable = "module_purge" innodb_monitor_enable = "module_file" innodb_monitor_enable = "module_index" innodb_monitor_enable = "module_adaptive_hash" innodb_monitor_enable = "module_ibuf_system" innodb_monitor_enable = "module_ddl" innodb_monitor_enable = "module_dml" innodb_monitor_enable = "module_log" innodb_monitor_enable = "module_icp" innodb_monitor_enable = "module_metadata"

vim /etc/my.cnf.d/mysql-clients.cnf,

在 [mysql] 字段下增加以下内容 prompt = "\U[\R:\m][\d]> " no-auto-rehash default-character-set = utf8mb4 user=root password=Qingdao,2018 # 此处就是第 12 步设置的 MariaDB root 密码

在 [mysqldump] 字段下增加以下内容 quick

注: 1、原则上 innodb_buffer_pool_size 需要设置为主机内存的 80%,如果主机内存不是 8GB,以上参数可依据相应比例进行调整,例如主机内存为 16GB,则 innodb_buffer_pool_size 建议设置为 12GB。请注意innodb_buffer_pool_size的值必须是整数,例如主机内存是4G,那么innodb_buffer_pool_size可以设置为3G,而不能设置为3.2G 2、本设置以提升数据库性能为目标,降低了数据安全性。如果要保证数据安全,需对部分参数进行调整,具体请参考 MariaDB 官方文档中的相关内容,本文不展开讨论

14、配置 MariaDB 中 zbx 所需要的库和账号权限

systemctl start mariadb mysql mysql>create database zabbix character set utf8; mysql>create user zabbix@'应用端主机IP' identified by 'Qingdao,2018'; mysql>grant all privileges on zabbix.* to zabbix@'应用端主机IP'; mysql>flush privileges; mysql>exit;

15、重启主机

systemctl stop mariadb && reboot

应用端

操作

16、最小化安装操作系统,推荐 x86_64 版本

17、升级系统组件到最新版本

yum -y update

18、关闭 SELinux

sed -i "s/SELINUX= enforcing/SELINUX= disabled/g" /etc/selinux/config

19、关闭防火墙

systemctl stop firewalld.service && systemctl disable firewalld.service

20、开启端口(如果已执行了第4步,则第5步可忽略。如果有信息安全合规要求,不能直接关闭防火墙,则跳过第4步,执行第5步)

firewall-cmd --zone=public --list-interfaces firewall-cmd --zone=public --permanent --add-interface=eth0 firewall-cmd --zone=public --add-port=10050/tcp --permanent firewall-cmd --zone=public --add-port=10050/udp --permanent firewall-cmd --set-default-zone=public firewall-cmd --complete-reload

21、增加 nproc 和 nofile 的上限值

vi /etc/security/limits.conf,增加以下内容 * soft nproc 65535 * hard nproc 65535 * soft nofile 65535 * hard nofile 65535

22、修改 vm.swappiness 的值

vi /etc/sysctl.conf,增加以下内容 vm.swappiness = 1

23、安装 MariaDB 源

vi /etc/yum.repos.d/MariaDB.repo,增加以下内容 [mariadb] name = MariaDB baseurl =

http://mirrors.ustc.edu.cn/mariadb/yum/10.3/centos7-amd64/ gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck=1

24、安装 zbx 所需软件支持包

yum -y install ntsysv wget telnet net-tools python-paramiko php 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 httpd gcc gcc-c++ dejavu-sans-fonts python-setuptools python-devel sendmail mailx pcre-devel net-snmp net-snmp-devel net-snmp-utils freetype-devel libpng-devel perl unbound libtasn1-devel p11-kit-devel OpenIPMI unixODBC unixODBC-devel MariaDB-client MySQL-python vim epel-release xorg-x11-xauth tree

25、停止并卸载 postfix

systemctl disable postfix.service && rpm -e --nodeps postfix

26、安装 zbx 源

rpm -ivh

http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

27、安装 zbx

yum -y install zabbix-server-mysql zabbix-web-mysql

28、将 zbx 创库文件传送到数据库主机上(本文编写时,Zabbix 3.0 最新版本为 3.0.19) scp create.sql.gz root@数据库主机IP地址:/root/

数据库端

操作

29、导入 zbx 所需信息

zcat /root/create.sql.gz | mysql zabbix rm -rf /root/create.sql.gz

应用端

操作

30、配置 zbx 参数

vim /etc/zabbix/zabbix_server.conf,主要是以下几个选项参数需要设置(以 8GB 内存为例)DBHost=数据库主机IP地址 DBPassword 配置为第 14 步中设置的自定义密码 CacheSize=512M HistoryCacheSize=128M HistoryIndexCacheSize=128M TrendCacheSize=128M ValueCacheSize=256M Timeout=30

其它参数保持默认值即可(如果监控主机数量较多,则调大 StartPollers 的值)

如果需要监控VMware虚拟机,则还需要设置以下选项参数:

StartVMwareCollectors=2 VMwareCacheSize=256M VMwareTimeout=300

31、配置 Apache 中的 PHP 参数(以 8GB 内存为例)

vim /etc/httpd/conf.d/zabbix.conf

max_execution_time 600 memory_limit 256M post_max-size 32M upload_max_filesize 32M max_input_time 600 date.timezone 去掉注释符号#,并将值修改为 Asia/Shanghai

32、重启主机

reboot

33、启动 zbx

systemctl start httpd && systemctl start zabbix-server

34、在浏览器中输入 http://zbx监控服务器的IP地址/zabbix,进行 zabbix 的页面初始化配置,根据页面提示信息进行设置即可。

“Check of pre-requisites”页面中,需要全部为绿色 ok

“Zabbix server detail”页面中,“Name”处可填写对此监控系统的描述性文字,支持中文

35、第一次登录zbx监控系统,默认用户名 admin(或Admin),默认密码 zabbix,确认可正常登录系统,且红色箭头处为绿色的 Yes 后,点击右上角图标退出

36、将 Windows 7 系统自带的雅黑字体( 此字体文件的默认位置是 c:\windows\fonts\msyh.ttf)上传到 zbx监控服务器系统的 /usr/share/zabbix/fonts 目录下

注:有人说雅黑字体有版权限制,不能使用在非 Windows 操作系统的环境下,可以更换为宋体等字体文件。

37、修改

/usr/share/zabbix/include/defines.inc.php 文件,将其中的45行ZBX_GRAPH_FONT_NAME和93行 ZBX_FONT_NAME 的值改为

msyhvim /usr/share/zabbix/include/defines.inc.php

38、重启 Apache 和 zbx

systemctl enable httpd && systemctl enable zabbix-server && systemctl restart httpd && systemctl restart zabbix-server

39、在浏览器中输入 http://zbx监控服务器的IP地址/zabbix,用户名 admin(或Admin),默认密码 zabbix,登录进入系统后,选择 Administrator --> Users --> Admin,Language 设置为 Chinese(zh_CN),点击 Update 按钮使之生效

40、回到“监测中” --> “仪表板”,就可以看到监控系统已设置为中文界面了

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2018-08-02,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Zabbix开源社区 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
命令行工具
腾讯云命令行工具 TCCLI 是管理腾讯云资源的统一工具。使用腾讯云命令行工具,您可以快速调用腾讯云 API 来管理您的腾讯云资源。此外,您还可以基于腾讯云的命令行工具来做自动化和脚本处理,以更多样的方式进行组合和重用。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档