[20130220]快速查看连接数据库的用户数量.txt
一般在linux查询连接数据库的用户数量,执行如下命令:
ps -ef | grep oracle$ORACLE_SID| grep -v grep |wc
--实际上以上的查询不包括后台的进程.
oracle 5782 1 0 2012 ? 00:35:29 ora_pmon_orcl1
oracle 5784 1 0 2012 ? 00:16:37 ora_diag_orcl1
oracle 5789 1 0 2012 ? 00:00:14 ora_psp0_orcl1
oracle 5796 1 0 2012 ? 00:46:06 ora_lmon_orcl1
oracle 5800 1 0 2012 ? 02:14:25 ora_lmd0_orcl1
oracle 5802 1 0 2012 ? 07:18:22 ora_lms0_orcl1
oracle 5806 1 0 2012 ? 06:23:08 ora_lms1_orcl1
oracle 5810 1 0 2012 ? 00:20:13 ora_mman_orcl1
oracle 5812 1 0 2012 ? 00:27:39 ora_dbw0_orcl1
oracle 5814 1 0 2012 ? 00:57:37 ora_lgwr_orcl1
oracle 5816 1 0 2012 ? 00:29:25 ora_ckpt_orcl1
oracle 5818 1 0 2012 ? 00:39:32 ora_smon_orcl1
oracle 5820 1 0 2012 ? 00:00:08 ora_reco_orcl1
oracle 5824 1 0 2012 ? 00:52:02 ora_cjq0_orcl1
oracle 5826 1 0 2012 ? 00:28:32 ora_mmon_orcl1
oracle 5830 1 0 2012 ? 00:21:58 ora_mmnl_orcl1
oracle 5846 1 0 2012 ? 01:01:32 ora_lck0_orcl1
oracle 5916 1 0 2012 ? 00:07:15 ora_arc0_orcl1
oracle 5920 1 0 2012 ? 00:01:33 ora_arc1_orcl1
oracle 6149 1 0 2012 ? 00:00:19 ora_qmnc_orcl1
实际上使用ipcs -m也可以获得连接的数量,只不过它包括后台的oracle用户:
对比如下:
$ ipcs -m ; ps -ef | grep $ORACLE_SID| grep -v grep|wc
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0xd47dfec8 0 oracle 660 2418016256 550
550 4920 39007
-- 可以发现nattch的数量与后面的查询一致.
$ ipcs -m ; ps -ef | grep oracle$ORACLE_SID| grep -v grep|wc
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0xd47dfec8 0 oracle 660 2418016256 545
515 4635 36760
--如果查询ps -ef | grep oracle$ORACLE_SID| grep -v grep|wc基本外面连接的用户.两者相差30.
--这样仅仅执行ipcs -m就可以估算连接用户的数量.