设置内存锁 配置limits.conf文件
vi /etc/security/limits.conf
添加或修改为如下内容: oracle soft memlock -1 oracle hard memlock -1
备注:-1为不限制,如果设置,则memlock的数据要大于大页内存的数量 查看修改(oracle用户)
ulimit -l
修改参数
sqlplus / as sysdba
SQL>alter system set lock_sga = true scope=spfile;
SQL>alter system set pre_page_sga = true scope=spfile;
SQL>shutdown immediate;
SQL>startup open;
错误 错误1
SQL>startup; ORA-27102: out of memory Linux-x86_64 Error: 12: Cannot allocate memory
解决方法:设置内存锁;
查看PGA实际大小
set pagesize 100
set linesize 100
col NAME for a22
col Used_Size for a9
select NAME, round(VALUE / 1024 / 1024 / 1024 , 2)||' GB' as Used_Size
from v$pgastat
where name like '%PGA allocated';
SGA内存管理参数 查看SGA的实际大小
set pagesize 100
set linesize 100
col Pool_Name for a15
col Used_Size for a9
select nvl(pool, name) as Pool_Name,
round(sum(bytes) / 1024 / 1024 / 1024 , 2) || ' GB' as Used_Size
from v$sgastat
group by nvl(pool, name)
order by nvl(pool, name);
db_keep_cache_size与db_recycle_cache_size
1.设置keep|recycle池大小
2.使用keep|recycle池和不使用
alter table|index .... storage(buffer_pool keep|recycle|default);
备注:db_keep_cache_size——可以使表长期驻留在这个区域
3.缓存|不缓存keep池中
alter table table_name cache|nocache;
4.刷新缓存
alter system flush shared_pool
5.查看表是否已经缓存到keep池中
select table_name,CACHE,BUFFER_POOL from user_tables;
自动内存管理 设置PGA参数
alter system set workarea_size_policy=auto; 设置PGA大小
alter system set pga_aggregate_target=0; 设置SGA大小
alter system set sga_target=0; 设置共享池大小
alter system set shared_pool_size=0; 设置数据库缓冲区大小
alter system set db_cache_size=0; 设置大池大小
alter system set large_pool_size=0; 设置流池大小
alter system set streams_pool_size=0; 设置JAVA池大小
alter system set java_pool_size=0; 设置数据库最大总内存值
alter system set memory_max_target=20G scope = spfile; 设置数据库总内存参数
alter system set memory_target=20G;
备注1:memory_target=sga_target+pga_aggregate_target
备注2:memory_target<=memory_max_target
取消自动内存管理
alter system reset memory_target scope=spfile;
alter system reset memory_max_target scope=spfile; OLTP系统
alter system set sga_target = (总物理内存* 0.8) * 0.7 scope=spfile;
alter system set sga_max_size = (总物理内存* 0.8) * 0.7 scope=spfile;
alter system set pga_aggregate_target= (总物理内存 * 0.8) * 0.3 scope=spfile; OLAP系统
alter system set sga_target = (总物理内存* 0.8) * 0.5 scope=spfile;
alter system set sga_max_size = (总物理内存* 0.8) * 0.5 scope=spfile;
alter system pga_aggregate_target= (总物理内存 * 0.8) * 0.5 scope=spfile;
SGA内存顾问
set pagesize 100
set linesize 100
select sga_size as estimate_sga_mb, --预测的SGA内存值
sga_size_factor as sga_rate, --若为1,则sga_size表示当前的SGA内存值
estd_physical_reads --物理读的百分比
from v$sga_target_advice;
总内存顾问
set pagesize 100
set linesize 100
select memory_size as estimate_memory_mb, --预测的总内存值
memory_size_factor, --若为1,则memory_size 表示当前的总内存值
estd_db_time,
estd_db_time_factor --消耗数据库时间的比例因子
from v$memory_target_advice;