CentOS 7.3 Zabbix-server4.0 安装
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS 7.3 Zabbix-server4.0 安装相关的知识,希望对你有一定的参考价值。
CentOS 7.3 Zabbix-server4.0 安装
安装
配置前先关闭 firewall 和SELINUX,避免安装过程中报错
禁用SELINUX
# sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
让SELINUX生效
# setenforce 0
修改主机名
# sed -i "s/localhost.localdomain/hqzabbix/g" /etc/hostname
修改配置文件
# vi /etc/hosts
172.18.1.112 hqzabbix
关闭防火墙:
systemctl stop firewalld.service && systemctl disable firewalld.service
(可选)开启端口:
firewall-cmd --zone=public --list-interfaces
firewall-cmd --zone=public --permanent --add-interface=ens160
firewall-cmd --zone=public --add-port=10050/tcp --permanent
firewall-cmd --zone=public --add-port=10050/udp --permanent
firewall-cmd --zone=public --add-port=80/udp --permanent
firewall-cmd --set-default-zone=public
firewall-cmd --complete-reload
安装 mysql 源:
rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
安装 zbx 所需软件支持包:
yum -y install ntsysv wget telnet net-tools python-paramiko php php-mysqlnd php-gd libjpeg*
yum install -y php-snmp php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath
yum install -y php-mhash php-common httpd gcc gcc-c++ dejavu-sans-fonts python-setuptools
yum install -y python-devel sendmai1 mailx net-snmp net-snmp-devel net-snmp-utils freetype-devel
yum install -y libpng-devel per1 unbound libtasn1-devel p11-kit-devel OpenIPMI unixODBC unixODBC-devel
yum install -y mysql-community-server mysql-community-devel vim
设置 MySQL 参数(8GB 内存为例):
vim /etc/my.cnf
在此文件最后部分新增添加以下内容:
character-set-server = utf8mb4
open_files_limit = 65535
back_log = 2048
max_connections = 5000
max_connect_errors = 100000
table_open_cache = 10000
table_definition_cache = 2048
table_open_cache_instances = 64
ssl = 0
skip-host-cache
core-file
thread_stack = 512k
external-locking = FALSE
max_allowed_packet = 32M
host_cache_size = 0
thread_cache_size = 768
query_cache_limit = 256K
query_cache_min_res_unit = 2k
query_cache_size = 0
query_cache_type = 0
interactive_timeout = 600
wait_timeout = 600
tmp_table_size = 32M
max_heap_table_size = 32M
slow_query_log = 1
long_query_time = 0.1
key_buffer_size = 32M
read_buffer_size = 8M
bulk_insert_buffer_size = 64M
lock_wait_timeout = 3600
explicit_defaults_for_timestamp = 1
innodb_thread_concurrency = 0
innodb_doublewrite = 1
innodb_sync_spin_loops = 100
innodb_spin_wait_delay = 30
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_data_file_path = ibdata1:10M:autoextend
innodb_flush_log_at_trx_commit = 0
innodb_log_buffer_size = 32M
innodb_log_file_size = 128M
innodb_log_files_in_group = 2
innodb_max_undo_log_size = 4G
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_flush_neighbors = 0
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_max_dirty_pages_pct_lwm = 10
innodb_flush_method = O_DIRECT
innodb_adaptive_hash_index = OFF
innodb_change_buffering = NONE
innodb_lru_scan_depth = 4000
innodb_checksum_algorithm = crc32
innodb_lock_wait_timeout = 10
innodb_rollback_on_timeout = 1
innodb_print_all_deadlocks = 1
innodb_online_alter_log_max_size = 4G
innodb_stats_on_metadata = 0
innodb_status_file = 1
innodb_status_output = 0
innodb_status_output_locks = 0
innodb_monitor_enable = ‘%‘
internal_tmp_disk_storage_engine = InnoDB
transaction_isolation = REPEATABLE-READ
performance_schema = OFF
disable_partition_engine_check = 1
[mysql]
prompt = "(U){R:m}[d]> "
no-auto-rehash
[mysqldump]
quick
max_allowed_packet = 32M
启动 MySQL:
systemctl enable mysqld && systemctl start mysqld
修改 MySQL 的 root 初始密码:
grep ‘temporary password‘ /var/log/mysqld.log
进行 MySQL 安全配置,配置开始时会用到第 11 步获取的初始密码,建议修改为自定义密码,其它选项一般选择 y 即可:
mysql_secure_installation
重启 MySQL:
systemctl restart mysqld
配置 MySQL 中 zbx 所需要的库和账号权限:
mysql -u root -p123456(需要输入第 12 步中设置的自定义密码)
mysql>create database hqzabbix character set utf8;
mysql>create user [email protected]‘%‘ identified by ‘123456‘;
mysql>grant all privileges on hqzabbix.* to [email protected]‘%‘;
mysql>flush privileges;
mysql>exit;
安装 zbx源:
cd /usr/local/src
wget http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
安装 zbx:
yum -y install zabbix-server-mysql zabbix-web-mysql
导入 zbx 所需信息(本文编写时,Zabbix 4.0 最新版本为 4.0.15):
cd /usr/share/doc/zabbix-server-mysql-4.0.5/
zcat create.sql.gz | mysql -uroot hqzabbix -p(需要自定义的zabbix 数据库密码)
配置 zbx 参数:
vim /etc/zabbix/zabbix_server.conf
主要是以下几个选项参数需要设置(8GB 内存为例):
DBPassword 配置为第 14 步第 3 行中设置的自定义密码
CacheSize=512M
HistoryCacheSize=128M
HistoryIndexCacheSize=128M
TrendCacheSize=128M
ValueCacheSize=256M
Timeout=30
其它参数保持默认值即可
如果需要监控VMware虚拟机,则还需要设置以下选项参数:
StartVMwareCollectors=2
VMwareCacheSize=256M
VMwareTimeout=300
配置 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
重启系统:
systemctl stop mysqld && reboot
启动 zbx:
systemctl start httpd && systemctl start zabbix-server
在浏览器中输入 http://zbx监控服务器的IP地址/zabbix,进行 zabbix 的页面初始化配置,根据页面提示信息进行设置即可。
第一次登录zbx监控系统,默认用户名 admin(或Admin),默认密码 zabbix,确认可正常登录系统后,点击右上角图标退出
以上是关于CentOS 7.3 Zabbix-server4.0 安装的主要内容,如果未能解决你的问题,请参考以下文章
CentOS 7.3 安装 Nagios 4.3.4 和 Nagios Plugins 2.2.1