MySQL性能監(jiān)控軟件Nagios的安裝及配置教程
Nagios是一款Linux上成熟的監(jiān)視系統(tǒng)運(yùn)行狀態(tài)和網(wǎng)絡(luò)信息的開(kāi)原IT基礎(chǔ)設(shè)施監(jiān)視系統(tǒng),Nagios能監(jiān)視所指定的本地或遠(yuǎn)程主機(jī)及服務(wù),例如HTTP服務(wù)、FTP服務(wù)等,同時(shí)提供異常通知、事件處理等功能,當(dāng)主機(jī)或服務(wù)出現(xiàn)故障時(shí),Nagios還可以通過(guò)郵件、手機(jī)短信等形式在第一時(shí)間進(jìn)行通知。Nagios可運(yùn)行在Linux和Unix平臺(tái)上,同時(shí)提供一個(gè)可選的基于瀏覽器的Web界面,方便系統(tǒng)管理員查看系統(tǒng)的運(yùn)行狀態(tài)、網(wǎng)絡(luò)狀態(tài)、各種系統(tǒng)問(wèn)題及日志異常等。
環(huán)境: 192.168.0.201 mysql主機(jī) rhel6.4
192.186.0.202 nagios主機(jī) rhel6.4
安裝相關(guān)軟件包:
yum install httpd gcc make perl-ExtUtils-Embed.x86_64 -y yum localinstall gd-devel-2.0.35-11.el6.x86_64.rpm -y
安裝nagios:
useradd nagios usermod -G nagios apache #編譯所需軟件包 #運(yùn)行 nagios 服務(wù)的用戶(hù) #使 apache 用戶(hù)對(duì) nagios 目錄具有寫(xiě)權(quán)限,不然 web 頁(yè)面操作失敗 tar jxf nagios-cn-3.2.3.tar.bz2 #nagios 軟件安裝 cd nagios-cn-3.2.3 ./configure –enable-embedded-perl make all //根據(jù)提示完成安裝 make install make install-init make install-commandmode make install-config make install-webconf //在apache下通過(guò)這條命令可以快速整合
安裝nagios-plugins:
yum install mysql-devel openssl-devel -y tar zxf nagios-plugins-1.4.15.tar.gz cd nagios-plugins-1.4.15 ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-extra-opts --enable-libtap --enable-perl-modules make make install
配置nagios:
vi /usr/local/nagios/etc/nagios.cfg
#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg #注釋掉localhost.cfg文件 cfg_file=/usr/local/nagios/etc/objects/services.cfg #新建 services.cfg 文件,存放服務(wù)與服務(wù)組定義 cfg_file=/usr/local/nagios/etc/objects/hosts.cfg #新建 hosts.cfg 文件,存放主機(jī)與主機(jī)組定義
配置hosts.cfg:
vi /usr/local/nagios/etc/objects/hosts.cfg
define host{ //主機(jī)的管理 use linux-server //使用默認(rèn)的主機(jī)規(guī)則 host_name vm2.example.com //主機(jī)名 alias Nagios vm2 //主機(jī)別名 address 127.0.0.1 //主機(jī)ip地址 icon_image switch.gif //圖標(biāo) statusmap_image switch.gd2 2d_coords 100,200 //2D圖像坐標(biāo) 3d_coords 100,200,100 //3D圖像坐標(biāo) } define hostgroup{ //主機(jī)組的管理 hostgroup_name linux-servers //主機(jī)組名字 alias Linux Servers //別名 members * //*代表上面所有主機(jī)
配置mysql
----建立nagdb專(zhuān)用數(shù)據(jù)庫(kù)
mysql> create database nagdb default CHARSET=utf8;
Query OK, 1 row affected (0.01 sec)
mysql> grant select on nagdb.* to 'nagios'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> update mysql.user set 'Password' = PASSWORD('nagios') where 'User'='nagios';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''Password' = PASSWORD('nagios') where 'User'='nagios'' at line 1 mysql> update mysql.user set Password = PASSWORD('nagios') where user='nagios'; Query OK, 1 row affected (0.03 sec) Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
----用以下命令來(lái)驗(yàn)證一下:
[root@node2 etc]# /usr/local/nagios/libexec/check_mysql -H 192.168.1.152 -u nagios -d nagdb -p nagios
Uptime: 3374 Threads: 1 Questions: 11 Slow queries: 0 Opens: 33 Flush tables: 1 Open tables: 26 Queries per second avg: 0.003
備注:如果出現(xiàn):/usr/local/nagios/libexec/check_mysql: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
請(qǐng)查看$MYSQL_HOME/lib
[root@node2 lib]# ln -s ./libmysqlclient.so.18.0.0 /usr/lib/libmysqlclient.so.18
配置nrpe.cfg
[root@node2 etc]# tail /usr/local/nagios/etc/nrpe.cfg
command[check_mysql]=/usr/local/nagios/libexec/check_mysql -H 192.168.1.152 -u nagios -d nagdb -p nagios //加入此行
配置nagios服務(wù)端
[root@node1 etc]# cat services.cfg //加入下面內(nèi)容
define service{ use local-service host_name node2 service_description mysql check_command check_nrpe!check_mysql notifications_enabled 1 }
最后重啟nrpe和服務(wù)端的nagios。
- mysql服務(wù)性能優(yōu)化—my.cnf_my.ini配置說(shuō)明詳解(16G內(nèi)存)
- 安裝配置MySQLMTOP來(lái)監(jiān)控MySQL運(yùn)行性能的教程
- mysql性能監(jiān)控工具Innotop簡(jiǎn)介及配置
- MySQL性能優(yōu)化之Open_Table配置參數(shù)的合理配置建議
- MySQL性能優(yōu)化之table_cache配置參數(shù)淺析
- MySQL性能優(yōu)化之max_connections配置參數(shù)淺析
- MySQL性能優(yōu)化配置參數(shù)之thread_cache和table_cache詳解
- MySQL性能優(yōu)化之路---修改配置文件my.cnf
- MySQL配置文件my.cnf中文詳解附mysql性能優(yōu)化方法分享
- 可以改善mysql性能的InnoDB配置參數(shù)
- 影響MySQL性能的五大配置參數(shù)
- 安裝MySQL后,需要調(diào)整的10個(gè)性能配置項(xiàng)
相關(guān)文章
詳解MySQL中的數(shù)據(jù)類(lèi)型和schema優(yōu)化
這篇文章主要介紹了MySQL中的數(shù)據(jù)類(lèi)型和schema優(yōu)化的相關(guān)資料,幫助大家更好的理解和學(xué)習(xí)MySQL的知識(shí),感興趣的朋友可以了解下2020-10-10Mysql數(shù)據(jù)庫(kù)表中為什么有索引卻沒(méi)有提高查詢(xún)速度
你有沒(méi)有想起過(guò)為什么明明再數(shù)據(jù)庫(kù)中有索引,但是查詢(xún)速度卻并沒(méi)有希望的那樣快?本篇文章將帶給你答案,跟小編一起看看吧2022-02-02

MySQL定時(shí)備份數(shù)據(jù)庫(kù)操作示例

解決MySQL時(shí)區(qū)日期時(shí)差8個(gè)小時(shí)的問(wèn)題

mysql存儲(chǔ)過(guò)程之返回多個(gè)值的方法示例