利用USE_INDIRECT_DATA_BUFFERS突破32位的2G記憶體限制(一)

yangtingkun發表於2009-10-12

對於絕大部分32位系統上的32位資料庫,記憶體最大的設定都不能超過2G,有的系統最大值甚至不能超過1.7G左右。

不過有的系統可以利用USE_INDIRECT_DATA_BUFFERS引數來突破這個限制。

這篇文章介紹如何設定這個引數。

 

 

當前的作業系統是Rethat Enterprise Linux 4 32位:

[oracle@zjyy ~]$ uname -a
Linux zjyy 2.6.9-42.ELsmp #1 SMP Wed Jul 12 23:27:17 EDT 2006 i686 i686 i386 GNU/Linux
[oracle@zjyy ~]$ more /etc/issue
Red Hat Enterprise Linux AS release 4 (Nahant Update 4)
Kernel \r on an \m

而安裝的資料庫是32位的Oracle10.2.0.1

[oracle@zjyy ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Sep 23 10:24:29 2009

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE    10.2.0.1.0      Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

透過設定USE_INDIRECT_DATA_BUFFERS引數,可以使得SGA超過3G的大小:

SQL> show sga

Total System Global Area 3288334336 bytes
Fixed Size                  1217836 bytes
Variable Size             322439892 bytes
Database Buffers         2949120000 bytes
Redo Buffers               15556608 bytes
SQL> show parameter use_indirect_data_buffers

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
use_indirect_data_buffers            boolean     TRUE

使用這個引數並不是簡單的將其置為TRUE就可以了,如果只是修改引數並重啟資料庫,會碰到各種的錯誤。下一篇文章中會專門介紹在使用這個引數的時候碰到的錯誤。

[oracle@zjyy bdump]$ su -
Password:
[root@zjyy ~]# umount /dev/shm
[root@zjyy ~]# mount -t ramfs ramfs /dev/shm
[root@zjyy ~]# chown oracle:oinstall /dev/shm
[root@zjyy ~]# vi /etc/rc.local

#!/bin/sh
#
# This script. will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style. init stuff.

touch /var/lock/subsys/local
umount /dev/shm
mount -t ramfs ramfs /dev/shm
chown oracle:oinstall /dev/shm
~
"/etc/rc.local" 10L, 298C written                                                                                
[root@zjyy ~]# reboot

Broadcast message from root (pts/4) (Wed Sep 23 07:52:56 2009):

The system is going down for reboot NOW!

首先切換到root使用者,執行umount /dev/shm操作,然後執行mount –t ramfs ramfs /dev/shm命令,並給Oracle使用者授權。

為了確保這個操作可以在系統重啟後生效,修改/etc/rc.local,將上面的命令新增進去,然後重啟系統。

檢查系統的配置:

[root@zjyy ~]# mount | grep shm
ramfs on /dev/shm type ramfs (rw)
[root@zjyy ~]# ls -ld /dev/shm
drwxr-xr-x  2 oracle oinstall 0 Sep 23 07:55 /dev/shm

下面修改系統配置,在/etc/security/limits.conf檔案,新增Oracle使用者所允許的記憶體限制:

*               soft     memlock   3145728
*               hard     memlock   3145728

修改/etc/init.d/sshd檔案,在指令碼中的start部分,新增ulimit –l命令:

start()
{
        # Create keys if necessary
        do_rsa1_keygen
        do_rsa_keygen
        do_dsa_keygen

        ulimit -l
        echo -n $"Starting $prog:"
        initlog -c "$SSHD $OPTIONS" && success || failure
        RETVAL=$?
        [ "$RETVAL" = 0 ] && touch /var/lock/subsys/sshd
        echo
}

下面修改/etc/ssh/sshd_config檔案,在檔案的最後新增下面的配置:

UseLogin yes

在作業系統級的設定完成,下面切換到Oracle使用者檢查設定是否生效:

[root@zjyy ~]# su - oracle
[oracle@zjyy ~]$ ulimit -l
3145728

如果Oracle使用者執行ulimit –l的結果不是前面設定的3145728,那麼說明前面的設定有問題,需要根據上面的步驟重新設定。

下面設定正確的Oracle資料庫初始化引數,就可以啟動資料庫了:

SQL> host vi initcis.ora

*.audit_file_dest='/data/ora10g/admin/cis/adump'
*.background_dump_dest='/data/ora10g/admin/cis/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/webdata/oracle/oradata/cis/control01.ctl','/webdata/oracle/oradata/cis/control02.ctl','/webdata/oracle/oradata/cis/control03.ctl'
*.core_dump_dest='/data/ora10g/admin/cis/cdump'
*.db_block_size=16384
#*.db_cache_size=2202009600
db_block_buffers=180000
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='cis'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=cisXDB)'
*.java_pool_size=0
*.job_queue_processes=10
*.large_pool_size=0
*.open_cursors=300
*.pga_aggregate_target=1048576000
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_max_size=0
*.sga_target=0
*.shared_pool_size=314572800
*.streams_pool_size=0
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/data/ora10g/admin/cis/udump'
use_indirect_data_buffers=true
~
~
"initcis.ora" 27L, 902C written

SQL> startup pfile=initcis.ora
ORACLE instance started.

Total System Global Area 3288334336 bytes
Fixed Size                  1217836 bytes
Variable Size             322439892 bytes
Database Buffers         2949120000 bytes
Redo Buffers               15556608 bytes
Database mounted.
Database opened.

需要注意,使用USE_INDIRECT_DATA_BUFFERS引數,不能在使用其他9i以後新增的記憶體控制引數了,比如SGA_TARGETDB_CACHE_SIZE等等,必須透過DB_BLOCK_BUFFERS引數來指定記憶體的容量。

SQL> show parameter db_block 

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_block_buffers                     integer     180000
db_block_checking                    string      FALSE
db_block_checksum                    string      TRUE
db_block_size                        integer     16384
SQL> select 180000*16384 from dual;

180000*16384
------------
  2949120000

SQL> show parameter sga

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
lock_sga                             boolean     FALSE
pre_page_sga                         boolean     FALSE
sga_max_size                         big integer 3136M
sga_target                           big integer 0
SQL> show parameter db_cache_size

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_cache_size                        big integer 0

而對於沒有使用這個引數的情況,將SGA設定到2.5G,也就是DB_CACHE_SIZE的大小超過1.7G,則Oracle啟動報錯:

SQL> startup
ORACLE instance started.

Total System Global Area 2214592512 bytes
Fixed Size                  1220532 bytes
Variable Size             486539340 bytes
Database Buffers         1711276032 bytes
Redo Buffers               15556608 bytes
Database mounted.
Database opened.
SQL> show parameter use_ind

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
use_indirect_data_buffers            boolean     FALSE
SQL> alter system set sga_target = 2500m scope = spfile;

System altered.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORA-27102: out of memory
Linux Error: 12: Cannot allocate memory
Additional information: 1
Additional information: 884739

 

 

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

相關文章