1. 程式人生 > >orabbix監控oracle

orabbix監控oracle

product src 全部 exceptio rip sid ted 系統啟動 trigger

Orabbix 是一個用來監控 Oracle 數據庫實例的 Zabbix 插件。下載地址:

http://www.smartmarmot.com/product/orabbix/download/

Orabbix插件的安裝與配置

確保安裝jdk環境,java version查看,沒有則通過yum來安裝JAVA:yum install java

1.在/opt目錄下新建一個orabbix目錄:

[[email protected] orabbix]#midir -p /opt/orabbix

(建議在此目錄下,如果放置其他目錄稍後需要更改orabbix的啟動文件orabbix,啟動文件默認寫在opt/orabbix目錄下 )

2. 解壓安裝文件

[[email protected] orabbix]#unzip orabbix-1.2.3.zip

3.賦予權限

[[email protected] orabbix]# chmod -R a+x orabbix/

4 通過/opt/orabbix/conf/config.props.sample文件創建一個config.props文件:

[[email protected] orabbix]#cp/opt/orabbix/conf/config.props.sample /opt/orabbix/conf/config.props

5. 編輯orabbix配置文件,具體如下

[[email protected] orabbix]#vi confi/config.props

#comma separed list of Zabbix servers
#ZabbixServerList=ZabbixServer1,ZabbixServer2
ZabbixServerList=ZabbixServer1  
#(zabbixserver的名字,下行中address和port都引用到了這個名字,所以下面兩行的前綴名字要與這裏的名字保持一致)
#ZabbixServer1.Address=IP_ADDRESS_OF_ZABBIX_SERVER
ZabbixServer1.Address=192.168.3.163
#ZabbixServer1.Port=PORT_OF_ZABBIX_SERVER ZabbixServer1.Port=10051 #ZabbixServer2.Address=IP_ADDRESS_OF_ZABBIX_SERVER #ZabbixServer2.Port=PORT_OF_ZABBIX_SERVER #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=DB1,DB2,DB3 DatabaseList=DB_QM (DB名稱,可隨意定義,但要與下文保持一致,切記要與監控的主機名稱保持一致) #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 #DB1.Url=jdbc:oracle:thin:@server.domain.example.com:<LISTENER_PORT>:DB1 DB_QM.Url=jdbc:oracle:thin:@192.168.3.250:1521:qmeas #確保有jdk環境,因為這裏是通過JDBC連接的 #DB1.User=zabbix DB_QM.User=qm #DB1.Password=zabbix_password DB_QM.Password=qm #DB的用戶和密碼,可創建zabbix用戶,並賦予權限,如下文(這裏直接用dba權限用戶) #Those values are optionals if not specified Orabbix is going to use the general values DB_QM.MaxActive=10 DB_QM.MaxWait=100 DB_QM.MaxIdle=1 DB_QM.QueryListFile=./conf/query.props #DB2.Url=jdbc:oracle:thin:@server2.domain.example.com:<LISTENER_PORT>:DB2 #DB2.User=zabbix #DB2.Password=zabbix_password #DB2.QueryListFile=./conf/query.props #DB3.Url=jdbc:oracle:thin:@server3.domain.example.com:<LISTENER_PORT>:DB3 #DB3.User=zabbix #DB3.Password=zabbix_password #DB3.QueryListFile=./conf/query.props #註釋未用到的DB連接

創建zabbix用戶如下步驟:

CREATE USER ZABBIX

IDENTIFIEDBY zabbix <Password>

DEFAULTTABLESPACE SYSTEM

TEMPORARYTABLESPACE TEMP

PROFILEDEFAULT

ACCOUNTUNLOCK;

GRANT CONNECT TO ZABBIX;

GRANTRESOURCE TO ZABBIX;

ALTERUSER ZABBIX DEFAULT ROLE ALL;

GRANT SELECT ANY TABLE TO ZABBIX;

GRANT CREATE SESSION TO ZABBIX;

GRANTSELECT ANY DICTIONARY TO ZABBIX;

GRANTUNLIMITED TABLESPACE TO ZABBIX;

GRANTSELECT ANY DICTIONARY TO ZABBIX;。

Oracle 11g添加如下命令

execdbms_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;

6. 創建執行文件(直接cp即可)

[[email protected] orabbix]# cp /opt/orabbix/init.d/orabbix/etc/init.d/orabbix

7.保存退出,啟動orabbix服務(確保有執行權限)

/etc/init.d/orabbix start

Orabbix服務加入隨系統啟動:

chkconfig --add orabbix

chkconfig --level 345 orabbix on

常見問題:

若config.props文件未配置,或是配置了錯誤,無法通過配置的信息正確連進Oracle數據庫的,會出現以下錯誤信息

[[email protected] orabbix]# /etc/init.d/orabbix start

Starting Orabbix service:

[[email protected] orabbix]# Stopping

java.lang.Exception: ERROR on main - Connections is empty

atcom.smartmarmot.orabbix.Orabbixmon.run(Orabbixmon.java:101)

atcom.smartmarmot.orabbix.bootstrap.main(bootstrap.java:50)

可查看log信息判斷解決

[[email protected] orabbix]# tail -f /opt/orabbix/logs/orabbix.log

到此,安裝配置完成,則通過web頁面訪問直接導入模塊即可

導入模版,模版放置在/opt/orabbix/template下
Orabbix_export_full.xml 全部導入(圖表 監控項 觸發器)
Orabbix_export_graphs.xml 圖表
Orabbix_export_items.xml 監控項
Orabbix_export_triggers.xml 觸發器

選中Orabbix_export_full.xml直接導入,則可以直接在主機中鏈接到模版就可以使用全部功能了(主機名稱一定要與配置中的 DatabaseList=DB_QM保持一致)!

也可以再模版中找到此模版。然後將需要的信息直接cp過去,比如打開此處的監控項,把它全部復制到oracle主機下,觸發器、圖像顯示同理!

創建圖表,部分效果如下:

技術分享

orabbix監控oracle