[20221214]limits.conf裡面關於memlock設定問題.txt

lfree發表於2022-12-14

[20221214]limits.conf裡面關於memlock設定問題.txt

--//別人給我的反饋,就是無論設定/etc/security/limits.conf多小,資料庫一樣能起來不知道為什麼,做一個記錄.
--//OS的基本概念不熟悉.我自己也不知道問題在那裡.

1.建立測試環境:

# grep "^oracle" /etc/security/limits.conf  | grep memlock
oracle hard  memlock  0
oracle soft  memlock  0

$ egrep "Max locked memory|Limit" /proc/self/limits
Limit                     Soft Limit           Hard Limit           Units
Max locked memory         0                    0                    bytes

$ cd /u01/app/oracle/product/11.2.0.4/dbhome_1/dbs
--//建立引數檔案initxxxx.ora
$ cat initxxxx.ora
db_name=xxxx
instance_name=xxxx
sga_target=50G
sga_max_size=50G
shared_pool_size=2G
pre_page_sga=true

# grep "^vm.nr" /etc/sysctl.conf
vm.nr_hugepages = 26000
vm.nr_overcommit_hugepages = 1300

# sysctl -p
..
# sysctl vm.nr_hugepages
vm.nr_hugepages = 26000
--//vm.nr_hugepages設定生效.

2.測試:
--//啟動資料庫前:
# grep -i page /proc/meminfo
AnonPages:        217416 kB
PageTables:         6400 kB
AnonHugePages:     57344 kB
HugePages_Total:   26000
HugePages_Free:    26000
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB

$ export ORACLE_SID=xxxx
SYS@xxxx> startup nomount
ORACLE instance started.

Total System Global Area 5.3447E+10 bytes
Fixed Size                  2265864 bytes
Variable Size            5.3284E+10 bytes
Database Buffers          134217728 bytes
Redo Buffers               26480640 bytes
--//居然可以啟動.也就是我設定memlock=0的情況,資料依舊可以啟動.

$ grep -i pages /proc/meminfo
AnonPages:        281204 kB
AnonHugePages:     77824 kB
HugePages_Total:   26000
HugePages_Free:      473
HugePages_Rsvd:       74
HugePages_Surp:        0
Hugepagesize:       2048 kB

$ ps -ef |grep dbw[0]
oracle   36844     1  0 08:50 ?        00:00:00 ora_dbw0_xxxx

$ egrep "Max locked memory|Limit" /proc/36844/limits
Limit                     Soft Limit           Hard Limit           Units
Max locked memory         0                    0                    bytes
--//說明從bash shell繼承的memlock的設定.

--//找到一個連結:


Edit the memlock setting in the /etc/security/limits.conf file. The memlock setting is specified in KB, and the maximum
locked memory limit should be set to at least 90 percent of the current RAM when HugePages memory is enabled and at
least 3145728 KB (3 GB) when HugePages memory is disabled. For example, if you have 64 GB RAM installed, then add the
following entries to increase the maximum locked-in-memory address space:

--//翻譯如下:
編輯/etc/security/limits.conf檔案中的成員鎖設定。記憶體鎖設定在KB中指定,當HugePages記憶體被啟用時,最大鎖定記憶體限制應至少設
置為當前RAM的90%,當HugePages記憶體被禁用時,至少設定為3145728 KB(3 GB)。例如,如果您安裝了64 GB RAM,則新增以下條目以增加
最大鎖定記憶體地址空間:

*   soft   memlock    60397977
*   hard   memlock    60397977

--//60397977/1024 = 58982.3994140625
--//64*1024*1024*.9 = 60397977.6,與oracle建議值一致.

You can also set the memlock value higher than your SGA requirements.

Log in as oracle user again and run the ulimit -l command to verify the new memlock setting:

$ ulimit -l
60397977

--//不熟練linux OS的相關知識,也不知道問題在那裡,僅僅做一個記錄.我前一次遇到的情況可能是記憶體不足導致的情況.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2927977/,如需轉載,請註明出處,否則將追究法律責任。

相關文章