Zabbix uses the Orabbix plug-in to monitor Oracle databases (enhanced version)

Source: Internet
Author: User

Zabbix uses the Orabbix plug-in to monitor Oracle databases (enhanced version)

According to some information on the Internet, the installation finally found many problems, so I fixed some problems and recorded them.

1. Install jdk (Orabbix Server)

1. decompress the software and place it in a fixed position.

Tar zxf jdk-8u51-linux-x64.tar.gz
Mv jdk1.8.0 _ 51 // usr/local/

2. Set system variables and add/etc/profile at the end.

Export JAVA_HOME =/usr/local/jdk1.8.0 _ 51
ExportCLASSPATH = $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar
Export PATH = $ JAVA_HOME/bin: $ PATH

3. Execute/etc/profile to make it take effect.

Source/etc/profile

2. Add monitoring users in Oracle and set corresponding user permissions. This step is completed in sqlplus (ORACLE Server)

Su-oracle
Sqlplus/as sysdba
SQL> CREATE USER zabbix
Identified by zabbix_password
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP
PROFILE DEFAULT
Account unlock;

Grant zabbix User Permissions

Grant alter session to zabbix;
Grant create session to zabbix;
Grant connect to zabbix;
Alter user zabbix default role all;
Grant select on v _ $ instance to zabbix;
Grant select on DBA_USERS to zabbix;
Grant select on v _ $ LOG_HISTORY to zabbix;
Grant select on v _ $ log to zabbix;
Grant select on v _ $ parameter to zabbix;
Grant select on sys. DBA_AUDIT_SESSION to zabbix;
Grant select on v _ $ lock to zabbix;
Grant select on DBA_REGISTRY to zabbix;
Grant select on v _ $ librarycache to zabbix;
Grant select on v _ $ sysstat to zabbix;
Grant select on v _ $ parameter to zabbix;
Grant select on v _ $ latch to zabbix;
Grant select on v _ $ pgastat to zabbix;
Grant select on v _ $ sgastat to zabbix;
Grant select on v _ $ librarycache to zabbix;
Grant select on v _ $ process to zabbix;
Grant select on DBA_DATA_FILES to zabbix;
Grant select on DBA_TEMP_FILES to zabbix;
Grant select on DBA_FREE_SPACE to zabbix;
Grant select on v _ $ SYSTEM_EVENT to zabbix;
Grant select on v _ $ locked_object to zabbix;
Grant select on dba_objects to zabbix;
Grant select on dba_tablespaces to zabbix;
Grant select on v _ $ session to zabbix;

I added some lower case letters to other articles.

If the database is 11 GB, perform the following steps:

1
2
3 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;

3. Install orabbix (Orabbix Server)

In fact, orabbix only needs to be installed on one Server. I chose to install it on Zabbix Server. Of course, the jdk above serves orabbix, because orabbix is an oracle client that searches for data in oracle and sends it to zabbix.

Mkdir/usr/local/orabbix
Cd/usr/local/orabbix
Wget orabbix http://nchc.dl.sourceforge.net/project/orabbix/orabbix-1.2.3.zip
Unzip orabbix-1.2.3.zip
Chmod + x run. sh
Cp init. d/orabbix/etc/init. d/
Sed-I's #/opt/orabbix # orabbix =/usr/local/orabbix # G'/etc/init. d/orabbix
Chmod + x/etc/init. d/orabbix
Sed-I's # java #/usr/local/jdk1.8.0 _ 51/bin/java # G'/usr/local/orabbix/run. sh
# Solve the/usr/local/orabbix/run. sh: line 2: java: command not found Error

Configure orabbix to go to the/usr/local/orabbix/conf/directory.

Cd/usr/local/orabbix/conf

Cp config. props. sample config. props

ZabbixServerList = ZabbixServer
ZabbixServer. Address = 192.168.0.81
ZabbixServer. Port = 10051
OrabbixDaemon. PidFile =./logs/orabbix. pid
OrabbixDaemon. Sleep = 300
Orabbian daemon. MaxThreadNumber = 100
DatabaseList = tpy100
DatabaseList. MaxActive = 10
Database List. MaxWait = 100
DatabaseList. MaxIdle = 1
Tpy100.Url = jdbc: oracle: thin: @ 192.168.0.209: 1521: orcl
Tpy100.User = ZABBIX
Tpy100.Password = zabbix
Tpy100.MaxActive = 10
Tpy100.MaxWait = 100
Tpy100.MaxIdle = 1
Tpy100.QueryListFile =./conf/query. props

Note that DatabaseList = CRMDB refers to the name of the monitored server, which must be consistent with the machine name on the zabbixserver interface, all subsequent settings referenced in this configuration file are subject to this name.
CRMDB. url = jdbc: oracle: thin: @ 192.168.0.209: 1521: orcl specifies the connection information of the monitored server (for example, in jdbc connection mode, the server address is 192.168.0.209, oracle port 1521, orcl refers to the database instance)

By default, the above steps are almost the same, but after you import the template, you will find that the monitoring items are incomplete, such as dbsize and dbfilesize categories. By default, orabbix does not enable the database size, query Needs to be configured. props

Edit the/usr/local/orabbix/conf/query. props File

Add dbfilesize, dbsize, and,

Add

Dbfilesize. Query = select to_char (sum (bytes/1024/1024/10), 'fm99999999999999990') retvalue from dba_data_files
 
Dbsize. query = SELECT to_char (sum (NVL (. bytes/1024/1024/10-NVL (f. bytes/1024/1024/10, 0), 0), 'fm999999999999990') retvalue \
FROM sys. dba_tablespaces d ,\
(Select tablespace_name, sum (bytes) bytes from dba_data_files group by tablespace_name) ,\
(Select tablespace_name, sum (bytes) bytes from dba_free_space group by tablespace_name) f \
WHERE d. tablespace_name = a. tablespace_name (+) AND d. tablespace_name = f. tablespace_name (+ )\
And not (d. extent_management like 'local' AND d. contents like 'temporary ')

SQL statement used to define the query of dbfilesize and dbsize

At this time, you can start the orabbix service.

Service orabbix start

Check the Service ps aux | grep orabbix | wc-l if it is equal to 2, it indicates that the startup is successful. If it is successful, it may not be okay. You need to check the log at this time.

/Usr/local/orabbix/logs/orabbix. log

From the above we can see that a lot of data cannot be captured, because the table cannot be found due to permission issues, so we need to use query. props

/Usr/local/orabbix/conf/query. props

Find the corresponding table, as shown in the following figure.

If you do not have the permission, you must use the DBA permission to access the database.

Grant select on v _ $ log to zabbix;

You can.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.