有半年时间没怎么碰过oracle了,突然开发人员让我把一个oracle 11g的sga设置的稍微大一点。于是按照之前对oracle 10g的记忆操作。
[oracle@localhost db_1]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on 星期六 6月 30 13:42:07 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> conn /as sysdba
已连接。
SQL> show parameter sga;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
lock_sga boolean FALSE
pre_page_sga boolean FALSE
sga_max_size big integer 4800M
sga_target big integer 0
SQL> create pfile='/tmp/pfile.ora' from spfile;
文件已创建。
SQL> host
[oracle@localhost db_1]$ cd /tmp
[oracle@localhost tmp]$ ls
mapping-root pfile.ora scim-panel-socket:0-root
[oracle@localhost tmp]$ mor pfile.ora
bash: mor: command not found
[oracle@localhost tmp]$ more pfile.ora
intopay.__db_cache_size=1610612736
intopay.__java_pool_size=67108864
intopay.__large_pool_size=67108864
intopay.__oracle_base='/u01'#ORACLE_BASE set from environment
intopay.__pga_aggregate_target=2013265920
intopay.__sga_target=3019898880
intopay.__shared_io_pool_size=0
intopay.__shared_pool_size=1207959552
intopay.__streams_pool_size=0
*.audit_file_dest='/u01/admin/intopay/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/oradata/intopay/control01.ctl','/u01/flash_recovery_area/intopay/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='intopay'
*.db_recovery_file_dest='/u01/flash_recovery_area'
*.db_recovery_file_dest_size=10737418240
*.diagnostic_dest='/u01'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=intopayXDB)'
*.memory_target=5033164800
*.nls_language='SIMPLIFIED CHINESE'
*.nls_territory='CHINA'
*.open_cursors=300
*.processes=1500
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=1655
*.undo_tablespace='UNDOTBS1'
[oracle@localhost tmp]$ exit
exit
SQL> shutdown immediate
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup mount
ORACLE 例程已经启动。
Total System Global Area 5010685952 bytes
Fixed Size 2212936 bytes
Variable Size 3355446200 bytes
Database Buffers 1610612736 bytes
Redo Buffers 42414080 bytes
数据库装载完毕。
SQL> ALTER SYSTEM SET sga_max_size = 6442450944 COMMENT=’internally adjusted’ SCOPE=SPFILE SID=’INTOPAY′;
ALTER SYSTEM SET sga_max_size = 6442450944 COMMENT=’internally adjusted’ SCOPE=SPFILE SID=’INTOPAY′
*
第 1 行出现错误:
ORA-01756: 引号内的字符串没有正确结束
SQL> ALTER SYSTEM SET sga_max_size = 6442450944 COMMENT='internally adjusted’ SCOPE=SPFILE SID='INTOPAY′;
ALTER SYSTEM SET sga_max_size = 6442450944 COMMENT='internally adjusted’ SCOPE=SPFILE SID='INTOPAY′
*
第 1 行出现错误:
ORA-02095: 无法修改指定的初始化参数
SQL> alter system set sga_max_size=6442450944 scope=spfile ;
系统已更改。
SQL> show parameter sga;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
lock_sga boolean FALSE
pre_page_sga boolean FALSE
sga_max_size big integer 4800M
sga_target big integer 0
SQL> ALTER SYSTEM SET sga_target = 6442450944 SCOPE=SPFILE;
系统已更改。
SQL> shutdown immediate
ORA-01109: 数据库未打开
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup
ORA-00844: Parameter not taking MEMORY_TARGET into account
ORA-00851: SGA_MAX_SIZE 6442450944 cannot be set to more than MEMORY_TARGET 5033164800.
SQL> startup mount
ORA-00844: Parameter not taking MEMORY_TARGET into account
ORA-00851: SGA_MAX_SIZE 6442450944 cannot be set to more than MEMORY_TARGET 5033164800.
启动报错了,去网上查了查,才知道oracle 11g和之前的10g对sga的管理有了些变化。MEMORY_TARGET相当于sga_target + pga_aggregate_target的总和。
于是把备份的pfile文件中的memory_target扩大,sga_target也扩大,然后使用pfile文件启动
oracle@localhost db_1]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on 星期六 6月 30 14:00:23 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL> conn /as sysdba
已连接到空闲例程。
SQL> startup pfile='/tmp/pfile.ora';
ORA-00845: MEMORY_TARGET not supported on this system
SQL> startup
ORA-00844: Parameter not taking MEMORY_TARGET into account
ORA-00851: SGA_MAX_SIZE 6442450944 cannot be set to more than MEMORY_TARGET 5033164800.
SQL> startup pfile='/tmp/pfile.ora';
ORA-00845: MEMORY_TARGET not supported on this system
这个问题参照网上的文档解决的。
解决这个问题只有两个方法,一种是修改初始化参数,使得初始化参数中SGA的设置小于/dev/shm的大小,另一种方法就是调整/dev/shm的大小。
如果修改初始化参数的话,sga就不能达到我的目的了,只能直接/dev/shm的大小了。
原理shm使用的是安装系统时系统指定的大小,
[root@localhost tmp]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
257G 16G 228G 7% /
/dev/sda1 99M 13M 81M 14% /boot
tmpfs 5.9G 0 5.9G 0% /dev/shm
需要调整一下,设置到10G
[root@localhost tmp]# more /etc/fstab
/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults,size=10240M 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
然后把tmpfs卸载,重新挂载一下
[root@localhost tmp]# umount /dev/shm
[root@localhost tmp]# mount /dev/shm
[root@localhost tmp]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
257G 16G 228G 7% /
/dev/sda1 99M 13M 81M 14% /boot
tmpfs 10G 0 10G 0% /dev/shm
再启动数据库就正常了。
SQL> startup pfile='/tmp/pfile.ora';
ORACLE 例程已经启动。
Total System Global Area 8551575552 bytes
Fixed Size 2215064 bytes
Variable Size 4831839080 bytes
Database Buffers 3690987520 bytes
Redo Buffers 26533888 bytes
数据库装载完毕。
数据库已经打开。
SQL> show parameter sga;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
lock_sga boolean FALSE
pre_page_sga boolean FALSE
sga_max_size big integer 8G
sga_target big integer 0