CentOS7x64上yum安裝Zabbix 3.0

CentOS7x64上yum安裝Zabbix 3.0,一次所有搞定,100%成功

 

0一、最小化安裝操做系統php

0二、升級系統組件到最新版本:
yum -y updatepython

0三、關閉 SELinux:
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/configmysql

0四、關閉防火牆:
systemctl stop firewalld.service && systemctl disable firewalld.servicelinux

0五、(可選)開啓端口:
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-reloadc++

注:若是已執行了第4步,則第5步可忽略。若是有信息安全合規要求,不能直接關閉防火牆,則跳過第4步,執行第5步web

0六、安裝 MySQL 源:
rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpmsql

0七、安裝 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 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數據庫

0八、(可選)卸載 postfix:
rpm -e postfixvim

0九、設置 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 = 32Mwindows

注:
一、原則上 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官方文檔中的相關內容,本文不展開討論

十、啓動 MySQL:
systemctl enable mysqld && systemctl start mysqld

十一、獲取 MySQL 的 root 初始密碼:
grep 'temporary password' /var/log/mysqld.log

十二、進行 MySQL 安全配置,配置開始時會用到第 11 步獲取的初始密碼,建議修改成自定義密碼,其它選項通常選擇 y 便可:
mysql_secure_installation

1三、重啓 MySQL:
systemctl restart mysqld

1四、配置 MySQL 中 zbx 所須要的庫和帳號權限:
mysql -u root -p(須要輸入第 12 步中設置的自定義密碼)
mysql>create database zabbix character set utf8;
mysql>create user zabbix@'%' identified by 'Qingdao@2017';
mysql>grant all privileges on zabbix.* to zabbix@'%';
mysql>flush privileges;
mysql>exit;

1五、安裝 zbx源:
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

1六、安裝 zbx:
yum -y install zabbix-server-mysql zabbix-web-mysql

1七、導入 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(須要輸入第 12 步中設置的自定義密碼)

1八、配置 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

1九、配置 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

20、重啓系統:
systemctl stop mysqld && reboot

2一、啓動 zbx:
systemctl start httpd && systemctl start zabbix-server

2二、在瀏覽器中輸入 http://zbx監控服務器的IP地址/zabbix,進行 zabbix 的頁面初始化配置,根據頁面提示信息進行設置便可。

注:第4步的「Zabbix server detail」頁面中,「Name」處可填寫對此監控系統的描述性文字,支持中文

2三、第一次登陸zbx監控系統,默認用戶名 admin(或Admin),默認密碼 zabbix,確承認正常登陸系統後,點擊右上角圖標退出

2四、將 Windows 7系統自帶的雅黑字體( 此字體文件的默認位置是 c:\windows\fonts\msyh.ttf)上傳到 zbx監控服務器系統的 /usr/share/zabbix/fonts 目錄下

2五、修改 /usr/share/zabbix/include/defines.inc.php 文件,將其中的 45 行 ZBX_GRAPH_FONT_NAME 和 93 行 ZBX_FONT_NAME 的值改成 msyh

2六、重啓 Apache 和 zbx:
systemctl enable httpd && systemctl enable zabbix-server && systemctl restart httpd && systemctl restart zabbix-server

2七、在瀏覽器中輸入 http://zbx監控服務器的IP地址/zabbix,用戶名 admin(或Admin),默認密碼 zabbix,登陸進入系統後,確認 Zabbix server is running 的值是 Yes。而後選擇 Administrator --> Users --> Admin

2八、Language 設置爲 Chinese(zh_CN),點擊 Update 按鈕使之生效

2九、回到「監測中」 --> 「儀表板」,就能夠看到監控系統已設置爲中文界面了

相關文章
相關標籤/搜索