01安裝centos系統(tǒng)(注:推薦內(nèi)存8G)
02、升級系統(tǒng)組件到最新版本:
yum -y update
03氧映、關(guān)閉 SELinux:
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
04钧萍、關(guān)閉防火墻:
systemctl stop firewalld.service && systemctl disable firewalld.service
05褐缠、(可選)開啟端口:
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-reload
關(guān)閉SELinux的方法:
修改/etc/selinux/config文件中的SELINUX="" 為 disabled ,然后重啟
vim /etc/selinux/config
注:如果已執(zhí)行了第4步划煮,則第5步可忽略送丰。如果有信息安全合規(guī)要求,不能直接關(guān)閉防火墻弛秋,則跳過第4步器躏,執(zhí)行第5步
補(bǔ)充:
缺少Error: Package: akonadi-mysql-1.9.2-4.el7.x86_64 (@anaconda)
? ? ? ? ? Requires: mariadb-server
依賴包
報(bào)錯(cuò)原因 :軟件包依賴 mariadb組件
解決方案:
yum -y remove mariadb-libs
運(yùn)行
yum install mysql-community-server
06、安裝 MySQL 源:
rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
07蟹略、安裝 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
08登失、(可選)卸載 postfix:
rpm -e postfix
09、設(shè)置 MySQL 參數(shù)(8GB 內(nèi)存為例):
vim /etc/my.cnf
在此文件最后部分新增添加以下內(nèi)容:
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 需要設(shè)置為主機(jī)內(nèi)存的 80%揽浙,如果主機(jī)內(nèi)存不是 8GB,以上參數(shù)可依據(jù)相應(yīng)比例進(jìn)行調(diào)整,例如主機(jī)內(nèi)存為 16GB馅巷,則 innodb_buffer_pool_size 建議設(shè)置為 12GB膛虫,innodb_log_buffer_size 建議設(shè)置為 32M,innodb_log_file_size 建議設(shè)置為 128M钓猬,以此類推稍刀。請注意innodb_buffer_pool_size的值必須是整數(shù),例如主機(jī)內(nèi)存是4G敞曹,那么innodb_buffer_pool_size可以設(shè)置為3G账月,而不能設(shè)置為3.2G
2、本設(shè)置以提升數(shù)據(jù)庫性能為目標(biāo)澳迫,降低了數(shù)據(jù)安全性局齿。如果要保證數(shù)據(jù)安全,需對部分參數(shù)進(jìn)行調(diào)整橄登,具體請參考MySQL官方文檔中的相關(guān)內(nèi)容抓歼,本文不展開討論
10、啟動(dòng) MySQL:
systemctl enable mysqld && systemctl start mysqld
11示绊、獲取 MySQL 的 root 初始密碼:
grep 'temporary password' /var/log/mysqld.log
12锭部、進(jìn)行 MySQL 安全配置暂论,配置開始時(shí)會(huì)用到第 11 步獲取的初始密碼面褐,建議修改為自定義密碼,其它選項(xiàng)一般選擇 y 即可:(密碼強(qiáng)度:包含大小寫和特殊字符大于八位)
mysql_secure_installation
13取胎、重啟 MySQL:
systemctl restart mysqld
14展哭、配置 MySQL 中 zbx 所需要的庫和賬號權(quán)限:
mysql -u root -p(需要輸入第 12 步中設(shè)置的自定義密碼)
mysql>create database zabbix character set utf8;
mysql>create user zabbix@'%' identified by 'Yiyangboco@123';
mysql>grant all privileges on zabbix.* to zabbix@'%';
mysql>flush privileges;
mysql>exit;
15、安裝 zbx源:
rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm
16闻蛀、安裝 zbx:
yum -y install zabbix-server-mysql zabbix-web-mysql
17匪傍、導(dǎo)入 zbx 所需信息(本文編寫時(shí),Zabbix 3.4 最新版本為 3.4.11):
cd /usr/share/doc/zabbix-server-mysql-3.4.11
zcat create.sql.gz | mysql -uroot zabbix -p(需要輸入第 12 步中設(shè)置的自定義密碼)
18觉痛、配置 zbx 參數(shù):
vim /etc/zabbix/zabbix_server.conf
主要是以下幾個(gè)選項(xiàng)參數(shù)需要設(shè)置(8GB 內(nèi)存為例):
DBPassword 配置為第 14 步第 3 行中設(shè)置的自定義密碼
CacheSize=512M
HistoryCacheSize=128M
HistoryIndexCacheSize=128M
TrendCacheSize=128M
ValueCacheSize=256M
Timeout=30
其它參數(shù)保持默認(rèn)值即可
如果需要監(jiān)控VMware虛擬機(jī)役衡,則還需要設(shè)置以下選項(xiàng)參數(shù):
StartVMwareCollectors=2
VMwareCacheSize=256M
VMwareTimeout=300
19、配置 Apache 中的 PHP 參數(shù)(8GB 內(nèi)存為例):
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手蝎、重啟系統(tǒng):
systemctl stop mysqld && reboot
21、啟動(dòng) zbx:
systemctl start httpd && systemctl start zabbix-server
22俐芯、在瀏覽器中輸入 http://zbx監(jiān)控服務(wù)器的IP地址/zabbix棵介,進(jìn)行 zabbix 的頁面初始化配置,根據(jù)頁面提示信息進(jìn)行設(shè)置即可吧史。
注:第4步的“Zabbix server detail”頁面中邮辽,“Name”處可填寫對此監(jiān)控系統(tǒng)的描述性文字,支持中文
23、第一次登錄zbx監(jiān)控系統(tǒng)吨述,默認(rèn)用戶名 admin(或Admin)岩睁,默認(rèn)密碼 zabbix,確認(rèn)可正常登錄系統(tǒng)后揣云,點(diǎn)擊右上角圖標(biāo)退出
24笙僚、將 Windows 7系統(tǒng)自帶的雅黑字體( 此字體文件的默認(rèn)位置是 c:\windows\fonts\msyh.ttf)上傳到 zbx監(jiān)控服務(wù)器系統(tǒng)的 /usr/share/zabbix/fonts 目錄下
25、修改 /usr/share/zabbix/include/defines.inc.php 文件灵再,將其中的 45 行 ZBX_GRAPH_FONT_NAME 和 93 行 ZBX_FONT_NAME 的值改為 msyh
26肋层、重啟 Apache 和 zbx:
systemctl enable httpd && systemctl enable zabbix-server && systemctl restart httpd && systemctl restart zabbix-server
27、在瀏覽器中輸入 http://zbx監(jiān)控服務(wù)器的IP地址/zabbix翎迁,用戶名 admin(或Admin)栋猖,默認(rèn)密碼 zabbix,登錄進(jìn)入系統(tǒng)后汪榔,確認(rèn) Zabbix server is running 的值是 Yes蒲拉。然后選擇 Administrator --> Users --> Admin
28、Language 設(shè)置為 Chinese(zh_CN)痴腌,點(diǎn)擊 Update 按鈕使之生效
29雌团、回到“監(jiān)測中” --> “儀表板”,就可以看到監(jiān)控系統(tǒng)已設(shè)置為中文界面了
Zabbix包下載地址:http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/
zabbxi-agent安裝及配置
1士聪、安裝zabbxi-agent
yum install zabbix-agent -y
2锦援、配置zabbxi-agent
grep -n '^'[a-Z] /etc/zabbix/zabbix_agentd.conf
vim /etc/zabbix/zabbix_agentd.conf
13:PidFile=/var/run/zabbix/zabbix_agentd.pid
32:LogFile=/var/log/zabbix/zabbix_agentd.log
43:LogFileSize=0
97:Server=172.16.8.254
138:ServerActive=172.16.8.254
149:Hostname=Zabbix server
267:Include=/etc/zabbix/zabbix_agentd.d/*.conf
3、啟動(dòng)zabbxi-agent并設(shè)置開機(jī)啟動(dòng)
systemctl enable zabbix-agent.service
systemctl restart zabbix-agent.service
老版本
開啟zabbix要用的端口, 也可以關(guān)閉服務(wù)器的防火墻
#vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m udp -p udp --dport 10050 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10050 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 10051 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10051 -j ACCEPT
#service iptables restart
或關(guān)閉服務(wù)器防火墻
#service iptables stop
下載zabbix rpm安裝包
#rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
安裝zabbix-agent
#yum -y install zabbix-agent
配置zabbix-agent
#vim /etc/zabbix/zabbix_agentd.conf
###修改配置文件中的Server, ServerActive的IP, 該IP是zabbix服務(wù)端IP地址
Server=zabbix server ip
ServerActive=zabbix server ip
Hostname=本機(jī)Ip #不要用127.0.0.1
啟動(dòng)zabbix-agent
#service zabbix-agent start
zabbix3.4安裝graphtrees補(bǔ)丁
1剥悟、插件安裝
Zabbix-web目錄
提示:如果是yum安裝并且是centos7目錄會(huì)在/usr/share/zabbix灵寺,也可以使用find進(jìn)行查找,目錄不對的話patch安裝不上区岗,會(huì)提示指定目錄
/usr/share/zabbix?
wget https://raw.githubusercontent.com/OneOaaS/graphtrees/master/graphtree3.2.x.patch
yum install -y patch
patch -Np0 < graphtree3.2.x.patch
注意此處的權(quán)限略板,權(quán)限不對打開網(wǎng)頁是空白的,必須和nginx或者apache的用戶一致慈缔,我用的是apache
chown -R apache:apache oneoaas
#vim /etc/httpd/conf.d/zabbix.conf? ?
Alias /oneoaas /usr/share/zabbix/oneoaas? ?
Alias /zabbix /user/share/zabbix