1. 程式人生 > >RedHat6.9中編制安裝zabbix-3.4.7,DB用percona mysql 5.7.20

RedHat6.9中編制安裝zabbix-3.4.7,DB用percona mysql 5.7.20

zabbix percona mysql linux 監控 zabbix配置

軟件版本:
Redhat6.9
zabbix-3.4.7
percona mysql-5.7.20

準備工作:
關閉防火墻,或者添加相應端口。
關閉selinux

———— (安裝如下zabbix依賴包)————
####這裏的包是我網上找的,如有需要請回復。#####
rpm -ivh *.rpm
fping-3.5-3.el6.x86_64.rpm
iksemel-1.4-2_2.el6.x86_64.rpm
iksemel-devel-1.4-2_2.el6.x86_64.rpm
libevent-devel-1.4.13-4.el6.x86_64.rpm
libevent-doc-1.4.13-4.el6.noarch.rpm

libevent-headers-1.4.13-4.el6.noarch.rpm
libiconv-1.14-3.el6.x86_64.rpm
libiconv-devel-1.14-3.el6.x86_64.rpm
libiksemel3-1.4-2_2.el6.x86_64.rpm
libssh2-devel-1.4.2-2.el6_7.1.x86_64.rpm
OpenIPMI-devel-2.0.16-14.el6.x86_64.rpm
php54w-5.4.45-2.w6.x86_64.rpm
php54w-bcmath-5.4.45-2.w6.x86_64.rpm
php54w-cli-5.4.45-2.w6.x86_64.rpm
php54w-common-5.4.45-2.w6.x86_64.rpm
php54w-gd-5.4.45-2.w6.x86_64.rpm
php54w-ldap-5.4.45-2.w6.x86_64.rpm
php54w-mbstring-5.4.45-2.w6.x86_64.rpm
php54w-mysql-5.4.45-2.w6.x86_64.rpm
php54w-pdo-5.4.45-2.w6.x86_64.rpm
php54w-xml-5.4.45-2.w6.x86_64.rpm
unixODBC-devel-2.2.14-14.el6.x86_64.rpm
————————————————

rpm -qa | grep mysql

卸載系統自帶mysql
rpm -e mysql mysql-server mysql-devel

解壓從Percona官網下載的rpm安裝包:
tar zxvf Percona-Server-5.7.20-19-r119-el6-x86_64-bundle.tar

cd Percona-Server-5.7.20-19-r119-el6-x86_64-bundle

安裝以下四個包即可:
rpm -ivh Percona-Server-server-57-5.7.20-19.1.el6.x86_64.rpm Percona-Server-client-57-5.7.20-19.1.el6.x86_64.rpm Percona-Server-devel-57-5.7.20-19.1.el6.x86_64.rpm Percona-Server-shared-57-5.7.20-19.1.el6.x86_64.rpm

創建zabbix用戶:
useradd -u 1000 zabbix

chgrp zabbix /usr/sbin/fping

chmod 4710 /usr/sbin/fping

解壓從官網下載下來的zabbix-3.4.7源碼安裝包:
tar zxvf zabbix-3.4.7.tar.gz

編譯安裝(編譯參數可根據自己需求更改):
./configure --prefix=/usr/local --enable-server --enable-agent --enable-java --with-mysql --with-libxml2 --with-unixodbc --with-net-snmp --with-ssh2 --with-openipmi --with-libevent --with-libpcre --with-ldap --with-openssl --with-libcurl --with-iconv --sysconfdir=/etc/zabbix

make && make install

修改數據庫引擎:
vim /etc/my.cnf
————————————末尾添加————————————
[mysqld]
default-storage-engine=InnoDB
————————————————————————————

chkconfig mysql on

service mysql start

由於mysql5.7版本以後初始密碼機制有所改變,第一次不能用匿名用戶登陸,但是密碼保存在mysql日誌文件/var/log/mysqld.log中。如下字段中kk&q)j88uKwU就是默認的root密碼,可根據如下提供的關鍵字搜索。
vim /var/log/mysqld.log
A temporary password is generated for root@localhost: kk&q)j88uKwU

輸入日誌中的默認密碼,登陸mysql
mysql -u root -p

修改root密碼:(註意,mysql5.7版本以後密碼需要滿足復雜性要求;必須包含數字,大寫字母,小寫字母,特殊字符其中三項才可以)
————以下代碼為sql語句,請登陸mysql後在mysql中執行————
set password for root@localhost=password (‘12345.Com‘);

flush privileges;

創建zabbix數據庫
create database zabbix character set utf8 collate utf8_bin;

給zabbix數據庫授權,密碼為12345.Com:
grant all privileges on zabbix. to zabbix@localhost identified by ‘12345.Com‘;

flush prvileges;
————————————————————

導入zabbix數據至zabbix數據庫:
cd /zabbix-3.4.7/database/mysql/

mysql -uzabbix -p zabbix <schema.sql

mysql -uzabbix -p zabbix <images.sql

mysql -uzabbix -p zabbix <data.sql

修改zabbix_server 配置文件
vim /etc/zabbix/zabbix_server
——————————修改—————————
38行
LogFile=/var/log/zabbix/zabbix_server.log

68行
PidFile=/var/log/zabbix/zabbix_server.pid

85行
DBHost=localhost ##mysql數據庫IP,此環境mysql與zabbix-server在同一機器上

95行
DBName=zabbix ##mysql數據庫

111行
DBUser=zabbix ##mysql用戶

119行
DBPassword=12345.Com ##mysql密碼

126行
DBSocket=/var/lib/mysql/mysql.sock ##這裏需要註意。用 find / -name mysql.sock查看,然後再填入。

322行
SNMPTrapperFile=/var/run/zabbix/zabbix_traps.tmp

588行
Include=/usr/local/etc/zabbix_server.conf.d/*.conf
——————————————————

修改zabbix_agent 配置文件
————————修改——————————
vim /etc/zabbix/zabbix_agentd.conf

11行
PidFile=/var/log/zabbix/zabbix_agentd.pid

30行
LogFile=/var/log/zabbix/zabbix_agentd.log

265行
Include=/usr/local/etc/zabbix_agentd.conf.d/*.conf
——————————————————————

創建zabbix 日誌目錄
mkdir -p /var/run/zabbix

mkdir -p /var/log/zabbix

chown -R zabbix:zabbix /var/run/zabbix/ /var/log/zabbix/

復制zabbix啟動腳本
cp zabbix-3.4.7/misc/init.d/fedora/core5/zabbix_server /etc/init.d/

cp zabbix-3.4.7/misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/

開機啟動
chkconfig zabbix_server on

chkconfig zabbix_agentd on

mkdir -p /usr/local/etc/zabbix_server.conf.d

mkdir -p /usr/local/etc/zabbix_agentd.conf.d

service zabbix_server restart

service zabbix_agentd restart

創建zabbix web頁面
mkdir /var/www/html/zabbix

cd zabbix-3.4.7/frontends/php

cp -a . /var/www/html/zabbix

chown -R zabbix:zabbix /var/www/html/zabbix/

vim /etc/httpd/conf/httpd.conf
————————————末尾追加一下內容—————————————
Alias /zabbix /var/www/html/zabbix
<Directory "/var/www/html/zabbix">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
<IfModule mod_php5.c>
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
</IfModule>
</Directory>
<Directory "/var/www/html/zabbix/conf">
Order deny,allow
Deny from all
<files .php>
Order deny,allow
Deny from all
</files>
</Directory>
<Directory "/var/www/html/zabbix/app">
Order deny,allow
Deny from all
<files
.php>
Order deny,allow
Deny from all
</files>
</Directory>
<Directory "/var/www/html/zabbix/include">
Order deny,allow
Deny from all
<files *.php>
Order deny,allow
Deny from all
</files>
</Directory>
————————————————————————————————

chkconfig httpd on

service httpd restart

此時即可用web訪問http://10.1.1.1/zabbix 進行手動配置zabbix—web
或者也可按照以下方式手動創建:

vim /var/www/html/zabbix/conf/zabbix.conf.php
———————————————————添加以下內容—————————————————————————
<?php
//Zabbix GUI configuration file.
global $DB;

$DB[‘TYPE‘] = ‘MYSQL‘;
$DB[‘SERVER‘] = ‘localhost‘;
$DB[‘PORT‘] = ‘0‘;
$DB[‘DATABASE‘] = ‘zabbix‘;
$DB[‘USER‘] = ‘zabbix‘;
$DB[‘PASSWORD‘] = ‘12345.Com‘;
// Schema name. Used for IBM DB2 and PostgreSQL.
$DB[‘SCHEMA‘] = ‘‘;
$ZBX_SERVER = ‘localhost‘;
$ZBX_SERVER_PORT = ‘10051‘;
$ZBX_SERVER_NAME = ‘‘;

$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
————————————————————————————————————————

chown zabbix.zabbix /var/www/html/zabbix/conf/zabbix.conf.php

此時zabbix_server端即配置完畢。

(此文章僅為個人安裝配置筆記內容,如有不足之處還請各位前輩多多指教!)

RedHat6.9中編制安裝zabbix-3.4.7,DB用percona mysql 5.7.20