- 浏览: 152770 次
- 性别:
- 来自: 南京
文章分类
- 全部博客 (327)
- JAVA (130)
- 工作笔记 (49)
- SQLSERVER (5)
- ORACLE (28)
- nginx (1)
- Unix C (16)
- 系统 (19)
- 网络技术 (17)
- WEB前端 (22)
- Eclipse (2)
- Tomcat (1)
- spring (7)
- MYSQL (12)
- Maven (6)
- JETTY (2)
- 设计 (2)
- 开源项目 (7)
- asterisk (0)
- C++ (2)
- WINDOWS (2)
- SCALA (0)
- 协议 (1)
- Netty (1)
- SHELL (1)
- mybaits (4)
- 并发 (2)
- 架构 (2)
- TCP/IP (8)
- 虚拟化 (3)
- 不要再说java慢 (0)
- mac (2)
- mysql乱码完美解决 (1)
最新评论
http://blog.csdn.net/laoshangxyc/article/details/8529381
通过修改lock_sga和pre_page_sga参数可以保证SGA不被换出到虚拟内存,进而可以提高SGA的使用效率。
当lock_sga参数设置为TRUE时(默认值是FALSE),可以保证整个SGA被锁定在物理内存中,这样可以防止SGA被换出到虚拟内存。只要设置lock_sga为“TRUE”便可保证SGA被锁定在物理内存中,这里之所以顺便将pre_page_sga参数也设置为“TRUE”,是因为这样可以保证在启动数据库时把整个SGA读入到物理内存中,以便提高系统的效率(虽然会增加系统的启动时间)。
修改过程如下:
1.查看lock_sga和pre_page_sga参数的默认值
代码:
tacsoft> show parameter sga
NAME TYPE VALUE
--------------- -------------------- -----------------
lock_sga boolean FALSE
pre_page_sga boolean FALSE
sga_max_size big integer 5G
sga_target big integer 5G
2.注意:两个参数都是静态参数。确认之
代码:
tacsoft> alter system set lock_sga=true;
alter system set lock_sga=true
*
ERROR at line 1:
ORA-02095: specified initialization parameter cannot be modified
tacsoft> alter system set pre_page_sga=true;
alter system set pre_page_sga=true
*
ERROR at line 1:
ORA-02095: specified initialization parameter cannot be modified
3.使用“scope=spfile”选项修改之,成功
代码:
tacsoft> alter system set lock_sga=true scope=spfile;
System altered.
tacsoft> alter system set pre_page_sga=true scope=spfile;
System altered.
4.重新启动Oracle使spfile的修改生效
代码:
tacsoft> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
tacsoft> startup;
ORA-27102: out of memory
Linux-x86_64 Error: 12: Cannot allocate memory
失败原因,Linux操作系统对每一个任务在物理内存中能够锁住的最大值做了限制!需要手工进行调整。
5.“ORA-27102”及“Cannot allocate memory”问题处理
1)使用“ulimit -a”命令获得“max locked memory”的默认大小
代码:
ora10g@tacsoft /home/oracle$ 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) 266239
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
可见,一个任务可以锁住的物理内存最大值是32kbytes,这么小的值根本无法满足我们SGA的5G大小需求。
2)将其修改为无限大
(1)oracle用户是无法完成这个修改任务的
代码:
ora10g@tacsoft /home/oracle$ ulimit -l unlimited
-bash: ulimit: max locked memory: cannot modify limit: Operation not permitted
(2)切换到root用户
代码:
ora10g@tacsoft /home/oracle$ su - root
Password:
(3)在root用户下尝试修改,成功。
代码:
[root@tacsoft ~]# ulimit -l unlimited
[root@tacsoft ~]# 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) 266239
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) 2047
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
6.调整完操作系统的限制后,我们再次尝试启动数据库。成功!
代码:
[root@tacsoft ~]# su - oracle
ora10g@tacsoft /home/oracle$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on Sun Dec 20 22:21:40 2009
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to an idle instance.
NotConnected@> startup;
ORACLE instance started.
Total System Global Area 5368709120 bytes
Fixed Size 2080320 bytes
Variable Size 905970112 bytes
Database Buffers 4445962240 bytes
Redo Buffers 14696448 bytes
Database mounted.
Database opened.
7.lock_sga和pre_page_sga参数在Oracle 10gR2官方文档中的描述,供参考。
LOCK_SGAProperty 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 lock the SGA into real (physical) memory, especially if the use of virtual memory would include storing some of the SGA using disk space. This parameter is ignored on platforms that do not support it.
PRE_PAGE_SGAProperty 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 instance startup. Operating system page table entries are then prebuilt for each page of the SGA. This setting can increase the amount of time necessary for instance startup, but it is likely to decrease the amount of time necessary for Oracle to reach its full performance capacity after startup.
Note:
This setting does not prevent your operating system from paging or swapping the SGA after it is initially read into memory.
PRE_PAGE_SGAcan increase the process startup duration, because every process that starts 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 every time a process starts. This approach can be useful with some applications, but not with all applications. Overhead can be significant if your system frequently creates and destroys processes by, for example, continually logging on and logging off.
The advantage thatPRE_PAGE_SGAcan afford depends on page size. For example, if the SGA is 80 MB in size and 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 must be touched to refresh the SGA (80,000/4,000 = 20). The page size is operating system-specific and generally cannot be changed. Some operating systems, however, have a special implementation for shared memory whereby you can change the page size.
通过修改lock_sga和pre_page_sga参数值为“TRUE”可以有效的将整个SGA锁定在物理内存中,这样可以有效的提高系统的性能,推荐酌情进行调整。
注意:不同的操作系统对这lock_sga参数的支持情况是不同的,如果操作系统不支持这种锁定,lock_sga参数将被忽略。
以上方法把 max locked memory 改成(kbytes, -l) unlimited,我觉得不好,我只要把oracle相关进程设成无限大就行了。
用以下方法解决
传说】上海0762) 上午 11:49:38
soft hard
【话唠】长沙-运维-Finy(97074667) 上午 11:52:40
可以针对某个进程? ulimit 里面最多就看到对用户限制。。
【吐槽】孤行-南京(1422207501) 上午 11:52:51
那我搞错了么?
【吐槽】孤行7501) 上午 11:53:02
或者说是对用户的限制?
【吐槽】孤7501) 上午 11:53:11
因为oracle进程必须是oracle用户访问的。
【吐槽】孤207501) 上午 11:53:18
我会限制住的。
【话唠】长074667) 上午 11:54:30
oracle soft nproc unlimited
【话唠】74667) 上午 11:54:52
在/etc/security/limits.d/90-nproc.conf 文件下面加
【吐槽501) 上午 11:55:06
哦。
【话唠】长074667) 上午 11:55:24
然后关闭oracle 再开启才生效
【吐槽】207501) 上午 11:55:28
谢谢。
【1) 上午 11:55:33
恩,要重启。
上午 11:56:30
看生效了没, cat /proc/oracle进程id/limits 看
上午 11:57:45
@长沙-运维-Finy 90.
上午 11:58:05
有。我看到了。
通过修改lock_sga和pre_page_sga参数可以保证SGA不被换出到虚拟内存,进而可以提高SGA的使用效率。
当lock_sga参数设置为TRUE时(默认值是FALSE),可以保证整个SGA被锁定在物理内存中,这样可以防止SGA被换出到虚拟内存。只要设置lock_sga为“TRUE”便可保证SGA被锁定在物理内存中,这里之所以顺便将pre_page_sga参数也设置为“TRUE”,是因为这样可以保证在启动数据库时把整个SGA读入到物理内存中,以便提高系统的效率(虽然会增加系统的启动时间)。
修改过程如下:
1.查看lock_sga和pre_page_sga参数的默认值
代码:
tacsoft> show parameter sga
NAME TYPE VALUE
--------------- -------------------- -----------------
lock_sga boolean FALSE
pre_page_sga boolean FALSE
sga_max_size big integer 5G
sga_target big integer 5G
2.注意:两个参数都是静态参数。确认之
代码:
tacsoft> alter system set lock_sga=true;
alter system set lock_sga=true
*
ERROR at line 1:
ORA-02095: specified initialization parameter cannot be modified
tacsoft> alter system set pre_page_sga=true;
alter system set pre_page_sga=true
*
ERROR at line 1:
ORA-02095: specified initialization parameter cannot be modified
3.使用“scope=spfile”选项修改之,成功
代码:
tacsoft> alter system set lock_sga=true scope=spfile;
System altered.
tacsoft> alter system set pre_page_sga=true scope=spfile;
System altered.
4.重新启动Oracle使spfile的修改生效
代码:
tacsoft> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
tacsoft> startup;
ORA-27102: out of memory
Linux-x86_64 Error: 12: Cannot allocate memory
失败原因,Linux操作系统对每一个任务在物理内存中能够锁住的最大值做了限制!需要手工进行调整。
5.“ORA-27102”及“Cannot allocate memory”问题处理
1)使用“ulimit -a”命令获得“max locked memory”的默认大小
代码:
ora10g@tacsoft /home/oracle$ 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) 266239
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
可见,一个任务可以锁住的物理内存最大值是32kbytes,这么小的值根本无法满足我们SGA的5G大小需求。
2)将其修改为无限大
(1)oracle用户是无法完成这个修改任务的
代码:
ora10g@tacsoft /home/oracle$ ulimit -l unlimited
-bash: ulimit: max locked memory: cannot modify limit: Operation not permitted
(2)切换到root用户
代码:
ora10g@tacsoft /home/oracle$ su - root
Password:
(3)在root用户下尝试修改,成功。
代码:
[root@tacsoft ~]# ulimit -l unlimited
[root@tacsoft ~]# 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) 266239
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) 2047
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
6.调整完操作系统的限制后,我们再次尝试启动数据库。成功!
代码:
[root@tacsoft ~]# su - oracle
ora10g@tacsoft /home/oracle$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on Sun Dec 20 22:21:40 2009
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to an idle instance.
NotConnected@> startup;
ORACLE instance started.
Total System Global Area 5368709120 bytes
Fixed Size 2080320 bytes
Variable Size 905970112 bytes
Database Buffers 4445962240 bytes
Redo Buffers 14696448 bytes
Database mounted.
Database opened.
7.lock_sga和pre_page_sga参数在Oracle 10gR2官方文档中的描述,供参考。
LOCK_SGAProperty 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 lock the SGA into real (physical) memory, especially if the use of virtual memory would include storing some of the SGA using disk space. This parameter is ignored on platforms that do not support it.
PRE_PAGE_SGAProperty 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 instance startup. Operating system page table entries are then prebuilt for each page of the SGA. This setting can increase the amount of time necessary for instance startup, but it is likely to decrease the amount of time necessary for Oracle to reach its full performance capacity after startup.
Note:
This setting does not prevent your operating system from paging or swapping the SGA after it is initially read into memory.
PRE_PAGE_SGAcan increase the process startup duration, because every process that starts 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 every time a process starts. This approach can be useful with some applications, but not with all applications. Overhead can be significant if your system frequently creates and destroys processes by, for example, continually logging on and logging off.
The advantage thatPRE_PAGE_SGAcan afford depends on page size. For example, if the SGA is 80 MB in size and 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 must be touched to refresh the SGA (80,000/4,000 = 20). The page size is operating system-specific and generally cannot be changed. Some operating systems, however, have a special implementation for shared memory whereby you can change the page size.
通过修改lock_sga和pre_page_sga参数值为“TRUE”可以有效的将整个SGA锁定在物理内存中,这样可以有效的提高系统的性能,推荐酌情进行调整。
注意:不同的操作系统对这lock_sga参数的支持情况是不同的,如果操作系统不支持这种锁定,lock_sga参数将被忽略。
以上方法把 max locked memory 改成(kbytes, -l) unlimited,我觉得不好,我只要把oracle相关进程设成无限大就行了。
用以下方法解决
传说】上海0762) 上午 11:49:38
soft hard
【话唠】长沙-运维-Finy(97074667) 上午 11:52:40
可以针对某个进程? ulimit 里面最多就看到对用户限制。。
【吐槽】孤行-南京(1422207501) 上午 11:52:51
那我搞错了么?
【吐槽】孤行7501) 上午 11:53:02
或者说是对用户的限制?
【吐槽】孤7501) 上午 11:53:11
因为oracle进程必须是oracle用户访问的。
【吐槽】孤207501) 上午 11:53:18
我会限制住的。
【话唠】长074667) 上午 11:54:30
oracle soft nproc unlimited
【话唠】74667) 上午 11:54:52
在/etc/security/limits.d/90-nproc.conf 文件下面加
【吐槽501) 上午 11:55:06
哦。
【话唠】长074667) 上午 11:55:24
然后关闭oracle 再开启才生效
【吐槽】207501) 上午 11:55:28
谢谢。
【1) 上午 11:55:33
恩,要重启。
上午 11:56:30
看生效了没, cat /proc/oracle进程id/limits 看
上午 11:57:45
@长沙-运维-Finy 90.
上午 11:58:05
有。我看到了。
发表评论
-
编译安装redis
2016-03-13 17:03 328tar xzf redis-3.07.tar.gz mv r ... -
zookeeper
2016-03-10 16:43 372ZooKeeper服务命令: ... -
oracle 分页
2015-09-17 20:31 503SELECT * FROM (SELECT A.*, R ... -
数据库自动备份
2015-09-09 15:52 434#!/bin/bash currTime=$(date &qu ... -
chkconfig
2015-09-09 14:48 300Linux下chkconfig命令详解 ... -
Oracle IMPDP如何改变索引表空间
2015-08-11 13:22 848转自 http://blog.sina.com.cn/s/b ... -
centos 查看内存
2015-08-08 14:40 569http://elf8848.iteye.com/blog/1 ... -
批量造数据
2015-08-01 17:19 0CREATE OR REPLACE PROCEDURE ES_ ... -
nginx+tomcat
2015-08-01 17:12 0一、安装Tomcat和JDK 1、上传apache-tomc ... -
linux 查看系统信息
2015-08-01 17:03 0# uname -a # 查看内核/操作系统/CPU信息 ... -
常用部署命令
2015-08-01 17:00 0#gcc -v --查看版本信息 #find -name fe ... -
linux系统调整时区和时间
2015-08-01 16:55 0查看/修改Linux时区和时间 一、时区 1. 查 ... -
Linux中cp和scp命令的使用方法
2015-08-01 16:54 0Linux中cp和scp命令的使用方法 Linux为我们提 ... -
Linux 系统挂载数据盘
2015-08-01 16:49 0Linux 系统挂载数据盘 转自 http://www.23 ... -
linux 查看端口
2015-08-01 16:47 0linux端口查看命令 Linux ... -
释放内存
2015-08-01 16:45 0细心的朋友会注意到,当你在linux下频繁存取文件后,物理内存 ... -
Linux 服务器限制IP访问
2015-08-01 16:43 704转自:http://blog.163.com/yuzhongf ... -
linux系统下免费防DDOS CC攻击脚本,有效减轻服务器压力 【转】
2015-08-01 16:37 1693网站DDOS是最头疼的事。即使是国内高防的服务器,也不能100 ... -
linux查看磁盘空间
2015-08-01 16:25 412linux下空间满可能有两种情况 可以通过命令 df -h ... -
NIO的陷阱
2015-06-25 22:28 299// Create a ...
相关推荐
在linux平台不支持lock_sga参数。如果设定lock_sga=true,启动时将报ORA-27126错误。本文总结的使用hugetlbfs来模拟lock_sga的步骤。
oracle实例内存(SGA和PGA)调整
oracle实例内存(SGA和PGA)分析与调整
SGA+PGA最好不要超过总内存的70%,内存详细调整方案,供学习。
有关Oracle的SGA基本组件与概述 如共享池的作用、使用方式等
SGA(system global area)系统全局区跟一些必须的后台进程合进来称为实例(Instance).说它是全局区是包含了全局变量和数据结构,是系统区是包含了进入整个Oracle ...本文将为大家介绍Oracle数据库内存结构SGA的区域信息。
Simple genetic algoritm in matlab
基本的遗传算法matlab语言实现,可变换其中的目标函数,实现计算
ORACLE修改SGA后无法启动的临时解决方法.比较实用的东西
2009Sep_SGA__suspension_FalphaSMC_skycontrol_smc_利用smc控制_kitchen
matlab_利用不同的光谱匹配算法实现光谱匹配_SA_SCA_SCF_SCM_SGA_SID_SID/SA
自编的基于实数编码的遗传算法源程序(fortran) ,用于搜索最小值
2009Sep_SGA__suspension_FalphaSMC_matlab仿真模型_skyhook_vehicle_半主动悬架_磨.zip
由于oracle.exe占用内存过高,修改SGA的大小后导致监听服务不能启动,数据库不能连接等一系列问题和错误,希望此资源能够帮你解决问题,或者给你带来帮助!
有时改oracle的sga相关值后,重启oracle出现异常。 其实更改sga前掌握好先备份的原则,就能快速恢复
调整SGA以及优化oracle数据库,提高数据库的性能。
更改ORACLE SGA的详细步骤 如果修改后启动不了ORACLE,还原ORACLE初始设置的方法方法: 2、使用dos端登录oracle Sqlplus /nolog; Conn / as sysdba; 3、找 pfile,在 /.../admin/XXX(服务名)/pfile 下,init.ora....
根据系统类型、DB版本和OS内存自动计算Oralce建议的memory_target、SGA和PGA大小