您好,登錄后才能下訂單哦!
環(huán)境準(zhǔn)備:
操作系統(tǒng):CentOS 7或以上
一.安裝mysql
1.建立Mysql賬號
groupadd mysql
useradd -s /sbin/nologin -g mysql -M mysql
2.創(chuàng)建mysql軟件目錄并修改權(quán)限
mkdir -p /usr/local/mysql
mkdir -p /data/mysql
mkdir -p /usr/local/mysql/run/
chown -R root:mysql /usr/local/mysql
chown -R mysql:mysql /data/mysql
chmod 775 /usr/local/mysql/run/
3.安裝依賴包
yum -y install make gcc-c++ cmake bison-devel ncurses-devel
4.下載源碼包并解壓
http://mirrors.sohu.com/mysql/
cd /usr/local/src
tar -zxf mysql-5.7.11.tar.gz
cd mysql-5.7.11
5.編譯
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DENABLED_LOCAL_INFILE=1 \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/local/boost
6.安裝
make && make install
7. 初始化MySQL
cd /usr/local/mysql/bin
./mysqld --initialize --user=mysql --datadir=/data/mysql --basedir=/usr/local/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/usr/local/mysql/run/mysqld.pid
8. 添加MySQL服務(wù)并設(shè)置開機啟動
cd /usr/local/mysql/support-files
cp mysql.server /etc/init.d/mysqld
cd /etc/init.d/
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
9. 編輯my.cnf文件
vi /etc/my.cnf
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
user = mysql
basedir = /usr/local/mysql
datadir = /data/mysql
pid-file=/usr/local/mysql/run/mysqld.pid
log-error = /var/log/mysql/mysqld.log
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
thread_cache_size = 8
query_cache_size = 8M
tmp_table_size = 16M
#skip-networking
max_connections = 500
max_connect_errors = 100
open_files_limit = 65535
log-bin=mysql-bin
binlog_format = mixed
server-id = 1
expire_logs_days = 10
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
10. 重啟MySQL
/etc/init.d/mysql start
Starting MySQL.. SUCCESS!
11. 登錄MySQL
cd ../bin/
./mysql -uroot -p //第一次登錄MySQL,密碼文件在,也可以從make install 最后的一行看到密碼,若看不到可以參考以下修改密碼的步驟
Enter password:
12.忘記root密碼可通過以下方法修改
vi /etc/my.cnf
[mysqld]
skip-grant-tables
重啟mysqld服務(wù),重新登陸已不需要密碼
13.修改root密碼
use mysql
update user set authentication_string=PASSWORD('zabbix') where User='root';
14.退出刪除mysql.cnf中的skip-grant-tables,以新密碼重新登陸即可
15.首次登陸需要重新設(shè)置一下新密碼,否則任何命令都會提示:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
set password for root@localhost = password('zabbix');
16.創(chuàng)建zabbix數(shù)據(jù)庫
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
二.安裝Zabbix
1.安裝官方的yum源
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
2.yum安裝zabbix-server\zabbix-web\zabbix-agent
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent
3.初始化數(shù)據(jù)庫
cd /usr/share/doc/zabbix-server-mysql-3.0.*
zcat create.sql.gz | mysql -uroot -pzabbix zabbix
4.編輯zabbix server配置文件
vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
5.開啟zabbix server以及agent服務(wù)并設(shè)置開機啟動
systemctl start zabbix-server
systemctl enable zabbix-server
systemctl start zabbix-agent
systemctl enable zabbix-agent
6.確保php的配置符合zabbix的要求(默認(rèn)已含下列配置),并修改timezone為PRC
vi /etc/httpd/conf.d/zabbix.conf
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
7.開啟Apache服務(wù)并設(shè)置開機啟動
systemctl start httpd
systemctl enable httpd
8.打開zabbix頁面http://192.168.17.100/zabbix/,首次要求初始化
PHP檢查通過
連接mysql數(shù)據(jù)庫
確保mysql.sock協(xié)議文件在/var/lib/mysql/下,如果不在可通過my.cnf修改
自定義zabbix server的細(xì)節(jié)
初始化完成
進(jìn)入zabbix界面
9.修改語言
Zabbix 3.0.3可以直接在界面上修改為簡體中文
三.Agent安裝
1.Linux OS rpm包安裝
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
yum install zabbix-agent -y
sed -i 's/^Server=.*/Server=192.168.17.100/g' /etc/zabbix/zabbix_agentd.conf
sed -i 's/^ServerActive=.*/ServerActive=192.168.17.100/g' /etc/zabbix/zabbix_agentd.conf
sed -i 's/^Hostname=.*/Hostname=TestHost/g' /etc/zabbix/zabbix_agentd.conf
service zabbix-agent start
2.Windows OS agent設(shè)置
http://www.zabbix.com/downloads/3.0.0/zabbix_agents_3.0.0.win.zip
修改zabbix_agent\conf\zabbix_agentd.win.conf中的hostname
在cmd窗口運行以下命令(64位\32位)
"C:\Program Files\zabbix\bin\win64\zabbix_agentd.exe" -c "C:\Program Files\zabbix\conf\zabbix_agentd.win.conf" -i
"C:\Program Files\zabbix\bin\win64\zabbix_agentd.exe" -c "C:\Program Files\zabbix\conf\zabbix_agentd.win.conf" -s
"C:\Program Files\zabbix\bin\win32\zabbix_agentd.exe" -c "C:\Program Files\zabbix\conf\zabbix_agentd.win.conf" -i
"C:\Program Files\zabbix\bin\win32\zabbix_agentd.exe" -c "C:\Program Files\zabbix\conf\zabbix_agentd.win.conf" -s
3.Linux OS source包安裝
groupadd zabbix
useradd zabbix -g zabbix -s /sbin/nologin
cd /usr/local/src/
wget http://ufpr.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.3/zabbix-3.0.3.tar.gz
tar -xzvf zabbix-3.0.3.tar.gz
cd zabbix-3.0.3
./configure --prefix=/usr/local/zabbix/ --enable-agent
make
make install
sed -i 's/^Server=.*/Server=192.168.17.100/g' /usr/local/zabbix/etc/zabbix_agentd.conf
sed -i 's/^ServerActive=.*/ServerActive=192.168.17.100/g' /usr/local/zabbix/etc/zabbix_agentd.conf
sed -i 's/^Hostname=.*/Hostname=TestHost/g' /usr/local/zabbix/etc/abbix_agentd.conf
啟動agent服務(wù)
/usr/local/zabbix/sbin/zabbix_agentd start
設(shè)置開機啟動
vi /etc/rc.d/rc.local
添加以下內(nèi)容
/usr/local/zabbix/sbin/zabbix_agentd start
四.附加配置
1.開放系統(tǒng)防火墻端口
firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" source address="192.168.17.0/24" port protocol="tcp" port="80" accept"
firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" source address="192.168.17.0/24" port protocol="tcp" port="10050" accept"
firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" source address="192.168.17.0/24" port protocol="tcp" port="10051" accept"
firewall-cmd --reload
2.從舊版本的zabbix升級
@舊版本zabbix
停用zabbix-server服務(wù),防止有新的數(shù)據(jù)產(chǎn)生
service zabbix-server stop
備份舊版本的數(shù)據(jù)庫
mysqldump -uroot -pzabbix zabbix > zabbix.sql
將備份后的數(shù)據(jù)庫傳到新的zabbix平臺
@新版本zabbix
停止zabbix-server/agent服務(wù)
service zabbix-server stop
service zabbix-agent stop
刪除zabbix 3.0.3初始化后的數(shù)據(jù)庫
drop database zabbix
導(dǎo)入舊版本的數(shù)據(jù)庫
mysql -uroot -pzabbix zabbix < zabbix.sql
查看日志tail -f /var/log/zabbix/zabbix-server.log,數(shù)據(jù)庫會自動升級
8816:20160527:140441.797 completed 0% of database upgrade
8816:20160527:140441.812 completed 1% of database upgrade
8816:20160527:140441.846 completed 2% of database upgrade
8816:20160527:140441.878 completed 3% of database upgrade
8816:20160527:140441.911 completed 4% of database upgrade
8816:20160527:140441.925 completed 5% of database upgrade
8816:20160527:140441.957 completed 6% of database upgrade
8816:20160527:140441.969 completed 7% of database upgrade
8816:20160527:140441.981 completed 8% of database upgrade
8816:20160527:140441.992 completed 9% of database upgrade
8816:20160527:140442.022 completed 10% of database upgrade
....
重新開啟服務(wù),一切正常
service zabbix-server start
service zabbix-agent start
3.中文亂碼問題
cd /usr/share/zabbix/fonts
上傳任一中文字體到該目錄,并修改php文件
vi /usr/share/zabbix/include/defines.inc.php
#('ZBX_GRAPH_FONT_NAME', 'graphfont'); #將graphfont替換為msyh(雅黑字體)文件名即可
#('ZBX_FONT_NAME', 'graphfont'); #將graphfont替換為msyh(雅黑字體)文件名即可
4.設(shè)置郵件報警
Zabbix 3.0可以直接在web界面配置郵件報警,不需要腳本的形式
安裝Sendmail
yum install sendmail –y
chkconfig sendmail on
service sendmail start
進(jìn)入管理-報警媒介類型-Email-設(shè)置發(fā)送郵箱的信息
管理-用戶群組,確保用戶群組有對監(jiān)控設(shè)備有對應(yīng)權(quán)限
配置-動作,有告警信息時通過Email發(fā)送給相關(guān)的用戶
編輯動作詳情
默認(rèn)接收人:
{TRIGGER.STATUS}: {TRIGGER.NAME}
默認(rèn)信息:
告警主機:{HOST.NAME}
告警IP:{HOST.IP}
告警時間:{EVENT.DATE}-{EVENT.TIME}
告警等級:{TRIGGER.SEVERITY}
告警信息:{TRIGGER.NAME}
問題詳情:{ITEM.NAME}:{ITEM.VALUE}
時間ID:{EVENT.ID}
恢復(fù)主題:
恢復(fù){TRIGGER.STATUS}, 服務(wù)器:{HOSTNAME1}: {TRIGGER.NAME}已恢復(fù)!
恢復(fù)信息:
告警主機:{HOST.NAME}
告警IP:{HOST.IP}
告警時間:{EVENT.DATE}-{EVENT.TIME}
告警等級:{TRIGGER.SEVERITY}
告警信息:{TRIGGER.NAME}
問題詳情:{ITEM.NAME}:{ITEM.VALUE}
時間ID:{EVENT.ID}
注意:使用部分的郵箱無法正常發(fā)送郵件,日志報錯:
11707:20160527:165712.955 Login denied: Authentication failed: 535
換成其它郵件就好了
管理-用戶-報警媒介,設(shè)置接收告警的郵箱地址
關(guān)閉監(jiān)控的zabbix-agent服務(wù),可以收到告警郵件。
5.配置默認(rèn)主頁為zabbix
vi /etc/httpd/conf.d/httpd.conf
修改以下內(nèi)容:
DocumentRoot "/usr/share/zabbix"
重啟服務(wù)即可
service httpd restart
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。