[20191119]探究ipcs命令输出.txt
[20191119]探究ipcs命令输出.txt
$ man ipcs
IPCS(8) Linux Programmer"s Manual IPCS(8)
NAME
ipcs - provide information on ipc facilities
SYNOPSIS
ipcs [ -asmq ] [ -tclup ]
ipcs [ -smq ] -i id
ipcs -h
DESCRIPTION
ipcs provides information on the ipc facilities for which the calling process has read access.
The -i option allows a specific resource id to be specified. Only information on this id will be printed.
Resources may be specified as follows:
-m shared memory segments
-q message queues
-s semaphore arrays
-a all (this is the default)
The output format may be specified as follows:
-t time
-p pid
-c creator
-l limits
-u summary
--//ipcs主要用来显示shared memory segments(-m)以及semaphore arrays(-s)
--//好像message queues(-q)没有相关信息.由于oracle使用要使用shared memory segments,而且配置需求很大,一些发布版本要修改
--//参数文件/etc/sysctl.conf,满足应用需求.很少人具体了解一些内核参数具体含义,仅仅copy and paste来安装配置数据库,
--//而且现在的安装如果不满足条件,oracle会提示如何修改相关参数.自己根据学习做一些测试.千万不要在生产系统做这些测试!!
--//从网上转抄的:
set kernel parameters by adding the following lines in "/etc/sysctl.conf"
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
--//kernel.shmall * kernel.shmmni = 2097152*4096 = 8589934592
--//8589934592/1024/1024/1024 = 8G
shmmax-> This parameter represents the size in bytes of a single shared memory segment
shmmni-> This parameter represents total no.of shared memory segments system wide(4096 is most probably enough)
shmall-> We specify this parameter in pages. The SHMALL defines the largest amount of shared memory pages that can be
used at one time on the system.
kernel.sem -> This parameter is related to semaphores
e.g.,
kernel.sem = SEMMSL SEMMNS SEMOPM SEMMNI
where
semmsl: The number of semaphores per set
semmns: The total number of semaphores available
semopm: The number of operations which can be made per semaphore call
semmni: The maximum number of shared memory segments available in the system
--//主要学习了解如下参数,因为这些与ipcs命令输出有关.
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
--//为了测试方便,我建立了实例文件并没有数据文件.
$ cat /tmp/test.ora
test.__db_cache_size=1258291200
test.__oracle_base="/u01/app/oracle"#ORACLE_BASE set from environment
test.__shared_pool_size=1048576000
*.db_name="test"
*.processes=2596
*.sga_target=2500M
*.undo_management="auto"
--//注:test.__shared_pool_size=1G,test.__db_cache_size=1.2G.
--//内核相关参数配置如下:
# grep "^kernel.s[he]" /etc/sysctl.conf
##kernel.shmmax = 68719476736 -> 与下面重复了
kernel.shmall = 4294967296
kernel.shmmax = 19327352832
kernel.shmmni = 4096
kernel.sem = 2600 332800 2600 128
--//68719476736/1024/1024/1024 = 64G
--//4294967296/1024/1024/1024 = 4G
--//19327352832/1024/1024/1024 = 18G
--//注:你可以发现我配置kernel.shmmax重复,最后1个配置有效.
1.测试1:
--//首先关闭一些测试库,避免影响.修改环境变量ORACLE_SID=test.
$ export ORACLE_SID=test
$ ipcs
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
------ Semaphore Arrays --------
key semid owner perms nsems
------ Message Queues --------
key msqid owner perms used-bytes messages
SYS@test> startup nomount pfile="/tmp/@.ora";
ORACLE instance started.
Total System Global Area 2622255104 bytes
Fixed Size 2256112 bytes
Variable Size 1124074256 bytes
Database Buffers 1476395008 bytes
Redo Buffers 19529728 bytes
$ ipcs
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 401735681 oracle 640 33554432 18
0x00000000 401768450 oracle 640 167772160 18
0x00000000 401801219 oracle 640 16777216 18
0x00000000 401833989 oracle 640 2415919104 18
0x8a931fb8 401866758 oracle 640 2097152 18
------ Semaphore Arrays --------
key semid owner perms nsems
0xc13ea218 326893568 oracle 640 2600
------ Message Queues --------
key msqid owner perms used-bytes messages
--//你可以发现建立5个Shared Memory Segments.nattch表示进程连接数量.
--//实际上你看连接数量有多少,直接看ipcs 的nattch就很快.而不用执行下面命令.
# ps -ef | grep "tes[t]" |wc
18 145 1163
--//查看Semaphore Arrays.
$ ipcs -s
------ Semaphore Arrays --------
key semid owner perms nsems
0xc13ea218 326893568 oracle 640 2600
$ ipcs -s -i 326893568
Semaphore Array semid=326893568
uid=502 gid=502 cuid=502 cgid=502
mode=0640, access_perms=0640
nsems = 2600
otime = Tue Nov 19 09:26:22 2019
ctime = Tue Nov 19 09:26:22 2019
semnum value ncount zcount pid
0 0 0 0 52844
1 2559 0 0 52844
2 19574 0 0 52844
3 1 0 0 52844
4 0 0 0 0
5 0 0 0 0
6 0 0 0 0
7 0 1 0 52849
8 0 0 0 0
9 0 1 0 52855
10 0 1 0 0
11 0 1 0 0
12 0 1 0 0
13 0 1 0 52863
14 0 1 0 0
15 0 1 0 0
16 0 1 0 0
17 0 1 0 0
18 0 1 0 52873
19 0 1 0 0
20 0 1 0 0
21 0 1 0 52879
22 0 1 0 0
23 0 0 0 0
24 0 0 0 52885
25 0 0 0 52887
...--//截断.
2590 0 0 0 0
2591 0 0 0 0
2592 0 0 0 0
2593 0 0 0 0
2594 0 0 0 0
2595 0 0 0 0
2596 0 0 0 0
2597 0 0 0 0
2598 0 0 0 0
2599 0 0 0 52844
--//查看sem可以发现nsems=2600,实际上我数据库参数文件中定义*.processes=2596,多出4个与参数kernel.sem = 2600 332800 2600 128 的SEMMSL.
--//kernel.sem = SEMMSL SEMMNS SEMOPM SEMMNI
--//semmsl: The number of semaphores per set ,你可以理解每一个进程有需要一个信号与共享内存段通讯.这个参数与oracle的processes有关.
$ ipcs -s -i 326893568 | awk "/semnum/,/^2599/" | awk "$5>0 {print $5}" | sort | uniq -c
5 52844
1 52849
1 52855
1 52863
1 52873
1 52879
1 52885
1 52887
1 pid
--//并没有18个进程与信号对应.而且并没有pid=52844进程.也许仅仅安装到nomount的缘故.
$ ps -fp 52844
UID PID PPID C STIME TTY TIME CMD
$ ps -eLf | grep "tes[t]" | sort -nk2
UID PID PPID LWP C NLWP STIME TTY TIME CMD
oracle 52847 1 52847 0 1 09:26 ? 00:00:00 ora_pmon_test
oracle 52849 1 52849 0 1 09:26 ? 00:00:00 ora_psp0_test
oracle 52851 1 52851 1 1 09:26 ? 00:00:19 ora_vktm_test
oracle 52855 1 52855 0 1 09:26 ? 00:00:00 ora_gen0_test
oracle 52857 1 52857 0 1 09:26 ? 00:00:00 ora_diag_test
oracle 52859 1 52859 0 1 09:26 ? 00:00:00 ora_dbrm_test
oracle 52861 1 52861 0 1 09:26 ? 00:00:05 ora_dia0_test
oracle 52863 1 52863 0 1 09:26 ? 00:00:00 ora_mman_test
oracle 52865 1 52865 0 1 09:26 ? 00:00:00 ora_dbw0_test
oracle 52867 1 52867 0 1 09:26 ? 00:00:00 ora_dbw1_test
oracle 52869 1 52869 0 1 09:26 ? 00:00:00 ora_dbw2_test
oracle 52871 1 52871 0 1 09:26 ? 00:00:00 ora_lgwr_test
oracle 52873 1 52873 0 1 09:26 ? 00:00:00 ora_ckpt_test
oracle 52875 1 52875 0 1 09:26 ? 00:00:00 ora_smon_test
oracle 52877 1 52877 0 1 09:26 ? 00:00:00 ora_reco_test
oracle 52879 1 52879 0 1 09:26 ? 00:00:00 ora_mmon_test
oracle 52881 1 52881 0 1 09:26 ? 00:00:01 ora_mmnl_test
oracle 52882 52843 52882 0 1 09:26 ? 00:00:00 oracletest (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
$ ipcs -m -p
------ Shared Memory Creator/Last-op --------
shmid owner cpid lpid
401735681 oracle 52844 52893
401768450 oracle 52844 52893
401801219 oracle 52844 52893
401833989 oracle 52844 52893
401866758 oracle 52844 52893
--//加入-p参数可以发现cpid(Creator)是52844.而lpid(Last-op)是52893(这个进程也不存在)
--//如果看ps -eLF最后一行PPID=52843,也就是建立Shared Memory Segments的进程已经消失.
--//启动一个新连接看看.
SYS@test> @ spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
---------- ---------- ------- ------------------ ------ ------- ---------- --------------------------------------------------
3281 3 53194 DEDICATED 53195 20 2 alter system kill session "3281,3" immediate;
SYS@test> select sysdate from dual ;
SYSDATE
-------------------
2019-11-19 09:59:51
$ ipcs -m -p
------ Shared Memory Creator/Last-op --------
shmid owner cpid lpid
401735681 oracle 52844 53195
401768450 oracle 52844 53195
401801219 oracle 52844 53195
401833989 oracle 52844 53195
401866758 oracle 52844 53195
--//SPID=53195,这次可以对上,估计在nomount阶段,一些进程完成某些操作已经退出.
$ ipcs
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 401735681 oracle 640 33554432 19
0x00000000 401768450 oracle 640 167772160 19
0x00000000 401801219 oracle 640 16777216 19
0x00000000 401833989 oracle 640 2415919104 19
0x8a931fb8 401866758 oracle 640 2097152 19
------ Semaphore Arrays --------
key semid owner perms nsems
0xc13ea218 326893568 oracle 640 2600
------ Message Queues --------
key msqid owner perms used-bytes messages
--//nattch=19,增加1个链接.
--//另外还有一个参数-t,可以显示时间.
$ ipcs -t
------ Shared Memory Attach/Detach/Change Times --------
shmid owner attached detached changed
401735681 oracle Nov 19 09:55:49 Nov 19 09:27:47 Nov 19 09:26:11
401768450 oracle Nov 19 09:55:49 Nov 19 09:27:47 Nov 19 09:26:11
401801219 oracle Nov 19 09:55:49 Nov 19 09:27:47 Nov 19 09:26:11
401833989 oracle Nov 19 09:55:49 Nov 19 09:27:47 Nov 19 09:26:11
401866758 oracle Nov 19 09:55:49 Nov 19 09:55:49 Nov 19 09:26:11
------ Semaphore Operation/Change Times --------
semid owner last-op last-changed
326893568 oracle Tue Nov 19 09:26:22 2019 Tue Nov 19 09:26:22 2019
------ Message Queues Send/Recv/Change Times --------
msqid owner send recv change
--//你可以从这些时间判断是否存在活动.
2.测试2:
--//我前面定义kernel.shmmax = 19327352832 等于18G,如果定义很小会什么问题呢?
--//假如定义kernel.shmmax=100M,也就是100*1024*1024 = 104857600,实际上就建立许多Shared Memory Segments,实际使用不会有什么问题,
--//这也是为什么许多文档设置该参数为机器物理内存的1半的缘故.
--//当然最好避免建立许多Shared Memory Segments.相互通讯应该有开销,还有就是Attach/Detach需要一点点时间(也就是影响登录与退出)
# grep "^kernel.s[he]" /etc/sysctl.conf
kernel.shmall = 4294967296
kernel.shmmax = 104857600
kernel.shmmni = 4096
kernel.sem = 2600 332800 2600 128
# sysctl -p
--//重新启动实例到nomount看看.
$ ps -ef | grep sqlplus | grep sysdb[a]
oracle 52843 52842 0 09:26 pts/10 00:00:00 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/sqlplus as sysdba
--//使用strace跟踪pid=52843.
$ strace -f -p 52843 -e ipc -o /tmp/52843.txt
SYS@test> startup nomount pfile="/tmp/@.ora";
ORACLE instance started.
Total System Global Area 2622255104 bytes
Fixed Size 2256112 bytes
Variable Size 1124074256 bytes
Database Buffers 1476395008 bytes
Redo Buffers 19529728 bytes
$ strace -f -p 52843 -e ipc -o /tmp/52843.txt
Process 52843 attached - interrupt to quit
Process 53315 attached
Process 53316 attached
Process 53316 detached
Process 53317 attached
Process 53318 attached
Process 53317 detached
Process 53319 attached
Process 53320 attached
Process 53319 detached
Process 53321 attached
Process 53322 attached (waiting for parent)
Process 53322 resumed (parent 53321 ready)
Process 53321 detached
Process 53323 attached
Process 53322 suspended
Process 53324 attached (waiting for parent)
Process 53324 resumed (parent 53323 ready)
Process 53322 resumed
Process 53323 detached
Process 53324 detached
Process 53325 attached
Process 53326 attached (waiting for parent)
Process 53326 resumed (parent 53325 ready)
Process 53325 detached
Process 53327 attached (waiting for parent)
Process 53327 resumed (parent 53320 ready)
Process 53328 attached (waiting for parent)
Process 53328 resumed (parent 53327 ready)
Process 53327 detached
Process 53329 attached
Process 53330 attached
Process 53329 detached
Process 53331 attached
Process 53332 attached
Process 53331 detached
Process 53333 attached
Process 53334 attached
Process 53333 detached
Process 53335 attached
Process 53336 attached
Process 53335 detached
Process 53337 attached
Process 53338 attached
Process 53337 detached
Process 53339 attached
Process 53340 attached
Process 53339 detached
Process 53341 attached
Process 53342 attached
Process 53341 detached
Process 53343 attached
Process 53344 attached
Process 53343 detached
Process 53345 attached
Process 53346 attached (waiting for parent)
Process 53346 resumed (parent 53345 ready)
Process 53345 detached
Process 53347 attached
Process 53348 attached
Process 53347 detached
Process 53349 attached
Process 53350 attached
Process 53349 detached
Process 53351 attached
Process 53352 attached (waiting for parent)
Process 53352 resumed (parent 53351 ready)
Process 53351 detached
Process 53353 attached
Process 53315 detached
Process 53354 attached
Process 53355 attached
Process 53354 detached
Process 53356 attached
Process 53357 attached (waiting for parent)
Process 53357 resumed (parent 53356 ready)
Process 53356 detached
Process 53355 detached
Process 53357 detached
$ ipcs -a
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 401932289 oracle 640 33554432 18
0x00000000 401965058 oracle 640 100663296 18
0x00000000 401997827 oracle 640 50331648 18
0x00000000 402030597 oracle 640 33554432 18
0x00000000 402063366 oracle 640 100663296 18
0x00000000 402096135 oracle 640 100663296 18
0x00000000 402128904 oracle 640 100663296 18
0x00000000 402161673 oracle 640 100663296 18
0x00000000 402194442 oracle 640 100663296 18
0x00000000 402227211 oracle 640 100663296 18
0x00000000 402259980 oracle 640 100663296 18
0x00000000 402292749 oracle 640 100663296 18
0x00000000 402325518 oracle 640 100663296 18
0x00000000 402358287 oracle 640 100663296 18
0x00000000 402391056 oracle 640 100663296 18
0x00000000 402423825 oracle 640 100663296 18
0x00000000 402456594 oracle 640 100663296 18
0x00000000 402489363 oracle 640 100663296 18
0x00000000 402522132 oracle 640 100663296 18
0x00000000 402554901 oracle 640 100663296 18
0x00000000 402587670 oracle 640 100663296 18
0x00000000 402620439 oracle 640 100663296 18
0x00000000 402653208 oracle 640 100663296 18
0x00000000 402685977 oracle 640 100663296 18
0x00000000 402718746 oracle 640 100663296 18
0x00000000 402751515 oracle 640 100663296 18
0x00000000 402784284 oracle 640 100663296 18
0x00000000 402817053 oracle 640 100663296 18
0x8a931fb8 402849822 oracle 640 2097152 18
--//注意仅仅1个key有值0x8a931fb8.
------ Semaphore Arrays --------
key semid owner perms nsems
0xc13ea218 327057408 oracle 640 2600
------ Message Queues --------
key msqid owner perms used-bytes messages
$ ipcs -m -p
------ Shared Memory Creator/Last-op --------
shmid owner cpid lpid
401932289 oracle 53315 53357
401965058 oracle 53315 53357
401997827 oracle 53315 53357
402030597 oracle 53315 53357
402063366 oracle 53315 53357
402096135 oracle 53315 53357
402128904 oracle 53315 53357
402161673 oracle 53315 53357
402194442 oracle 53315 53357
402227211 oracle 53315 53357
402259980 oracle 53315 53357
402292749 oracle 53315 53357
402325518 oracle 53315 53357
402358287 oracle 53315 53357
402391056 oracle 53315 53357
402423825 oracle 53315 53357
402456594 oracle 53315 53357
402489363 oracle 53315 53357
402522132 oracle 53315 53357
402554901 oracle 53315 53357
402587670 oracle 53315 53357
402620439 oracle 53315 53357
402653208 oracle 53315 53357
402685977 oracle 53315 53357
402718746 oracle 53315 53357
402751515 oracle 53315 53357
402784284 oracle 53315 53357
402817053 oracle 53315 53357
402849822 oracle 53315 53357
--//共建立29个Shared Memory Segments.如果你看前面的strace,就可以发现cpid,lpid对应进程号.
$ ipcs -m -p | grep oracle|wc
29 116 1276
SYS@test> @ spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
---- ---------- ------- --------- ------ ------- ---------- --------------------------------------------------
3117 1 52843 DEDICATED 53353 19 1 alter system kill session "3117,1" immediate;
SYS@test> quit
$ grep 53353 /tmp/52843.txt | egrep "shmat|shmdt"
53353 shmat(402849822, 0, 0) = ?
53353 shmdt(0x7f9410123000) = 0
53353 shmat(402849822, 0xfd000000, 0) = ?
53353 shmat(401932289, 0x60000000, 0) = ?
53353 shmat(401965058, 0x62000000, 0) = ?
53353 shmat(401997827, 0x68000000, 0) = ?
53353 shmat(402030597, 0x6b000000, 0) = ?
53353 shmat(402063366, 0x6d000000, 0) = ?
53353 shmat(402096135, 0x73000000, 0) = ?
53353 shmat(402128904, 0x79000000, 0) = ?
53353 shmat(402161673, 0x7f000000, 0) = ?
53353 shmat(402194442, 0x85000000, 0) = ?
53353 shmat(402227211, 0x8b000000, 0) = ?
53353 shmat(402259980, 0x91000000, 0) = ?
53353 shmat(402292749, 0x97000000, 0) = ?
53353 shmat(402325518, 0x9d000000, 0) = ?
53353 shmat(402358287, 0xa3000000, 0) = ?
53353 shmat(402391056, 0xa9000000, 0) = ?
53353 shmat(402423825, 0xaf000000, 0) = ?
53353 shmat(402456594, 0xb5000000, 0) = ?
53353 shmat(402489363, 0xbb000000, 0) = ?
53353 shmat(402522132, 0xc1000000, 0) = ?
53353 shmat(402554901, 0xc7000000, 0) = ?
53353 shmat(402587670, 0xcd000000, 0) = ?
53353 shmat(402620439, 0xd3000000, 0) = ?
53353 shmat(402653208, 0xd9000000, 0) = ?
53353 shmat(402685977, 0xdf000000, 0) = ?
53353 shmat(402718746, 0xe5000000, 0) = ?
53353 shmat(402751515, 0xeb000000, 0) = ?
53353 shmat(402784284, 0xf1000000, 0) = ?
53353 shmat(402817053, 0xf7000000, 0) = ?
53353 shmdt(0x60000000) = 0
53353 shmdt(0x62000000) = 0
53353 shmdt(0x68000000) = 0
53353 shmdt(0x6b000000) = 0
53353 shmdt(0x6d000000) = 0
53353 shmdt(0x73000000) = 0
53353 shmdt(0x79000000) = 0
53353 shmdt(0x7f000000) = 0
53353 shmdt(0x85000000) = 0
53353 shmdt(0x8b000000) = 0
53353 shmdt(0x91000000) = 0
53353 shmdt(0x97000000) = 0
53353 shmdt(0x9d000000) = 0
53353 shmdt(0xa3000000) = 0
53353 shmdt(0xa9000000) = 0
53353 shmdt(0xaf000000) = 0
53353 shmdt(0xb5000000) = 0
53353 shmdt(0xbb000000) = 0
53353 shmdt(0xc1000000) = 0
53353 shmdt(0xc7000000) = 0
53353 shmdt(0xcd000000) = 0
53353 shmdt(0xd3000000) = 0
53353 shmdt(0xd9000000) = 0
53353 shmdt(0xdf000000) = 0
53353 shmdt(0xe5000000) = 0
53353 shmdt(0xeb000000) = 0
53353 shmdt(0xf1000000) = 0
53353 shmdt(0xf7000000) = 0
53353 shmdt(0xfd000000) = 0
--//你可以1个连接要调用shmat attach共享内存段29次,而退出连接一个使用shmdt函数29次.总之尽量避免设置kernel.shmmax过小.
3.测试3:
shmmni-> This parameter represents total no.of shared memory segments system wide(4096 is most probably enough)
--//此参数表示系统范围内共享内存段的总数(4096很可能足够),我以前使用它与shmall相乘完全是理解错误.因为它正好定义是4096.
--//先测试修改kernel.shmmni = 28看看.
# grep "^kernel.s[he]" /etc/sysctl.conf
kernel.shmall = 4294967296
kernel.shmmax = 104857600
kernel.shmmni = 28
kernel.sem = 2600 332800 2600 128
# sysctl -p
SYS@test> startup nomount pfile="/tmp/@.ora";
ORA-27102: out of memory
Linux-x86_64 Error: 28: No space left on device
Additional information: 100663296
Additional information: 1
--//增加3个看看.注我测试时忽略1个问题,已经存在2个shared memory segments.使用root用户就可以发现,oracle用户看不到如下信息.
# ipcs
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x740202db 2523136 root 600 4 0
0x00000000 348422148 gdm 600 393216 2 dest
------ Semaphore Arrays --------
key semid owner perms nsems
------ Message Queues --------
key msqid owner perms used-bytes messages
# grep "^kernel.s[he]" /etc/sysctl.conf
kernel.shmall = 4294967296
kernel.shmmax = 104857600
kernel.shmmni = 31
kernel.sem = 2600 332800 2600 128
# sysctl -p
SYS@test> startup nomount pfile="/tmp/@.ora";
ORACLE instance started.
Total System Global Area 2622255104 bytes
Fixed Size 2256112 bytes
Variable Size 1124074256 bytes
Database Buffers 1476395008 bytes
Redo Buffers 19529728 bytes
--//OK.这样就可以很准确验证自己的判断.
4.测试4:
--//kernel.shmall 参数.
shmall-> We specify this parameter in pages. The SHMALL defines the largest amount of shared memory pages that can be
used at one time on the system.
--//这个定义最大shared memory pages数量.每页4096.也就是shmall*4096表示当前服务器最大共享内存段大小.
# grep "^kernel.s[he]" /etc/sysctl.conf
kernel.shmall = 4294967296
kernel.shmmax = 19327352832
kernel.shmmni = 4096
kernel.sem = 2600 332800 2600 128
--//我的定义超大,实际上以前对参数不理解.kernel.shmall = 4294967296
--//4294967296*4096/1024/1024/1024 = 16384G.
--//实际上这个参数表示总的sga使用量,也许还要大一些.
--//我当前数据库定义
*.sga_target=2500M
--//假设定义2400*1024*1024/4096 = 614400,相当于2400M.
# grep "^kernel.s[he]" /etc/sysctl.conf
kernel.shmall = 614400
kernel.shmmax = 19327352832
kernel.shmmni = 4096
kernel.sem = 2600 332800 2600 128
# sysctl -p
SYS@test> startup nomount pfile="/tmp/@.ora";
ORA-27102: out of memory
Linux-x86_64 Error: 28: No space left on device
Additional information: -1879048192
Additional information: 1
--//如果修改如下:2600*1024*1024/4096 = 665600
# grep "^kernel.s[he]" /etc/sysctl.conf
kernel.shmall = 665600
kernel.shmmax = 19327352832
kernel.shmmni = 4096
kernel.sem = 2600 332800 2600 128
# sysctl -p
SYS@test> startup nomount pfile="/tmp/@.ora";
ORACLE instance started.
Total System Global Area 2622255104 bytes
Fixed Size 2256112 bytes
Variable Size 1124074256 bytes
Database Buffers 1476395008 bytes
Redo Buffers 19529728 bytes
--//OK启动正常.
# ipcs -m| grep "^0x" | awk "{print $5/4096}"
0.000976562
8192
40960
4096
96
589824
512
# ipcs -m| grep "^0x" | awk "{print $5/4096}"| paste -sd+| bc -l
643680.000976562
--//也就是我定义643681可以启动数据库,小于643681无法启动数据库.
# grep "^kernel.s[he]" /etc/sysctl.conf
kernel.shmall = 643681
kernel.shmmax = 19327352832
kernel.shmmni = 4096
kernel.sem = 2600 332800 2600 128
# sysctl -p
SYS@test> startup nomount pfile="/tmp/@.ora";
ORACLE instance started.
Total System Global Area 2622255104 bytes
Fixed Size 2256112 bytes
Variable Size 1124074256 bytes
Database Buffers 1476395008 bytes
Redo Buffers 19529728 bytes
--//OK可以启动数据库.
--//减少1个看看.
# grep "^kernel.s[he]" /etc/sysctl.conf
kernel.shmall = 643680
kernel.shmmax = 19327352832
kernel.shmmni = 4096
kernel.sem = 2600 332800 2600 128
# sysctl -p
SYS@test> startup nomount pfile="/tmp/@.ora";
ORA-27102: out of memory
Linux-x86_64 Error: 28: No space left on device
Additional information: 2097152
--//OK.验证自己的判断.
--//还原内核参数.
# grep "^kernel.s[he]" /etc/sysctl.conf
kernel.shmmax = 68719476736
kernel.shmall = 4294967296 -->不改小了.
kernel.shmmni = 4096
kernel.sem = 2600 332800 2600 128
# sysctl -p
5.sysrev命令
--//另外oracle提供1个sysresv 命令.
$ sysresv -h
sysresv: invalid option -- h
usage : sysresv [-if] [-d <on/off>] [-l sid1 <sid2> ...]
-i : Prompt before removing ipc resources for each sid
-f : Remove ipc resources silently, oevrrides -i option
-d <on/off> : List ipc resources for each sid if on
-l sid1 <sid2> .. : apply sysresv to each sid
Default : sysresv -d on -l $ORACLE_SID
Note : ipc resources will be attempted to be deleted for a
sid only if there is no currently running instance
with that sid.
$ sysresv -l test
IPC Resources for ORACLE_SID "test" :
Shared Memory:
ID KEY
406683649 0x00000000
406716418 0x00000000
406749187 0x00000000
406781957 0x00000000
406814726 0x8a931fb8
Semaphores:
ID KEY
327647232 0xc13ea218
Oracle Instance alive for sid "test"
--//才发现sysresv命令-f参数可以Remove ipc resources.而且这个命令相对安全.
$ sysresv -f -l test
IPC Resources for ORACLE_SID "test" :
Shared Memory:
ID KEY
406683649 0x00000000
406716418 0x00000000
406749187 0x00000000
406781957 0x00000000
406814726 0x8a931fb8
Semaphores:
ID KEY
327647232 0xc13ea218
Oracle Instance alive for sid "test"
SYSRESV-005: Warning
Instance maybe alive - aborting remove for sid "test"
--//监测alive,移除ipc失败.
$ sysresv -if -l test
IPC Resources for ORACLE_SID "test" :
Shared Memory:
ID KEY
406683649 0x00000000
406716418 0x00000000
406749187 0x00000000
406781957 0x00000000
406814726 0x8a931fb8
Semaphores:
ID KEY
327647232 0xc13ea218
Oracle Instance alive for sid "test"
SYSRESV-005: Warning
Instance maybe alive - aborting remove for sid "test"
总结:
--//剩下kernel.sem = SEMMSL SEMMNS SEMOPM SEMMNI没写,下一篇了.再次摘抄前面内容:
shmmax-> This parameter represents the size in bytes of a single shared memory segment
shmmni-> This parameter represents total no.of shared memory segments system wide(4096 is most probably enough)
shmall-> We specify this parameter in pages. The SHMALL defines the largest amount of shared memory pages that can be
used at one time on the system.
--//我自己仅仅希望这些测试很好理解这些参数的具体含义以及ipcs的相关输出.
以上是 [20191119]探究ipcs命令输出.txt 的全部内容, 来源链接: utcz.com/z/531433.html