2009年4月29日星期三

用UNIX的kill命令来终止Oracle的过程

正如你所知,有时候我们有必要终止所有的Oracle过程(process)或者指定的一组Oracle过程。当数据库“锁定”而你无法进入Server Manager来“温柔”的终止数据库时,就可以用UNIX中的kill命令来终止所有的Oracle过程——这是kill命令的常见用途之一。
当你需要终止一个UNIX服务器上的一个Oracle实例(instance)时,执行下面的步骤:
1、 终止与ORACLE_SID有关的所有Oracle过程。
2、用ipcs –pmb命令来识别所有占用的RAM内存片断。
3、用ipcrm -m 命令来从UNIX中释放占用的RAM内存。
(针对Non-AIX:用ipcs -sa命令来显示占用标记,用ipcrm –s命令来释放该实例的占用标记。)
创建单一命令来终止与挂起(hung)的数据库实例有关的Oracle过程是很简单的。在下面的例子之中,我们用ps指令来识别Oracle过程,然后用 awk程序来获取Oracle过程的过程ID(process ID,PID)。然后,我们把过程ID输入到UNIX的kill命令之中。

root> ps -efgrep ora_ \
grep -v grepawk '{print $2}'xargs -i kill -9 {}

在终止所有Oracle过程之后,我们可以用ipcs –pmb指令来检查占用的内存并清除数据库所占用的内存。我们首先显示出数据库服务器上所有占用内存:

root> ipcs -pmb
IPC status from /dev/kmem as of Mon Sep 10 16:45:16 2001
T ID KEY MODE OWNER GROUP SEGSZ CPID LPID
Shared Memory:
m 24064 0x4cb0be18 --rw-r----- oracle dba 28975104 1836 23847
m 1 0x4e040002 --rw-rw-rw- root root 31008 572 572
m 2 0x411ca945 --rw-rw-rw- root root 8192 572 584
m 4611 0x0c6629c9 --rw-r----- root root 7216716 1346 23981
m 4 0x06347849 --rw-rw-rw- root root 77384 1346 1361

在这里,我们看到Oracle只拥有一个ID=24064的RAM内存。下面的命令将会释放这个内存片断:
root> ipcrm -m 24064

2008年7月13日星期日

I'm Back.

不知道怎么想起来要打开自己的blog看看,因为以前blogspot.com这个地址一直是封的,没有想到现在解封了,意外,之所以打开自己的blog看看,想想还是那个技术梦在作怪吧,现在看来是越来越难完成我的技术之路的梦想。
看到blog,就想到了当初创建这个博客的那段时光,时间真快。
最近经历了很多事,人成熟了些,想想生活最重要的是什么,结论是一家人在一起,快乐的生活,这是最重要的。
在这里祝我自己好运,明天是个新的开始。

2007年3月31日星期六

win2003下oracle 9.2.0.8 用dbca建库时出现ora-29807错误

很少在windows下部署oracle的生产库,今天在win2003下oracle 9.2.0.8 用dbca建库时出现ora-29807错误记得这个bug很早就出现过,没有想到在9.2.0.8下还没有修正,特地又去metalink上查了一下,解决方法如下,记录在此备忘:

Problem
~~~~~~~

While using Database Creation Assistant (DBCA) to create a database (custom or template) after patchset 9.2.0.2.0 or 9.2.0.3.0 has been applied, ORA-29807 'specified operator does not exist' is encountered during 'create data dictionary views.'

It has been determined that this error is being raised while DBCA is running the script prvtxml.plb.

Prvtxml.plb is a script which creates a particular package body. This script is called from the catxml.sql script - which in turn is called by the catproc.sql script - run automatically when creating a database using DBCA.

Workaround
~~~~~~~~~~
This workaround can be implemented either before invoking the DBCA or after the ORA-29807 has been encountered.

1. Go to the script catxml.sql and comment out the line which will run prvtxml.plb
2a. If the script has been edited before invoking DBCA, it is now safe to proceed with invoking DBCA

OR

2b. If the script has been edited after the ORA-29807 is encountered, go back to your DBCA screen and click 'Ignore'

3. The database creation using DBCA should now proceed without additional errors.

4. Once DBCA has completed database creation, remember to run the 'prvtxml.plb' script independently, as the user SYS.

5. Check whether there are invalid objects:select * from dba_objects where owner = 'SYS' and status = 'INVALID' ;If so, run the 'utlrp.sql' script to validate those objects.

2007年1月28日星期日

解决winxp(sp2)下因防火墙导致的oracle客户端无法连接数据库问题的方法

解决步骤如下:
1、在winxp的防火墙上打开1521端口(默认的监听端口,如果你更改了listener的默认监听端口,打开相应的端口即可);
2、在系统环境变量中设置 USE_SHARED_SOCKET = TRUE 或者 设置到注册表中以下位置
HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOME<#> (Release 8i or higher)

(利用了Winsock 2的端口共享特性)

以上设置需要重起机器;另外,这样设置后停止listener不会中断已有的session,但是重起的时候会强制断开已有的session。

原话:The listener can be stopped without interupting the connected sessions, but itcannot be restarted without forcibly disconnecting connected sessions first.


更进一步的信息可以参考metalink:124140.1