Zabbix 3.2.6 通過Orabbix監控Oracle數據庫

一、背景

    公司業務使用的是一直Oracle數據庫,因爲多次出現表空間滿的時候不能及時發現,每次都是業務組的人員通知處理,這樣下來DBA這邊就比較被動,所以老大要求監控表空間剩餘大小並且當剩餘過小時能夠及時報警。剛想出來的方案是通過寫腳本獲取表空間的數據,通腳本中使用expect自動輸入密碼登陸oracle用戶然後再登陸數據庫查詢數據返回給zabbix_server。但是由於腳本運行時間大概12秒左右,zabbix獲取數據總是超時,在網上搜索中發現zabbix插件orabbix,原理是通過orabbix登陸被監控主機oracle數據庫,查詢數據。個人認爲非常好用,包括自定義監控項。唯一的麻煩就是需要在配置文件中添加每一個數據庫服務器ip、數據庫用戶、密碼。

二、Orabbix介紹

    Orabbix是設計用來爲zabbix監控Oracle的數據庫的插件,它提供多層次的監控,包括可用性和服務器性能的指標。它提供了從衆多Oracle實例採集的有效機制,進而提供此信息的監控和性能指標。然後,您可以利用的zabbix的報告功能爲收集的所有數據,並提供分析。目前的發行版中包含了一組預先定義的模板,包括從初始部署報警和圖形功能。然而,這些可以進行微調,以滿足您額需求和數據/監控要求。

wKiom1nMX8zDJ5GYAAK4cqzvph0185.png

三、Orabbix功能

  • DB Version (i.e. Validity of package)

  • Archiving (Archive log production with trend analysis)

  • Event Waits (Files I/O, single block read, multi-block read, direct path read, SQLNet Messages, Control file I/O, Log Write)

  • Hit Ratio (Hit Ratio on Triggers, Tables/Procedures, SQL Area, Body)

  • Logical I/O (Server performance on Logical I/O of: Current Read, Consistent Read, Block Change)

  • Physical I/O (Redo Writes, Datafile Writes, Datafile Reads)

  • PGA

  • SGA (In particular; Fixed Buffer, Java Pool, Large Pool, Log Buffer, Shared Poolm Buffer Cache)

  • Shared Pool (Pool Dictionary Cache, Pool Free Memory, Library Chache, SQL Area, MISC.)

  • Pin Hit Ratio (Oracle library cache pin are caused by contention with the library cache, the area used to store SQL executables for re-use)

  • Sessions / Processes

  • Sessions (Active Sessions, Inactive Sessions, System Sessions)

  • DBSize/DBFileSize (DBSize size of database really used space and of Filesize)

四、Orabbix的安裝配置

    其實orabbix只需要安裝在一臺服務器即可,我就選擇安裝在Zabbix Server上,當然上面的jdk是爲orabbix服務的,因爲orabbix就是一個oracle客戶端去查找oracle中的數據,然後傳給zabbix。

    關於JDK的安裝可以參加我其他的博文,安裝非常簡單,這裏不再進行介紹。

1、下載Orabbix

    建議使用我修改好的軟件,下載地址爲http://down.51cto.com/data/2337373

unzip Orabbix-1.2.3.zip
mv orabbix-1.2.3 /usr/local/orabbix

2、調整配置文件

cd /usr/local/orabbix
cp init.d/orabbix /etc/init.d/
chmod +x /etc/init.d/orabbix
chmod +x /usr/local/orabbix/run.sh

3、創建數據庫賬號

    首先我們需要在被監控的Oracle上面創建一個賬號,用於zabbix的數據獲取,在oracle的sqlplus裏面執行。

CREATE USER ZABBIX
IDENTIFIED BY "zabbix"
DEFAULT TABLESPACE SYSTEM
TEMPORARY TABLESPACE TEMP
PROFILE DEFAULT
ACCOUNT UNLOCK;

#2 Roles for ZABBIX

GRANT CONNECT TO ZABBIX;
GRANT RESOURCE TO ZABBIX;
ALTER USER ZABBIX DEFAULT ROLE ALL;

#5 System Privileges for ZABBIX

GRANT SELECT ANY TABLE TO ZABBIX;
GRANT CREATE SESSION TO ZABBIX;
GRANT SELECT ANY DICTIONARY TO ZABBIX;
GRANT UNLIMITED TABLESPACE TO ZABBIX;
GRANT SELECT ANY DICTIONARY TO ZABBIX;

    如果我們的數據庫是Oracle 11g,我們還需要執行下面的語句。

exec dbms_network_acl_admin.create_acl(acl => 'resolve.xml',description => 'resolve acl', principal =>'ZABBIX', is_grant => true, privilege => 'resolve');
exec dbms_network_acl_admin.assign_acl(acl => 'resolve.xml', host =>'*');
commit;

4、配置config.props

    config.props是Orabbix的配置文件,路徑爲/usr/local/orabbix/conf。

cp config.props.sample config.props

    打開配置文件,修改後內容如下:

#comma separed list of Zabbix servers
ZabbixServerList=ZabbixServer1

ZabbixServer1.Address=10.0.0.14
ZabbixServer1.Port=10051

#pidFile
OrabbixDaemon.PidFile=./logs/orabbix.pid
#frequency of item's refresh
OrabbixDaemon.Sleep=300
#MaxThreadNumber should be >= than the number of your databases
OrabbixDaemon.MaxThreadNumber=100

#put here your databases in a comma separated list
DatabaseList=10.0.2.64,10.0.2.63

#Configuration of Connection pool
#if not specified Orabbis is going to use default values (hardcoded)
#Maximum number of active connection inside pool
DatabaseList.MaxActive=10
#The maximum number of milliseconds that the pool will wait 
#(when there are no available connections) for a connection to be returned 
#before throwing an exception, or <= 0 to wait indefinitely. 
DatabaseList.MaxWait=100
DatabaseList.MaxIdle=1

#define here your connection string for each database
10.0.2.64.Url=jdbc:oracle:thin:@10.0.2.64:1521:unicode
10.0.2.64.User=zabbix
10.0.2.64.Password=zabbix
#Those values are optionals if not specified Orabbix is going to use the general values
10.0.2.64.MaxActive=10
10.0.2.64.MaxWait=100
10.0.2.64.MaxIdle=1
10.0.2.64.QueryListFile=./conf/query.props

#define here your connection string for each database
10.0.2.63.Url=jdbc:oracle:thin:@10.0.2.63:1521:orcl
10.0.2.63.User=zabbix
10.0.2.63.Password=zabbix
#Those values are optionals if not specified Orabbix is going to use the general values
10.0.2.63.MaxActive=10
10.0.2.63.MaxWait=100
10.0.2.63.MaxIdle=1
10.0.2.63.QueryListFile=./conf/query.props

    備註:

  • ZabbixServerList:可以設置多個,用","進行分割;

  • DatabaseList:可以設置多個被監控的Oracle數據庫服務器,用","進行分割,該名稱要和zabbix server界面中的Host name保持一致,該配置文件中後續所引用的設定都以該名稱爲準。

五、啓動Orabbix服務

service orabbix start

wKioL1nMa1rRRsIhAACc7O2eGn4532.jpg

六、配置Zabbix添加監控

1、導入模板

    模板在軟件包的template目錄下面,全部導入即可,因爲Orabbix版本很老舊了,導入新版的Zabbix可能會出現問題,請大家下載我附件修改好的模板使用。

wKiom1nMbLbDMm_qAABvHhb0I_4279.jpg

   Configuration-->Templates-->Import

wKiom1nMbD-R8w6XAABvWYkEtMs677.jpg

2、Oracle主機添加監控模板

wKiom1nMbYCwuMQJAADc59lL6qg847.jpg


wKioL1nMbUGjIYP4AACqd0nKy2Y676.jpg

七、驗證

wKiom1nMbi_AThgSAAFa5wQf_yg297.jpg


wKioL1nMbfDRsXg-AADSx4hn-gk292.jpg


wKiom1nMbjDhi08gAAEB_dBzObQ023.jpg


wKioL1nMbfCCykisAAC4HyyXAcw013.jpg




參考文檔:http://www.smartmarmot.com/wiki/index.php?title=Orabbix



                             wKioL1nMbieQV2ANAACmb4CVfN4478.jpg

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章