oracle: unrecognized service,nagios插件之check_oracle_health

-------by shine

环境:

Oracle server: RHEL5U4

Oracle client: ubuntu 10.4 32bit

1、server端安装好后建了个库:orcl03

2、安装oracle cient

1、Oracle 为 Ubuntu 用户设立了专门的 apt 源服务器,只需要在 /etc/apt/source.list 中添加一行:

deb

http://oss.oracle.com/debian unstable main

non-free

即可。在运行 apt-get update 命令之前,还需要将该源服务器的公钥添加在本地 apt 系统的密钥库中。

首先下载公钥:

wget

http://oss.oracle.com/el4/RPM-GPG-KEY-oracle

下载完成之后添加该公钥到密钥库中:

sudo apt-key

add RPM-GPG-KEY-oracle

再执行

sudo apt-get

update

同步软件包索引文件。

我们可以从这个源上下载安装 Oracle 10g Express

Edition。可以选择的软件包有:

oracle-xe -

Oracle Database 10g Express Western European

Edition

oracle-xe-client - Oracle Client 10g Express

Edition

oracle-xe-universal - Oracle Database 10g Express Universal

Edition

因为我的开发工作只需要在本地安装一个用于连接 Oracle 服务器的客户端,所以我选择安装的是 oralce-xe-client 这个软件包。

sudo apt-get

install oracle-xe-client

2.设置oracle的环境变量.ORACLE_HOME LD_LIBARAY_PATH

.我的设置如下:.bashrc文件里面添加如下.

export

ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/client

export TNS_ADMIN=/usr/lib/oracle

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH

export

PATH=$PATH:$ORACLE_HOME/bin应用新的环境变量。source .bashrc

3、使方才设置的环境变量即刻在当前终端中生效。切换到 /usr/lib/oracle 目录中,建立 tnsnames.ora 文件,用于配置 Oracle 服务器的连接信息。

配置TNS

sudo vi /usr/lib/oracle/tnsnames.ora添加连接内容,例如ORCL03 =

(DESCRIPTION =

(ADDRESS = (PROTOCOL =

TCP)(HOST = 192.168.42.199)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = orcl03)

)

)

所有工作完成之后,就可以在本地连接 Oracle 服务器进行开发工作了。

3、check_oracle_health的安装和使用

check_oracle_health是nagios的一个oracle数据库状态检测插件,使用perl编写,因此需要事先安装perl连接oracle数据的组件。

check_oracle_health

要使用check_oracle_health,先要设置设置perl访问oracle

从下

载DBI并编译安装#wget #tar -zxvf DBI-1.609.tar.gz

#cd DBI-1.609

#perl Makefile.PL

#make all #make install从下

载DBD-Oracle

#wget http://cpan.wenzk.com/authors/id/P/PY/PYTHIAN/DBD-Oracle-1.24a.tar.gz

#tar -zxvf DBD-Oracle-1.24a.tar.gz

#cd DBD-Oracle-1.24

#perl Makefile.PL

#make all

#make

install

有资料说,以上两个工具在make all时报错cc1: invalid option

`tune=pentium4'

解决方法是

# vi

Makefile 去掉

-mtune=pentium4

就可以make过了

但我安装的时候没有碰到这个问题,只是DBD-Oracle安装前要设置ORACLE_HOME的环境变量,如:F:\oracle\product\10.2.0\db_2。

下载check_oracle_health-1.6.4.tar.gz,解压,

./configure

--prefix=/usr/local/nagios --with-nagios-user=nagiosadmin

--with-nagios-group=nagios

--with-mymodules-dir=/usr/local/nagios/libexec

--with-mymodules-dyn-dir=/usr/local/nagios/libexec

还可以有以下参数设置,现在没有明确设置,则会采用默认设置:

--with-perl:

/usr/bin/perl

--with-statefiles-dir:

/var/tmp/check_oracle_health

--with-nagios-user: nagiosadmin

--with-nagios-group: nagios

--with-mymodules-dir: /usr/local/nagios/libexec

--with-mymodules-dyn-dir:

/usr/local/nagios/libexec

make

all

make

install

make的时候,出现如下错误

cc1: error:

unrecognized command line option "-fstack-protector"

原因如下:

This error is

due to older version of GCC in your system.

The stack

protector was introduced as of GCC 4. Look the version in your

system by running gcc -v.

Update your

system if you are using cygwin run setup.exe and from the package

list check GCC4

try

reinstalling the PERL module.

如上,安装gcc4以后,重新configure 和 make,安装成功。

cd

/usr/local/nagios/libexec/

./check_oracle_health

-h查看一下使用语法,如果出现了语法说明,则表示安装成功。

shine@shine-desktop:/usr/local/nagios/libexec$

./check_oracle_health --connect=ORCL03 --username=system

--password=oracle --mode=invalid-objects

OK - no invalid objects found | invalid_ind_partitions=0

invalid_indexes=0 invalid_objects=0

~~~由于对oracle不了解。此插件耗掉我两天的时间。oracle好复杂。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值