[20191119]探究ipcs命令輸出.txt

来源:https://www.cnblogs.com/lfree/archive/2019/11/19/11888256.html
-Advertisement-
Play Games

[20191119]探究ipcs命令輸出.txt$ man ipcsIPCS(8) Linux Programmer's Manual IPCS(8)NAME ipcs - provide information on ipc facilitiesSYNOPSIS ipcs [ -asmq ] [ ...


[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的相關輸出.


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 前兩篇介紹了Spark的yarn client和yarn cluster模式,本篇繼續介紹Spark的STANDALONE模式和Local模式。 下麵具體還是用計算PI的程式來說明,examples中該程式有三個版本,分別採用Scala、Python和Java語言編寫。本次用Java程式JavaSp ...
  • 最近遇到一些腳本誘發的審計相關BUG,感覺有必要重新梳理一下11g與12c的審計模式,於是根據官網修正了一下以前的一篇筆記這裡發出來。 一、審計功能的開啟: audit_trail參數的值可以設置為以下幾種(11G,12C適用): https://docs.oracle.com/cd/E11882_ ...
  • flink 中自身雖然實現了大量的connectors,如下圖所示,也實現了jdbc的connector,可以通過jdbc 去操作資料庫,但是flink-jdbc包中對資料庫的操作是以ROW來操作並且對資料庫事務的控制比較死板,有時候操作關係型資料庫我們會非常懷念在java web應用開發中的非常優 ...
  • 需求:有一個活動記錄表 t_ad ,商家每次發起一個活動,就會在 t_shake_devices_relation 表裡面生成一些關聯記錄。現在寫一個存儲過程實現,如果活動過期,就將關聯表裡面的數據標記刪除。 1、代碼如下: BEGIN /* 用途:每天23:00執行一次,處理“開屏廣告”和“門店主 ...
  • [20191119]探究ipcs命令輸出2.txt--//繼續上午的測試:http://blog.itpub.net/267265/viewspace-2664758/=>[20191119]探究ipcs命令輸出.txt--//先補充ipcs 剩餘2個參數 -l -u--//-l limits--/ ...
  • 前言: 關聯規則是數據挖掘中最活躍的研究方法之一, 是指搜索業務系統中的所有細節或事務,找出所有能把一 組事件或數據項與另一組事件或數據項聯繫起來的規則,以獲 得存在於資料庫中的不為人知的或不能確定的信息,它側重於確 定數據中不同領域之間的聯繫,也是在無指導學習系統中挖掘本地模式的最普通形式。 一般 ...
  • 思考:一般我們的數據都是存儲在資料庫裡面,對於常規的CRUD操作都是用代碼實現,比如使用PHP做項目,所有的數據處理都需要主動操作代碼實現。如果我們現在有一項目,業務需要在用戶下單後,對用戶的訂單進行分潤處理,比如在每個月的21號,對上個月所有的訂單按設置的規則進行分潤處理,當然shll腳本也可以實 ...
  • 下載: 1.下載地址:https://www.mysql.com/downloads/ 2.選擇社區版:MySQL Community (GPL) Downloads » 3.MySQL Community Server 4.選擇版本 Looking for previous GA versions ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...