Oracle安装 - shmmax和shmall设置
Python微信訂餐小程序課程視頻
https://edu.csdn.net/course/detail/36074
Python實(shí)戰(zhàn)量化交易理財(cái)系統(tǒng)
https://edu.csdn.net/course/detail/35475
一、概述
在Linux上安裝oracle,需要對(duì)內(nèi)核參數(shù)進(jìn)行調(diào)整,其中有shmmax和shmall這兩個(gè)參數(shù),那這兩個(gè)參數(shù)是什么意思,又該如何設(shè)置呢?
二、官方文檔
在oracle的官方文檔( https://docs.oracle.com/en/database/oracle/oracle-database/19/ladbi/minimum-parameter-settings-for-installation.html#GUID-CDEB89D1-4D48-41D9-9AC2-6AD9B0E944E3 )中對(duì)這兩個(gè)參數(shù),設(shè)置了最小的標(biāo)準(zhǔn)值。
shmall - Greater than or equal to the value of shmmax, in pages.
shmmax - Half the size of physical memory in bytes. See My Oracle Support Note 567506.1 for additional information about configuring shmmax.
再根據(jù)redhat的官方文檔( https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/performance_tuning_guide/sect-red_hat_enterprise_linux-performance_tuning_guide-configuration_tools-configuring_system_memory_capacity ),去查這兩個(gè)參數(shù)所表達(dá)的含義。
shmall - Defines the total amount of shared memory pages that can be used on the system at one time. A page is 4096 bytes on the AMD64 and Intel 64 architecture, for example.
shmmax - Defines the maximum size (in bytes) of a single shared memory segment allowed by the kernel.
以上兩段英文翻譯過來:shmmax單個(gè)最大共享內(nèi)存段,shmall同一時(shí)刻能使用的所有共享內(nèi)存頁。shmmax最小一半的物理內(nèi)存,shmall >= shmmax/4096。
oracle的sga(Shared Global Area)使用的就是共享內(nèi)存,共享內(nèi)存的優(yōu)勢redhat官方文檔( https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/tuning_and_optimizing_red_hat_enterprise_linux_for_oracle_9i_and_10g_databases/chap-oracle_9i_and_10g_tuning_guide-setting_shared_memory#sect-Oracle_9i_and_10g_Tuning_Guide-Setting_Shared_Memory-Setting_SHMMAX_Parameter_ )中也有提及。直白點(diǎn)說就是多進(jìn)程使用共享內(nèi)存交流數(shù)據(jù)最快。例如:服務(wù)器進(jìn)程從磁盤讀取數(shù)據(jù)到sga的buffer cache,dbwn進(jìn)程從buffer cache將數(shù)據(jù)寫回到磁盤,操作的是同一片內(nèi)存區(qū)域。如果沒有共享內(nèi)存,那么就需要將服務(wù)器進(jìn)程操作的這片內(nèi)存復(fù)制一份到dbwn所操作的內(nèi)存中去,來完成讀取和寫入操作。
Shared memory allows processes to access common structures and data by placing them in shared memory segments. It is the fastest form of inter-process communication available since no kernel involvement occurs when data is passed between the processes. In fact, data does not need to be copied between the processes.
Oracle uses shared memory segments for the Shared Global Area (SGA) which is an area of memory that is shared by Oracle processes. The size of the SGA has a significant impact to Oracle’s performance since it holds database buffer cache and much more.
從上面的官方文檔我們了解了這兩個(gè)參數(shù)的含義,但是oracle只給了shmmax和shmall的最小值。接下來我們就通過實(shí)驗(yàn)來看看這兩個(gè)參數(shù)對(duì)oracle的影響。
三、實(shí)驗(yàn)
我的實(shí)驗(yàn)機(jī)器物理內(nèi)存是1877M,設(shè)置SGA_TAEGET為1000M。接下來測試幾個(gè)場景。
a. shmmax 200M, shmall 200M
將/etc/sysctl.conf參數(shù)設(shè)置為
kernel.shmmax = 209715200
kernel.shmall = 51200
oracle啟動(dòng)直接報(bào)錯(cuò)
SQL> startup nomount pfile='/home/oracle/test.ora' ORA-27102: out of memory Linux-x86\_64 Error: 28: No space left on device Additional information: 209715200 Additional information: 1b. shmmax 1200M, shmall 200M
將/etc/sysctl.conf參數(shù)設(shè)置為
kernel.shmmax = 1258291200
kernel.shmall = 51200
oracle啟動(dòng)報(bào)跟上面一樣的錯(cuò)
SQL> startup nomount pfile='/home/oracle/test.ora' ORA-27102: out of memory Linux-x86\_64 Error: 28: No space left on device Additional information: 1035993088 Additional information: 1從a和b的實(shí)驗(yàn)結(jié)果來看,oracle是否能夠正常啟動(dòng)跟shmmax參數(shù)無關(guān),只與shmall有關(guān)。shmall不能設(shè)置的比SGA_TAEGET小。
c. shmmax 200M, shmall 1200M
將/etc/sysctl.conf參數(shù)設(shè)置為
kernel.shmmax = 209715200
kernel.shmall = 307200
數(shù)據(jù)庫能夠正常啟動(dòng)
SQL> startup nomount pfile='/home/oracle/test.ora' ORACLE instance started.Total System Global Area 1043886080 bytes Fixed Size 2259840 bytes Variable Size 327156864 bytes Database Buffers 708837376 bytes Redo Buffers 5632000 bytes查看共享內(nèi)存的信息
[root@oracletest ~]# ipcs -m------ Shared Memory Segments -------- key shmid owner perms bytes nattch status 0x00000000 229376 oracle 640 12582912 18 0x00000000 262145 oracle 640 209715200 18 0x00000000 294914 oracle 640 209715200 18 0x00000000 327683 oracle 640 209715200 18 0x00000000 360452 oracle 640 209715200 18 0x00000000 393221 oracle 640 197132288 18 0x276f5044 425990 oracle 640 2097152 18把上面的共享內(nèi)存段bytes全部加起來(12582912+209715200…+2097152)/1024/1024=1002MB。可以看到oracle分配內(nèi)存段的時(shí)候,單個(gè)共享內(nèi)存段的確沒有超過shmmax(209715200)。總的共享內(nèi)存剛好等于SGA_TAEGET。
d. shmmax 1200M, shmall 1200M
將/etc/sysctl.conf參數(shù)設(shè)置為
kernel.shmmax = 1258291200
kernel.shmall = 307200
數(shù)據(jù)庫同樣能夠正常啟動(dòng)
SQL> startup nomount pfile='/home/oracle/test.ora' ORACLE instance started.Total System Global Area 1043886080 bytes Fixed Size 2259840 bytes Variable Size 327156864 bytes Database Buffers 708837376 bytes Redo Buffers 5632000 bytes查看共享內(nèi)存的信息
[root@oracletest ~]# ipcs -m------ Shared Memory Segments -------- key shmid owner perms bytes nattch status 0x00000000 557056 oracle 640 12582912 18 0x00000000 589825 oracle 640 1035993088 18 0x276f5044 622594 oracle 640 2097152 18把上面的共享內(nèi)存段bytes全部加起來(12582912+1035993088+2097152)/1024/1024=1002MB。總的共享內(nèi)存仍然剛好等于SGA_TAEGET。內(nèi)存段的數(shù)量卻只有三個(gè),最大的內(nèi)存段達(dá)到1035993088/1024/1024=988M
f. shmmax 2400M, shmall 2400M
將/etc/sysctl.conf參數(shù)設(shè)置為
kernel.shmmax = 2516582400
kernel.shmall = 614400
可以看到f跟e沒啥區(qū)別,shmmax這個(gè)值你就算設(shè)置超過了物理內(nèi)存也不受影響。因?yàn)閛racle實(shí)際上分配的共享內(nèi)存不會(huì)超過SGA_TAEGET。
四、總結(jié)
++本人水平有限,特別是對(duì)于共享內(nèi)存這塊,我仍然有很多疑問,比如共享內(nèi)存能否被交換出去?多個(gè)共享內(nèi)存段有什么缺點(diǎn)?暫時(shí)就先記錄到這里,后面了解之后,再來更新此文。如果有專家看到文章錯(cuò)誤,還望指正。++
總結(jié)
以上是生活随笔為你收集整理的Oracle安装 - shmmax和shmall设置的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Hbase Java API详解
- 下一篇: 使用HTML+CSS设计个人简历