4.2.1 ONS配置内容
在RAC环境中,需要使用$CRS_HOME下的ONS,而不是$ORACLE_HOME下的ONS。
[root@rac2 conf]# pwd
/u01/app/oracle/product/10.2.0/db_1/opmn/conf
[root@rac2 conf]# more ons.config
localport=6113
remoteport=6200
loglevel=3
useocr=on
参数:
localport:这个参数代表本地监听端口,这里本地值:127.0.0.1这个回环地址,用来和运行在本地的客户端进行通信。
remoteport:这个参数代表的是远程监听端口,也就是除了127.0.0.1以外的所有本地IP地址,用来和远程的客户端进行通信。
loglevel:ORACLE允许跟踪ONS进程的运行,并把日志记录到本地文件中,这个参数用来定义ONS进程要记录的日志级别,从1-9,缺省值是3.
logfile:这个参数和Loglevel参数一起使用,用于定义ONS进程日志文件的位置,缺省值是$CRS_HOME/opmn/logs/opmn.log.
nodes和userocr:这两个参数共同决定了本地ONS DAEMON要和哪些远程节点上的ONS daemon进行通信。
nodes参数值格式如下:Hostname/IP:port[hostname/ip:port]
如:useoce=off
Nodes=rac1:6200,rac2:6200
而useocr 参数值为on/off, 如果useocr 是ON, 说明信息保存在OCR中,如果是OFF,说明信息取nodes中的配置。对于单实例而言,要把useocr设置为off。
4.2.2 配置ONS
可以直接编译ONS的配置文件来修改配置,如果使用了OCR,则可以通过racgons命令进行配置,但必须以root用户来执行,如果用oracle 用户来执行,不会提示任何错误,但也不会更改任何配置。
[root@rac2 bin]# ./racgons
To add ONS daemons configuration:
./racgons.bin add_config hostname:port [hostname:port] ...
To remove ONS daemons configuration:
./racgons.bin remove_config hostname[:port] [hostname:port] ...
若要添加配置,可以使用下面命令:
Racgons add_config rac1:6200 rac2:6200
若要删除配置,可以用下面命令:
Racgons remove_config rac1:6200 rac2:6200
4.2.3 onsctl命令
使用onsctl命令可以启动、停止、调试ONS,并重新载入配置文件,其命令格式如下:
[root@rac2 bin]# ./onsctl
usage: ./onsctl start|stop|ping|reconfig|debug
start - Start opmn only.
stop - Stop ons daemon
ping - Test to see if ons daemon is running
debug - Display debug information for the ons daemon
reconfig - Reload the ons configuration
help - Print a short syntax description (this).
detailed - Print a verbose syntax description.
ONS进程运行,并不一定代表ONS正常工作,需要使用ping命令来确认。
[root@rac2 bin]# ps -ef |grep ons
root 7505 20858 0 15:09 pts/5 00:00:00 grep ons
oracle 10184 1 0 13:28 00:00:00 /u01/app/oracle/product/10.2.0/db_2/perl/bin/perl /u01/app/oracle/product/10.2.0/db_2/bin/emwd.pl dbconsole /u01/app/oracle/product/10.2.0/db_2/rac2_RACDB2/sysman/log/emdb.nohup
oracle 26106 1 0 13:57 00:00:00 /u01/app/oracle/product/10.2.0/db_1/opmn/bin/ons -d
oracle 26107 26106 0 13:57 00:00:00 /u01/app/oracle/product/10.2.0/db_1/opmn/bin/ons -d
b.确认ONS服务的状态
[root@rac2 bin]# ./onsctl ping
Number of onsconfiguration retrieved, numcfg = 2
onscfg[0]
{node = rac1, port = 6200}
Adding remote host rac1:6200
onscfg[1]
{node = rac2, port = 6200}
Adding remote host rac2:6200
ons is running ...
c.启动、停止ONS
[root@rac2 bin]# ./onsctl start
[root@rac2 bin]# ./onsctl stop
d.使用debug选项,可以查看详细信息,其中最有意义的就是能显示所有连接。
[root@rac2 bin]# ./onsctl debug
Number of onsconfiguration retrieved, numcfg = 2
onscfg[0]
{node = rac1, port = 6200}
Adding remote host rac1:6200
onscfg[1]
{node = rac2, port = 6200}
Adding remote host rac2:6200
HTTP/1.1 200 OK
Content-Length: 1361
Content-Type: text/ html
Response:
======== ONS ========
Listeners:
NAME BIND ADDRESS PORT FLAGS SOCKET
------- --------------- ----- -------- ------
Local 127.000.000.001 6113 00000142 7
Remote 192.168.090.005 6200 00000101 8
Request No listener
Server connections:
ID IP PORT FLAGS SENDQ WORKER BUS