2008年11月20日星期四

数据库环境克隆

操作系统环境为
HP-UX BHGHIS01 B.11.11 U 9000/800 883605913 unlimited-user license
数据库环境为
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit

Production环境:
alter database begin backup;
host cp *.dbf ./back
host cp *.ctl ./back
host cp *.log ./back
alter database end backup;
这里主要是克隆数据文件,控制文件,以及重做日志.
另外,copy SPFILE文件以及密码文件.

将以上文件拷贝到克隆环境的对应目录下, 注意要先建好相应目录, 并设置好owner.
然后在新环境中:
startup mount;
alter database open resetlogs;

以上步骤也可以用来建立production环境的standby:
拷贝相关文件后
startup mount;
同步更新:
copy production的归档日志到克隆环境相应路径
recover database using backup controlfile until cancel;
然后应用相应归档
最后如果需要切换, 同样先应用完所有归档, 然后应用在线归档,最后
alter database resetlogs;
则standy环境与production环境数据已经完全同步了.

以上克隆仅针对production环境与clone环境路径完全一样, 如果不一样, 则需要使用PFILE文件,修改PFILE文件路径, 还需要手动重建控制文件.

2008年11月4日星期二

Oracle sessions,processes参数

ORACLE的连接数(sessions)与其参数文件中的进程数(process)有关,它们的关系如下:

sessions=(1.1*process+5)

但是我们增加process数时,往往数据库不能启动了。这因为我们还漏调了一个unix系统参数:它是/etc/proc/kernel 中semmns,这是unix系统的信号量参数。每个process会占用一个信号量。semmns调整后,需要重新启动unix操作系统,参数才能生 效。不过它的大小会受制于硬件的内存或ORACLE SGA。范围可从200——2000不等。

semmns的计算公式为: SEMMNS>processes+instance_processes+system

processes=数据库参数processes的值 instance_processes=5(smon,pmon,dbwr,lgwr,arch)

system=系统所占用信号量。系统所占用信号量可用下列命令查出:
#ipcs -s
其中列NSEMS显示系统已占用信号量。

背景:
One of the most common reasons for the TNS-12516 and/or TNS-12519 errors being reported is the configured maximum number of PROCESSES and/or SESSIONS limitation being reached. When this occurs, the service handlers for the TNS listener become "Blocked" and no new connections can be made. Once the TNS Listener receives an update from the PMON process associated with the Database instance telling the TNS Listener the thresholds are below the configured limit, and the database is now accepting connections connectivity resumes.

By way of instance registration, PMON is responsible for updating the listener with information about a particular instance such as load and dispatcher information. Maximum load for dedicated connections is determined by the PROCESSES parameter. The frequency at which PMON provides SERVICE_UPDATE information varies according to the workload of the instance. The maximum interval between these service updates is 10 minutes.

The listener counts the number of connections it has established to the instance but does not immediately get information about connections that have terminated. Only when PMON updates the listener via SERVICE_UPDATE is the listener informed of current load. Since this can take as long as 10 minutes, there can be a difference between the current instance load according to the listener and the actual instance load.

When the listener believes the current number of connections has reached maximum load, it may set the state of the service handler for an instance to "blocked" and begin refusing incoming client connections with either of the following errors: ora-12519 or ora-12516