01、配置与前提
00.1、Linux最小化系统配置 https://www.cnblogs.com/huanu/p/9235558.html
00.2、安装vim编辑器 yum -y install vim
00.3、zabbix 客户端安装 https://www.cnblogs.com/huanu/p/9253777.html
02、关闭SELinux
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
03、关闭防火墙
systemctl stop firewalld.service && systemctl disable firewalld.service
完成03、04后,用reboot命令重启一下操作系统,并重新登录
04、获取SQL源
rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
05、安装 Zabbix 所需软件支持包
先安装mysql
yum -y install mysql-* --skip-broken #有冲突的软件跳过
安装Apache
yum -y install httpd systemctl start httpd.service #启动 systemctl stop httpd.service #停止 systemctl restart httpd.service #重启 systemctl enable httpd.service #开机启动 systemctl disable httpd.service #开机不启动
安装php
yum -y install php
安装php扩展
yum -y 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 -y 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
06、设置 MySQL 参数(8GB 内存为例)
vim /etc/my.cnf #不然没权限保存
在my.cnf后面添加以下内容
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
07、启动MySQL
systemctl enable mysqld && systemctl start mysqld
08、获取 MySQL 的 root 初始密码
grep 'temporary password' /var/log/mysqld.log
[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log 2018-06-23T00:18:25.380389Z 1 [Note] A temporary password is generated for root@localhost: oj8n=R%9)Q1. [root@localhost ~]#
oj8n=R%9)Q1. #即是默认mysql密码
09、进行 MySQL 安全配置
配置开始时会用到第 09获取的初始密码,建议修改为自定义密码,其它选项选择 y 即可
mysql_secure_installation

[root@localhost ~]# mysql_secure_installation Securing the MySQL server deployment. Enter password for user root: The existing password for the user account root has expired.Please set a new password. New password:
密码改为:Abc2345,.
10、重启 MySQL
systemctl restart mysqld
11、配置 MySQL 中 zabbix要的库和账号权限
[root@localhost ~]# mysql -u root -p(需要输入第 10步中设置的自定义密码) mysql>create database zabbix character set utf8; #创建数据库 mysql>create user zabbix@'%' identified by 'Abc@2018'; #创建用户和密码 mysql>grant all privileges on zabbix.* to zabbix@'%'; #赋权 mysql>flush privileges; mysql>exit;
12、安装 Zabbix源
1 rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm 2 http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/
13、安装zabbix
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-java-gateway zabbix-web
14、导入 zabbix 所需信息
cd /usr/share/doc/zabbix-server-mysql-3.4 #先按Tab键补全文件夹全名 zcat create.sql.gz | mysql -uroot zabbix -p #(需要输入第 10 步中设置的自定义密码)
15、配置 zabbix 参数
vim /etc/zabbix/zabbix_server.conf #这个配置要一遍过
主要是以下几个选项参数需要设置(8GB 内存为例):
vim显示行号命令 :set number

119 ### Option: DBPassword 120 # Database password. Ignored for SQLite. 121 # Comment this line if no password is used. 122 # 123 # Mandatory: no 124 # Default: 125 DBPassword=Abc@2018

378 ### Option: CacheSize 379 # Size of configuration cache, in bytes. 380 # Shared memory size for storing host, item and trigger data. 381 # 382 # Mandatory: no 383 # Range: 128K-8G 384 # Default: 385 CacheSize=512M

403 ### Option: HistoryCacheSize 404 # Size of history cache, in bytes. 405 # Shared memory size for storing history data. 406 # 407 # Mandatory: no 408 # Range: 128K-2G 409 # Default: 410 HistoryCacheSize=128M

412 ### Option: HistoryIndexCacheSize 413 # Size of history index cache, in bytes. 414 # Shared memory size for indexing history cache. 415 # 416 # Mandatory: no 417 # Range: 128K-2G 418 # Default: 419 HistoryIndexCacheSize=128M

421 ### Option: TrendCacheSize 422 # Size of trend cache, in bytes. 423 # Shared memory size for storing trends data. 424 # 425 # Mandatory: no 426 # Range: 128K-2G 427 # Default: 428 TrendCacheSize=128M

430 ### Option: ValueCacheSize 431 # Size of history value cache, in bytes. 432 # Shared memory size for caching item history data requests. 433 # Setting to 0 disables value cache. 434 # 435 # Mandatory: no 436 # Range: 0,128K-64G 437 # Default: 438 ValueCacheSize=256M

440 ### Option: Timeout 441 # Specifies how long we wait for agent, SNMP device or external check (in seconds). 442 # 443 # Mandatory: no 444 # Range: 1-30 445 # Default: 446 Timeout=30
其它参数保持默认值即可
如果需要监控VMware虚拟机,则还需要设置以下选项参数:

280 ### Option: StartVMwareCollectors 281 # Number of pre-forked vmware collector instances. 282 # 283 # Mandatory: no 284 # Range: 0-250 285 # Default: 286 StartVMwareCollectors=2

304 ### Option: VMwareCacheSize 305 # Size of VMware cache, in bytes. 306 # Shared memory size for storing VMware data. 307 # Only used if VMware collectors are started. 308 # 309 # Mandatory: no 310 # Range: 256K-2G 311 # Default: 312 VMwareCacheSize=256M

314 ### Option: VMwareTimeout 315 # Specifies how many seconds vmware collector waits for response from VMware service. 316 # 317 # Mandatory: no 318 # Range: 1-300 319 # Default: 320 VMwareTimeout=300
16、配置 Apache 中的 PHP 参数(8GB 内存为例)
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
php_value date.timezone Asia/shanghai
17、重启系统
systemctl stop mysqld && reboot
18、启动 zabbix
systemctl start httpd && systemctl start zabbix-server
19、在浏览器中输入 http://zbx监控服务器的IP地址/zabbix,进行 zabbix 的页面初始化配置
这个页面PHP设置要求全部OK
如果密码输错,是跳转不到下一步的。密码是前面设置的 Abc@2018
注:第4步的”Zabbix server detail”页面中,”Name”处可填写对此监控系统的描述性文字,支持中文,有点像网站的名称。
20、第一次登录zbx监控系统,默认用户名 admin,默认密码 zabbix,确认可正常登录系统。
21、登录进入系统后,确认 Zabbix server is running 的值是 Yes。
然后选择 Administrator –> Users –> Admin
22、回到”监测中” –> “仪表板”,就可以看到监控系统已设置为中文界面了。
本文参考azurew