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
