Linux下yum安装zabbix

来源:微信公众号 Zabbix社区
ps:步骤为自己的实验过程

//系统(最小化安装)与基础设置
# cat /etc/redhat-release 
CentOS Linux release 7.5.1804 (Core)
# uname -r
3.10.0-862.el7.x86_64
//关闭SELinux
# sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
//防火墙设置
# firewall-cmd --zone=public --list-interfaces
# firewall-cmd --zone=public --permanent --add-interface=ens33
# firewall-cmd --zone=public --permanent --add-port=80/tcp
# firewall-cmd --zone=public --permanent --add-port=3306/tcp
# firewall-cmd --zone=public --permanent --add-port=10050/tcp
# firewall-cmd --zone=public --permanent --add-port=10050/udp
# 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
//安装zabbix需要的依赖包
# 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 net-snmp net-snmp-devel net-snmp-utils freetype-devel libpng-devel perl unbound libtasn1-devel p11-kit-devel OpenIPMI unixODBC unixODBC-devel 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
//注:
//1、原则上 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
# systemctl enable mysqld && systemctl start mysqld
//获取 MySQL 的 root 初始密码:
# grep 'temporary password' /var/log/mysqld.log
//进行 MySQL 安全配置,配置开始时会用到获取的初始密码,建议修改为自定义密码,密码必须足够复杂,其它选项一般选择 y 即可:
# mysql_secure_installation
//完成后的MySQL信息
(root@localhost){11:14}[(none)]> status;
--------------
mysql  Ver 14.14 Distrib 5.7.22, for Linux (x86_64) using  EditLine wrapper

Connection id:      2
Current database:   
Current user:       root@localhost
SSL:            Not in use
Current pager:      stdout
Using outfile:      ''
Using delimiter:    ;
Server version:     5.7.22-log MySQL Community Server (GPL)
Protocol version:   10
Connection:     Localhost via UNIX socket
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8
Conn.  characterset:    utf8
UNIX socket:        /var/lib/mysql/mysql.sock
Uptime:         14 sec

Threads: 1  Questions: 7  Slow queries: 0  Opens: 107  Flush tables: 1  Open tables: 6  Queries per second avg: 0.500
--------------
//重启 MySQL:
# systemctl restart mysqld
//配置 MySQL 中 zbx 所需要的库和账号权限:
# mysql -u root -p(需要输入设置的自定义密码)
mysql>create database zabbix character set utf8;
mysql>create user zabbix@'%' identified by '设置访问zabbix的密码(需要足够复杂)';
mysql>grant all privileges on zabbix.* to zabbix@'%';
mysql>flush privileges;
mysql>exit;
//安装 zbx源:
# rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
//安装 zbx:
# yum -y install zabbix-server-mysql zabbix-web-mysql
//导入 zbx 所需信息(本文编写时,Zabbix 3.0 最新版本为 3.0.15):
# cd /usr/share/doc/zabbix-server-mysql-3.0.15
# zcat create.sql.gz | mysql -uroot zabbix -p(需要输入zbx授权设置的自定义密码)
//配置 zbx 参数:
# vim /etc/zabbix/zabbix_server.conf
//主要是以下几个选项参数需要设置(8GB 内存为例):
DBPassword 配置为zbx授权设置的自定义密码
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 的页面初始化配置,根据页面提示信息进行设置即可。
//注:第4步的“Zabbix server detail”页面中,“Name”处可填写对此监控系统的描述性文字,支持中文
//第一次登录zbx监控系统,默认用户名 admin(或Admin),默认密码 zabbix,确认可正常登录系统后,点击右上角图标退出
//将 Windows系统自带的雅黑字体( 此字体文件的默认位置是 c:\windows\fonts\msyh.ttf)上传到 zbx监控服务器系统的 /usr/share/zabbix/fonts 目录下
//修改 /usr/share/zabbix/include/defines.inc.php 文件,将其中的 45 行 //ZBX_GRAPH_FONT_NAME 和 93 行 ZBX_FONT_NAME 的值改为 msyh
//重启 Apache 和 zbx:
# systemctl enable httpd && systemctl enable zabbix-server && systemctl restart httpd && systemctl restart zabbix-server
//在浏览器中输入 http://zbx监控服务器的IP地址/zabbix,用户名 admin(或Admin),默认密码 zabbix,登录进入系统后,确认 Zabbix server is running 的值是 Yes。然后选择 Administrator --> Users --> Admin
//Language 设置为 Chinese(zh_CN),点击 Update 按钮使之生效
//回到“监测中” --> “仪表板”,就可以看到监控系统已设置为中文界面了

猜你喜欢

转载自blog.csdn.net/qq_35590198/article/details/80841632