免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
Zabbix部署、監(jiān)測及郵件報(bào)警機(jī)制(實(shí)戰(zhàn)!)

Zabbix部署

實(shí)驗(yàn)環(huán)境:

CentOS 7-2:192.168.18.147(監(jiān)測端:部署安裝zabbix)

CentOS 7-3:192.168.18.128(被監(jiān)測端)

監(jiān)測端操作:

[root@cacti ~]# systemctl stop firewalld.service        #關(guān)閉防火墻功能[root@cacti ~]# systemctl disable firewalld.service     #開機(jī)禁用防火墻功能Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.[root@cacti ~]# setenforce 0                            #關(guān)閉增強(qiáng)型安全功能`安裝LAMP架構(gòu)`[root@cacti ~]# yum install -y httpd mariadb-server mariadb php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mhash`編輯apache配置文件`[root@cacti ~]# vim /etc/httpd/conf/httpd.conf95 ServerName www.yun.com:80                        #第95行,刪除注釋,域名自定義164     DirectoryIndex index.html index.php         #164行,添加首頁支持類類型index.php#修改完成后按Esc退出插入模式,輸入:wq保存退出`修改時(shí)區(qū)為中國`[root@cacti ~]# vim /etc/php.ini878 date.timezone = PRC     #878行,把前面模板的;號刪除,后面添加中國時(shí)區(qū)PRC#修改完成后按Esc退出插入模式,輸入:wq保存退出[root@cacti ~]# systemctl start httpd.service       #啟動(dòng)apache服務(wù)[root@cacti ~]# systemctl start mariadb.service     #啟動(dòng)mariadb服務(wù)[root@cacti ~]# netstat -ntap | egrep '(3306|80)'   #使用egrep命令同時(shí)查看3306和80端口tcp        0      0 0.0.0.0:3306            0.0.0.0:*            LISTEN      4410/mysql   tcp6       0      0 :::80                   :::*                 LISTEN      4131/httpd    `初始化數(shù)據(jù)庫配置`[root@cacti ~]# mysql_secure_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the currentpassword for the root user.  If you've just installed MariaDB, andyou haven't set the root password yet, the password will be blank,so you should just press enter here.Enter current password for root (enter for none):   #此處直接回車OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDBroot user without the proper authorisation.Set root password? [Y/n] y      #設(shè)置密碼New password:       #abc123Re-enter new password:      #確認(rèn)輸入:abc123Password updated successfully!Reloading privilege tables.. ... Success!By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem.  This is intended only for testing, and to make the installationgo a bit smoother.  You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] n     #是否刪除匿名用戶,選擇不刪除 ... skipping.Normally, root should only be allowed to connect from 'localhost'.  Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] y   #是否遠(yuǎn)程連接 ... Success!By default, MariaDB comes with a database named 'test' that anyone canaccess.  This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] n      #是否刪除測試數(shù)據(jù)庫 ... skipping.Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? [Y/n] y    #是否重新加載 ... Success!Cleaning up...All done!  If you've completed all of the above steps, your MariaDBinstallation should now be secure.Thanks for using MariaDB!#驗(yàn)證登錄數(shù)據(jù)庫[root@cacti ~]# mysql -u root -pEnter password:     #輸入密碼abc123Welcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection id is 8Server version: 5.5.64-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.`創(chuàng)建zabbix數(shù)據(jù)庫,并且設(shè)置為utf8形式,把里面的字符串轉(zhuǎn)換為二進(jìn)制`MariaDB [(none)]> CREATE DATABASE zabbix character set utf8 collate utf8_bin;Query OK, 1 row affected (0.00 sec)`提升用戶`MariaDB [(none)]> show databases; -------------------- | Database           | -------------------- | information_schema || mysql              || performance_schema || test               || zabbix             | -------------------- 5 rows in set (0.00 sec)#此時(shí)有zabbix數(shù)據(jù)庫,需要?jiǎng)?chuàng)建管理里這個(gè)數(shù)據(jù)庫的用戶MariaDB [(none)]> GRANT all privileges ON *.* TO 'zabbix'@'%' IDENTIFIED BY 'admin123';Query OK, 0 rows affected (0.01 sec)    #把所有數(shù)據(jù)庫和所有表都交給zabbix進(jìn)行管理,并且設(shè)置密碼為admin123MariaDB [(none)]> flush privileges;     #刷新Query OK, 0 rows affected (0.00 sec)MariaDB [(none)]> quit      #退出數(shù)據(jù)庫Bye`測試php基本信息`[root@localhost ~]# cd /var/www/html/[root@localhost html]# ls[root@localhost html]# vim index.php<?php  phpinfo();?>
此時(shí)在宿主機(jī)中輸入:192.168.18.147,查看是否可以訪問php頁面:

測試是否能夠連接數(shù)據(jù)庫:
[root@localhost html]# vim index.php#先按3dd刪除原有內(nèi)容,再插入以下內(nèi)容<?php$link=mysql_connect('192.168.18.147','zabbix','admin123');if($link) echo "<h1>Success!!</h1>";else echo "Fail!!";mysql_close();?>
此時(shí)在宿主機(jī)中刷新之前的頁面:192.168.18.147,如果可以訪問mysql數(shù)據(jù)庫則返回Success提示,如果不能則返回Fail提示:

解決問題:

如果出現(xiàn)Fail報(bào)錯(cuò)一般為本地?zé)o法登錄得問題,可以使用以下方法解決
[root@cacti html]# mysql -u zabbix -pEnter password:     #此時(shí)輸入admin123無法登錄數(shù)據(jù)庫,說明有用戶占用ERROR 1045 (28000): Access denied for user 'zabbix'@'localhost' (using password: YES)`先使用root用戶登錄數(shù)據(jù)庫`[root@cacti html]# mysql -u root -pEnter password:Welcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection id is 15Server version: 5.5.64-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> select user,host from mysql.user; -------- ----------- | user   | host      | -------- ----------- | zabbix | %         || root   | 127.0.0.1 || root   | ::1       ||        | cacti     ||        | localhost || root   | localhost | -------- ----------- 6 rows in set (0.00 sec)`以下操作刪除空用戶`MariaDB [(none)]> drop user ''@localhost;Query OK, 0 rows affected (0.00 sec)MariaDB [(none)]> drop user ''@cacti;Query OK, 0 rows affected (0.00 sec)`此時(shí)空用戶被刪除`MariaDB [(none)]> select user,host from mysql.user; -------- ----------- | user   | host      | -------- ----------- | zabbix | %         || root   | 127.0.0.1 || root   | ::1       || root   | localhost | -------- ----------- 4 rows in set (0.00 sec)MariaDB [(none)]> quitBye`此時(shí)再次刷新頁面就會顯示Success?。〕晒Φ卿沗

部署Zabbix Server

[root@cacti html]# yum install php-bcmath php-mbstring -y`安裝zabbix源`[root@cacti html]# rpm -ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm獲取http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm警告:/var/tmp/rpm-tmp.13QGZK: 頭V4 RSA/SHA512 Signature, 密鑰 ID a14fe591: NOKEY準(zhǔn)備中...                          ################################# [100%]正在升級/安裝...   1:zabbix-release-3.5-1.el7         ################################# [100%]`查看源`[root@cacti html]# cd /etc/yum.repos.d/[root@cacti yum.repos.d]# lsCentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repoCentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo  zabbix.repo[root@cacti yum.repos.d]# cat zabbix.repo[zabbix]name=Zabbix Official Repository - $basearchbaseurl=http://repo.zabbix.com/zabbix/3.5/rhel/7/$basearch/enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591[zabbix-non-supported]name=Zabbix Official Repository non-supported - $basearchbaseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/enabled=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIXgpgcheck=1[root@cacti yum.repos.d]# yum install zabbix-server-mysql zabbix-web-mysql -y......此處省略多行已安裝:  zabbix-server-mysql.x86_64 0:4.0.0-1.1rc3.el7    zabbix-web-mysql.noarch 0:4.0.0-1.1rc3.el7作為依賴被安裝:  OpenIPMI.x86_64 0:2.0.27-1.el7                   OpenIPMI-libs.x86_64 0:2.0.27-1.el7  OpenIPMI-modalias.x86_64 0:2.0.27-1.el7          fping.x86_64 0:3.10-1.el7  iksemel.x86_64 0:1.4-2.el7.centos                zabbix-web.noarch 0:4.0.0-1.1rc3.el7`生成數(shù)據(jù)庫文件`[root@cacti yum.repos.d]# zcat /usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz | mysql -u zabbix -p  zabbixEnter password:     #輸入密碼admin123[root@cacti yum.repos.d]# grep -n '^'[a-Z] /etc/zabbix/zabbix_server.conf38:LogFile=/var/log/zabbix/zabbix_server.log49:LogFileSize=072:PidFile=/var/run/zabbix/zabbix_server.pid82:SocketDir=/var/run/zabbix101:DBName=zabbix117:DBUser=zabbix357:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log475:Timeout=4518:AlertScriptsPath=/usr/lib/zabbix/alertscripts529:ExternalScripts=/usr/lib/zabbix/externalscripts565:LogSlowQueries=3000#是配置文件中缺少的就是密碼,其它得系統(tǒng)已自動(dòng)配置[root@cacti yum.repos.d]# vim /etc/zabbix/zabbix_server.conf125 DBPassword=admin123     #125行刪除注釋,添加密碼admin123在=號后面#修改完成后按Esc退出插入模式,輸入:wq保存退出`修改時(shí)區(qū)`[root@cacti yum.repos.d]# vim /etc/httpd/conf.d/zabbix.conf20         php_value date.timezone Asia/Shanghai        #20行刪除注釋,失去改為Asia/Shanghai#修改完成后按Esc退出插入模式,輸入:wq保存退出`修正圖表中文亂碼`[root@cacti yum.repos.d]# vim /usr/share/zabbix/include/defines.inc.php#輸入以下內(nèi)容進(jìn)行全局字體替換為kaiti:%s /graphfont/kaiti/g#修改完成后按Esc退出插入模式,輸入:wq保存退出`復(fù)制STKAITI.TTF文件到字體目錄下`[root@cacti yum.repos.d]# mkdir /aaa        #創(chuàng)建掛載目錄[root@cacti yum.repos.d]# mount.cifs //192.168.0.105/rpm /aaa       #進(jìn)行遠(yuǎn)程掛載Password for root@//192.168.0.105/rpm:[root@cacti yum.repos.d]# cd /aaa/zabbix/[root@cacti zabbix]# lsphp-bcmath-5.4.16-42.el7.x86_64.rpm    STKAITI.TTFphp-mbstring-5.4.16-42.el7.x86_64.rpm  zabbix.conf.php[root@cacti zabbix]# cp STKAITI.TTF /usr/share/zabbix/fonts/`啟動(dòng)服務(wù)查看端口開啟情況`[root@cacti zabbix]# systemctl enable zabbix-serverCreated symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.[root@cacti zabbix]# systemctl start zabbix-server[root@cacti zabbix]# netstat -ntap | grep zabbix        #監(jiān)聽端口為10051tcp        0      0 0.0.0.0:10051           0.0.0.0:*        LISTEN    6735/zabbix_servertcp6       0      0 :::10051                :::*             LISTEN    6735/zabbix_server[root@cacti zabbix]# systemctl restart httpd.service    #重啟httpd服務(wù),用于驗(yàn)證登錄zabbix

驗(yàn)證:登錄操作,安裝zabbix

第一步:在宿主機(jī)地址欄中輸入:http://192.168.18.147/zabbix/可進(jìn)入以下頁面,按Next step進(jìn)入下一步

第二步:確認(rèn)檢查全部為OK之后,按Next step進(jìn)入下一步

第三步:數(shù)據(jù)庫設(shè)置,輸入端口號3306,填寫密碼admin123,按Next step進(jìn)入下一步

第四步:填寫zabbix服務(wù)名稱,此處填寫Zabbix(可自行定義),按Next step進(jìn)入下一步

第五步:可以顯示之前所有配置的內(nèi)容,直接按Next step進(jìn)入下一步

第六步:進(jìn)入頁面后直接按Finish結(jié)束,進(jìn)入登陸界面,輸入默認(rèn)賬戶Admin,默認(rèn)密碼zabbix,點(diǎn)擊登錄

此時(shí)就可以進(jìn)入到zabbix的監(jiān)控界面了:

可點(diǎn)擊右上角人物頭像,在Language語言欄選擇Chinese(zh_CN)簡體中文,點(diǎn)擊Update更新

以上就是監(jiān)測端的所有操作!


被監(jiān)測端操作:

[root@localhost ~]# systemctl stop firewalld.service[root@localhost ~]# systemctl disable firewalld.serviceRemoved symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.[root@localhost ~]# setenforce 0`安裝yum源`[root@localhost ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm獲取http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm警告:/var/tmp/rpm-tmp.elS5cl: 頭V4 RSA/SHA512 Signature, 密鑰 ID a14fe591: NOKEY準(zhǔn)備中...                          ################################# [100%]正在升級/安裝...   1:zabbix-release-3.5-1.el7         ################################# [100%][root@localhost ~]# cd /etc/yum.repos.d/[root@localhost yum.repos.d]# lsCentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repoCentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo  zabbix.repo[root@localhost yum.repos.d]# yum install zabbix-agent -y`修改配置文件`[root@localhost yum.repos.d]# grep -n '^'[a-Z] /etc/zabbix/zabbix_agentd.conf13:PidFile=/var/run/zabbix/zabbix_agentd.pid32:LogFile=/var/log/zabbix/zabbix_agentd.log43:LogFileSize=098:Server=127.0.0.1             #此處需要修改為監(jiān)控端IP139:ServerActive=127.0.0.1      #此處需要修改為監(jiān)控端IP150:Hostname=Zabbix server268:Include=/etc/zabbix/zabbix_agentd.d/*.conf[root@localhost yum.repos.d]# vim /etc/zabbix/zabbix_agentd.conf98 Server=192.168.18.147            #98行,指向監(jiān)控服務(wù)器IP139 ServerActive=192.168.18.147     #139行,指向監(jiān)控服務(wù)器IP150 Hostname=zhou                   #主機(jī)名,可自行定義#修改完成后按Esc退出插入模式,輸入:wq保存退出`啟動(dòng)服務(wù)`[root@localhost yum.repos.d]# systemctl enable zabbix-agent.serviceCreated symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.[root@localhost yum.repos.d]# systemctl restart zabbix-agent.service[root@localhost yum.repos.d]# netstat -ntap | grep zabbix       #監(jiān)聽端口為10050tcp        0      0 0.0.0.0:10050           0.0.0.0:*         LISTEN   5425/zabbix_agentdtcp6       0      0 :::10050                :::*              LISTEN   5425/zabbix_agentd

此時(shí)不會自動(dòng)識別被監(jiān)控端,需要做以下操作:

第一步:找到配置下的主機(jī)選項(xiàng),點(diǎn)擊創(chuàng)建主機(jī)

第二步:在主機(jī)配置界面填入相應(yīng)內(nèi)容,然后點(diǎn)擊模板

第三步:在模板中選擇HTTP和SSH的模板鏈接,點(diǎn)擊提示器中的添加,然后再點(diǎn)擊藍(lán)色的添加圖標(biāo)

此時(shí)回到開始的界面就會顯示新添加的監(jiān)控項(xiàng)

以上就實(shí)現(xiàn)了服務(wù)器監(jiān)控被監(jiān)控端,假如被監(jiān)控端遇到問題,就會觸發(fā)報(bào)警,最終會以郵件形式提供(需要添加郵件發(fā)送服務(wù))


Zabbix監(jiān)測和報(bào)警機(jī)制

監(jiān)控端安裝郵件報(bào)警功能的操作
[root@cacti zabbix]# yum install mailx -y[root@cacti zabbix]# vim /etc/mail.rc#在末行下插入以下內(nèi)容set from=郵箱地址   #例如19919919911@163.comset smtp=smtp.163.comset smtp-auth-user=郵箱地址set smtp-auth-password=郵箱密碼set smtp-auth=login#修改完成后按Esc退出插入模式,輸入:wq保存退出`嘗試發(fā)送測試郵件`[root@cacti zabbix]# echo "hello world" | mail -s "testmail" 郵箱地址
此時(shí)郵箱收到測試郵件:

編寫發(fā)郵件腳本:

[root@cacti zabbix]# cd /usr/lib/zabbix/alertscripts[root@cacti alertscripts]# vim mail.sh#!/bin/bash#send mailmessages=`echo $3 | tr '\r\n' '\n'`subject=`echo $2 | tr '\r\n' '\n'`echo "${messages}" | mail -s "${subject}" $1 >>/tmp/mailx.log 2>&1#修改完成后按Esc退出插入模式,輸入:wq保存退出[root@cacti alertscripts]# mv mail.sh mailx.sh`在tmp目錄下創(chuàng)建mailx的日志文件`[root@cacti alertscripts]# touch /tmp/mailx.log`賦予權(quán)限`[root@cacti alertscripts]# chown -R zabbix.zabbix  /tmp/mailx.log[root@cacti alertscripts]# chmod  x /usr/lib/zabbix/alertscripts/mailx.sh[root@cacti alertscripts]# chown -R zabbix.zabbix /usr/lib/zabbix/`驗(yàn)證過程`[root@cacti alertscripts]# ./mailx.sh 郵箱地址 "yun" "hello"#其中郵箱地址為$1,yun為$2主題,hello為$3內(nèi)容

此時(shí)執(zhí)行完腳本,郵箱中就可以收到相對應(yīng)的郵件了!

接下來進(jìn)入Web界面進(jìn)行設(shè)置:

第一步:在上方選擇管理,找到其中的報(bào)警媒介類型,再點(diǎn)擊頁面右上角的創(chuàng)建媒體類型,在界面中輸入相關(guān)信息

第二步:選項(xiàng)中會顯示3次探測服務(wù),如果宕掉就會觸發(fā)報(bào)警,最后點(diǎn)擊下方的藍(lán)色添加圖標(biāo),就可以生成新的報(bào)警類型了


接下來我們需要指定用戶

第一步:找到配置中的用戶界面,點(diǎn)擊Admin用戶

第二步:在用戶的報(bào)警媒介中點(diǎn)擊添加,輸入相對應(yīng)的媒介信息,最后點(diǎn)擊添加

第三步:添加媒介之后一定不要忘記點(diǎn)擊更新

在動(dòng)作中刪除原有模板,在進(jìn)行重新定義,點(diǎn)擊右上角的創(chuàng)建動(dòng)作

第一步:在動(dòng)作界面中輸入名稱,生成新的觸發(fā)條件

第二步:在操作中做以下操作,下方點(diǎn)擊新的,做添加操作,最后點(diǎn)擊跟新

此時(shí)新的操作生成!

第三步:恢復(fù)操作中做以下填寫

此時(shí)新的操作生成!

第四步:點(diǎn)擊藍(lán)色圖標(biāo)添加,此時(shí)就會進(jìn)行持續(xù)性的監(jiān)控了

查看被監(jiān)控端SSH遠(yuǎn)程連接服務(wù)狀態(tài)

[root@localhost yum.repos.d]# systemctl status sshd● sshd.service - OpenSSH server daemon   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)   Active: active (running) since 一 2019-11-25 11:00:11 CST; 2 months 7 days ago#此時(shí)顯示為running運(yùn)行狀態(tài)`停止此服務(wù)`[root@localhost yum.repos.d]# systemctl stop sshd

此時(shí)我們看監(jiān)控界面會不會跳出提示

經(jīng)過等待幾分鐘之后監(jiān)控界面會自動(dòng)跳出SSH服務(wù)down的提示,此時(shí)郵箱也會收到郵件

`啟動(dòng)sshd服務(wù)`[root@localhost yum.repos.d]# systemctl start sshd
此時(shí)幾分鐘過后會自動(dòng)監(jiān)測到服務(wù)成功開啟,報(bào)警已解決,同時(shí)郵箱也會收到服務(wù)恢復(fù)的郵件

以上就是Zabbix監(jiān)控的監(jiān)測和報(bào)警機(jī)制

來源:https://www.icode9.com/content-4-628901.html
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
CentOS更改yum源與更新系統(tǒng)
不給電腦,我用手機(jī)敲命令十分鐘完成了zabbix監(jiān)控,面試官當(dāng)場下offer
搭建zabbix 4.0
1、Zabbix企業(yè)及監(jiān)控
2-Preparations before Install Cacti
centos7更改dns配置
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服