在zabbix下面使用ODBC 监控oracle数据库(11.2.0.3)和mysql数据库
1,监控mysql数据库
1)安装ODBC
yum -y install unixODBC unixODBC-devel
yum install mysql-connector-odbc
2)odbcinst -j 查看配置文件
unixODBC 2.2.14
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
3)编辑/etc/odbcinst.ini
[mysql]
Description = ODBC for MySQL
Driver = /usr/lib/libmyodbc5.so
Setup = /usr/lib/libodbcmyS.so
Driver64 = /usr/lib64/libmyodbc5.so
Setup64 = /usr/lib64/libodbcmyS.so
FileUsage = 1
4)编辑
vi /etc/odbc.ini
[test]
Description = MySQL test database
Driver = mysql
Server = 127.0.0.1
User = root
Password = 123456
Port = 3306
Database = zabbix
5)测试
shell> isql test
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>
可以正常监控
2,使用ODBC监控oracle数据库
1)下载oracle客户端
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm
oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm
oracle-instantclient11.2-odbc-11.2.0.3.0-1.x86_64.rpm
oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm
2)安装
rpm -ivh oracle-instantclient11.2-*
3)创建本地监控
安装的默认位置分别在/usr/share/oracle/11.2/client64
/usr/include/oracle/11.2/client64
/usr/lib/oracle/11.2/client64
设置环境变量之前,在/usr/lib/oracle/11.2/client64下创建network/admin文件夹,
mkdir -p /usr/lib/oracle/11.2/client64/network/admin
在此文件夹下创建tnsnames.ora,其内容入下:
571WB=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.23.153.9)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = sss)
)
)
571WW=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.23.163.10)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = sss)
)
)
在/usr/lib/oracle/11.2/client64/network/admin文件下创建sqlnet.ora,输入:
vi sqlnet.ora
NAME_DIRECTORY_PATH=(TNSNAMES,EZCONNECT)
4)
export ORACLE_HOME=/usr/lib/oracle/11.2/client64
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib64:$LD_LIBRARY_PATH
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
5)
And at once we do such check:
# ldd /usr/lib/oracle/11.2/client64/lib/libsqora.so.11.1
With big share probability, you receive libodbcinst.so.1 => not found, therefore it is necessary to make this - link:
# ls -lah /lib64 | grep odbc
cd /usr/lib64/
ln -s libodbcinst.so.2.0.0 libodbcinst.so.1
vi /etc/odbcinst.ini 创建驱动
[oracle]
Description = Oracle ODBC driver for Oracle 11g
Driver = /usr/lib/oracle/11.2/client64/lib/libsqora.so.11.1
vi /etc/odbc.ini 创建数据源
[571WB]
Driver= oracle
DSN= 571WB
ServerName= 571WB
UserID= sss
Password= hangzhou571wb
在zabbix下面使用ODBC 监控oracle数据库(11.2.0.3)和mysql数据库
原文地址:http://11542796.blog.51cto.com/11532796/1827927