Lock_sga 和 pre_page_sga 参数详解

 

     Lock_sga 和pre_page_sga,是两个平时用的不算太多的参数,但是这两个参数平时在优化的时候可能给你带来比较乐观的性能提升,通过修改lock_sga和pre_pga_sga参数可以保证SGA不被换出到swap,进而而已提高SGA的使用效率。

当lock_sga参数的值修改设置为true的时候,可以保证整个sga被锁定在物理内存中,这样可以防止sga被换出到swap中;当然理当需要把pre_page_sga参数也设置为true,只有这样才能保证在数据库启动之初将整个sga读取到物理内存,而不走交换内存,从而有效的提高数据库效率,当然会增加数据库的启动时间。

调整过程如下:

1、 查看lock_sga和pre_page_sga参数的默认值:

SQL> show parameter lock_sga

NAME                                 TYPE        VALUE
------------------------------------ -----------------------------------------
lock_sga boolean FALSE
SQL> show parameter pre_page_sga NAME TYPE VALUE
------------------------------------ -----------------------------------------
pre_page_sga boolean FALSE

2、 修改这两个参数,因为其是静态参数,故在添加scop=spfile,记录到参数文件,下次启动生效:

SQL> alter system set lock_sga = truescope=spfile;

System altered.

Elapsed: 00:00:00.03
SQL> alter system set pre_page_sga = truescope=spfile; System altered. Elapsed: 00:00:00.02
SQL>

3、 重启数据库

SQL> startup

ORA-27102: out of memory

Linux-x86_64 Error: 12: Cannot allocate memory
SQL>

发现数据库现在起不来了,想想看,这是什么原因导致启动失败呢,其实很简单,Linux操作系统对每一个任务在内存中能锁住的值做了限制,只需手工修改即可。

4、 处理解决ora-27102及Linux-x86_64 Error:12问题:

[oracle@woo ~]$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 32768
max locked memory (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files (-n) 65536
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 16384
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

从上面信息我们可以看到,一个任务可以锁住的物理内存最大值为32KB,这个值根本没法满足我们sga的大小。那么我们需要对该值进行修改,使其适应及满足相关要求。

5、 修改有两种方法:

5.1、临时生效可以切换到root用户通过如下命令,进行修改:

[root@woo ~]# ulimit -l
32
[root@woo ~]# ulimit -l unlimited
[root@woo ~]# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 32768
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 32768
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

5.2 让其永久生效的方法:

[root@woo ~]# vi /etc/security/limits.conf   最底部添加如下两行
oracle soft memlock unlimited
oracle hard memlock unlimited

6、 修改系统限制成功后,启动数据库,可以正常Open,但是时间更长了。

SQL> startup
ORACLE instance started. Total System Global Area 6081740870 bytes
Fixed Size 1220844 bytes
Variable Size 197136148 bytes
Database Buffers 406847488 bytes
Redo Buffers 2969600 bytes
Database mounted.
Database opened.
SQL>

7、 参考:

关于locak_sgapre_page_sga 参数在ORACLE10gR2官方文档中的介绍:

LOCK_SGA

Property

Description

Parameter type

Boolean

Default value

false

Modifiable

No

Range of values

true | false

Basic

No

LOCK_SGAlocks the entire SGA into physical memory. It is usually advisable to lockthe SGA into real (physical) memory, especially if the use of virtual memorywould include storing some of the SGA using disk space. This parameter isignored on platforms that do not support it.

PRE_PAGE_SGA

Property

Description

Parameter type

Boolean

Default value

false

Modifiable

No

Range of values

true | false

PRE_PAGE_SGAdetermines whether Oracle reads the entire SGA into memory at instancestartup. Operating system page table entries are then prebuilt for each page ofthe SGA. This setting can increase the amount of time necessary for instancestartup, but it is likely to decrease the amount of time necessary for Oracleto reach its full performance capacity after startup.

Note:

This setting does not prevent your operating system from paging orswapping the SGA after it is initially read into memory.

PRE_PAGE_SGAcan increase the process startup duration, because every process thatstarts must access every page in the SGA. The cost of this strategy is fixed;however, you might simply determine that 20,000 pages must be touched everytime a process starts. This approach can be useful with some applications, butnot with all applications. Overhead can be significant if your systemfrequently creates and destroys processes by, for example, continually loggingon and logging off.

The advantage thatPRE_PAGE_SGAcan afford depends on page size. For example, if the SGA is 80 MB in sizeand the page size is 4 KB, then 20,000 pages must be touched to refresh the SGA(80,000/4 = 20,000).

If the system permits you to set a 4 MB page size, then only 20 pages mustbe touched to refresh the SGA (80,000/4,000 = 20). The page size is operatingsystem-specific and generally cannot be changed. Some operating systems,however, have a special implementation for shared memory whereby you can changethe page size.

关于Metalink对于该介绍,参考如下地址:

http://space.itpub.net/?uid-20674423-action-viewspace-itemid-767830

http://blog.csdn.net/wuweilong/article/details/9774337

http://www.prudentwoo.com/archives/1207

慎重提醒:不同操作系统对着lock_sga参数的支持情况是不同的,如果操作系统不支持这种锁定,参数将忽略。

Lock_sga 和 pre_page_sga 参数详解的更多相关文章

  1. Nginx主配置参数详解,Nginx配置网站

    1.Niginx主配置文件参数详解 a.上面博客说了在Linux中安装nginx.博文地址为:http://www.cnblogs.com/hanyinglong/p/5102141.html b.当 ...

  2. iptables参数详解

    iptables参数详解 搬运工:尹正杰 注:此片文章来源于linux社区. Iptalbes 是用来设置.维护和检查Linux内核的IP包过滤规则的. 可以定义不同的表,每个表都包含几个内部的链,也 ...

  3. chattr的常用参数详解

    chattr的常用参数详解 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 在实际生产环境中,有的运维工程师不得不和开发和测试打交道,在我们公司最常见的就是部署接口.每天每个人部署的 ...

  4. mha配置参数详解

    mha配置参数详解: 参数名字 是否必须 参数作用域 默认值 示例 hostname Yes Local Only - hostname=mysql_server1, hostname=192.168 ...

  5. $.ajax()方法所有参数详解;$.get(),$.post(),$.getJSON(),$.ajax()详解

    [一]$.ajax()所有参数详解 url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. type: 要求为String类型的参数,请求方式(post或get)默认为get.注 ...

  6. linux PHP 编译安装参数详解

    linux PHP 编译安装参数详解 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc -- ...

  7. 【转】jqGrid 各种参数 详解

      [原文]http://www.cnblogs.com/younggun/archive/2012/08/27/2657922.htmljqGrid 各种参数 详解 JQGrid JQGrid是一个 ...

  8. HTML滚动字幕代码参数详解及Js间隔滚动代码

    html文字滚动代码 <marquee style="WIDTH: 388px; HEIGHT: 200px" scrollamount="2" dire ...

  9. mysql5.6主从参数详解

    mysql5.6的主从相当的不错,增加了不少参数,提升了主从同步的安全和效率,以下是mysql5.6主从参数详解. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ...

随机推荐

  1. java參数传递方式问题

    java的參数传递方式到底是值传递还是引用传递,这一直是一个争论不休的问题,一直以来没有形成统一意见. 在这里,我也仅仅是说一说个人见解,不保证是对的,全当是抛砖引玉. 首先我的观点是java採用的是 ...

  2. Coreseek:indexer crashed不解之谜

    前两天浩哥让我再把Coreseek的索引再做一次,由于需求那边有点变化,要把索引的公司名字显示出来,就在配置文件中面加入了sql_field_string:字符串字段.. 这个属性特别好用,由于它不仅 ...

  3. 八.使用OpenCv图像平滑操作

    1.cvSmooth函数 函数 cvSmooth 可使用简单模糊.简单无缩放变换的模糊.中值模糊.高斯模糊.双边滤波的不论什么一种方法平滑图像.每一种方法都有自己的特点以及局限. 没有缩放的图像平滑仅 ...

  4. Java学习文件夹

    每天进步一点点,先研究一门语言深入研究下去.

  5. U10vim程序编辑器

    vim需要多加练习. 1.你可以将vim视为vi的高级版本.vi分成三种模式:一般模式,编辑模式和命令行模式. 一般模式:以vi打开一个文件就直接进入一般模式了(这也是默认的模式).在这个模式中,你可 ...

  6. orcl 删除重复的行

    delete from FOODDETAIL t where t.id in (select   t.id from FOODDETAIL where t.sendtime>=to_date(' ...

  7. Tomcat6 Session建立机制简要

    底:  测试部门做压力测试, 结果没多久新闻,出现OutOfMemory. 查找原因,通过监视工具,查找StandardSession(org.apache.catalina.session.Stan ...

  8. Flipping Game(枚举)

    Flipping Game time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  9. windows phone (14) 简单了解Ellipse元素和Rectangle元素

    原文:windows phone (14) 简单了解Ellipse元素和Rectangle元素  System.Windows.Shapes命名空间中包含了显示矢量图形的元素分别为ellipse和re ...

  10. hihocoder第42周 k*N骨牌覆盖(状态dp+矩阵快速幂)

    上周的3*N的骨牌,因为状态只有8中,所以我们可以手算出状态转移的矩阵 但是这周是k*N,状态矩阵不好手算,都是我们改成用程序自动生成一个状态转移的矩阵就行了,然后用这个矩阵进行快速幂即可 枚举枚举上 ...