数据库参数设置不当,再强大的服务器也无法发挥它的性能 若设置memory_target,可将该值设置为物理内存的80%左右,sga_max_size、sga_target、db_cache_size、shared_pool_size和pga_aggregate_target设置为0。 若不设置 memory_target ,可将sga_max_size、sga_target设置为物理内存的70%左右,pga_aggregate_target设置为物理内存的10%;
重要说明: a) memory_max_target和memory_target存在严重的bug,在多个客户下出现过值配置合理,但共享池和数据库缓冲区内存分配极不合理情况,建议不使用这两个参数! 而是使用sga_max_size、sga_target这两个参数,并设置为物理内存的70%左右,设置db_cache_size应设置为物理内存的50%~60%左右,shared_pool_size应设置为物理内存的10%~15%左右 b) memory_max_target和lock_sga,hugepage有冲突,设置了memory_max_target就没法使用 hugepage和lock_sga? c)shared_pool_size值并非越大越好,通常情况下,不建议设置大于80G d) 设置内存参数时,需要调查数据库服务器中有没有mysql,mongodb等数据库在运行,有多少数据库实例在运行,有没有EAS或其它应用服务器在运行, ? ?如果有,那说明不能把内存仅用于oracle实例,就不能按本文档来设置,而是根据实际剩余可用内存进行计算。 #------------------------------------------------------------------------- 前期准备(windows无需此步骤,Linux则需要): 查询参数设置值应该设置多少: sqlplus / as sysdba ?column "kernel.shmmax" format 99999999999999999999
请输入服务器物理内存大小: select? round(&InputPhysicalMemorySize*0.8*1024*1024*1024/(2048*1024)) as "vm.nr_hugepages", round(&InputPhysicalMemorySize*0.8*1024*1024*1024) ?as ?"kernel.shmmax", round(&InputPhysicalMemorySize*0.8*1024*1024*1024*0.9/4096) as "kernel.shmall"? from dual;
?输出结果会例如下所示: vm.nr_hugepages ? ? ? ? kernel.shmmax kernel.shmall --------------- --------------------- ------------ (注意实际的值可能与些不同,应看实际输出结果,而不是直接复制下面的值!) ? ? ? ? ? 52429 ? ? ? ? ?109951162778 ? ? 24159191
kernel.shmall = 1073741824
#vi /etc/sysctl.conf, 在文件末尾加入: vm.nr_hugepages = 上面查询值 kernel.shmmax = 上面查询值 kernel.shmall = 上面查询值 或kernel.shmall = 1073741824 fs.file-max=6815744 fs.aio-max-nr=1048576
vim /etc/security/limits.conf ,在文件末尾加入: * hard memlock unlimited * soft memlock unlimited #---------------------------------------------- 数据库内存参数设置步骤: 步骤1: sqlplus / as sysdba --登录数据库 show parameter spfile --复制spfile,保存到其它地方做备份 widows: create pfile='c:\init_eas.ora' from spfile; --在修改pfile前先备份参数文件,如果修改后数据库无法启动,可以使用这个参数来启动数据库 Linux/Unix: create pfile='/tmp/init_eas.ora' from spfile;
步骤2: ?修改数据库参数,请根据本文中后面的物理内存大小对号入座,进行设置
步骤3: shutdown immediate; 重启数据库服务器操作系统(请确认重启操作系统是否安全,有可能重启操作系统后,系统启动失败)
步骤4: sqlplus / as sysdba 登录数据库,如果数据库没有启动,请用下面命令启动数据库 startup --重启数据库
步骤5: lsnrctl status 查看监听是否启动,如果没有启动,请用下面命令启动监听 lsntctl start
#-------------------------------------------# 数据参数的修改_失败回退: 1. 登录数据库 sqlplus / as sysdba 2.复制 c:\init_eas.ora ?到c:\init_eas.ora.bak 3.修改c:\init_eas.ora 的参数为合适的值 4.使用新修改的参数文件尝试启动数据库:? ?startup force pfile='c:\init_eas.ora'; 5.如果使用新的c:\init_eas.ora 文件能启动,则创建新的spfile,否则返回第3点:? ?create spfile from pfile='c:\init_eas.ora'; 6.如果实在不会修改init_eas.ora参数文件,可以使用之前步骤2中备份的spfile来替换回去
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 16G物理内存参考参数: ?
alter system reset memory_target scope=spfile sid='*'; --出错表明该参数没有设置,请忽略 alter system reset memory_max_target scope=spfile sid='*'; ?--出错表明该参数没有设置,请忽略 alter system set sga_max_size=10G scope=spfile sid='*'; alter system set sga_target=10G scope=spfile sid='*'; alter system set db_cache_size=5g scope=spfile sid='*'; alter system set shared_pool_size=3g scope=spfile sid='*'; alter system set pga_aggregate_target=800M scope=spfile sid='*'; alter system set dml_locks=12000 scope=spfile ?sid='*'; alter system ?set optimizer_index_caching=90 scope=both sid='*'; alter system ?set optimizer_index_cost_adj=50 scope=both sid='*'; alter system ?set open_cursors=3000 scope=both sid='*'; alter system ?set processes=1200 scope=spfile sid='*'; alter system set "_b_tree_bitmap_plans"=FALSE scope=both sid='*'; alter system set "_complex_view_merging"=TRUE scope=both sid='*'; alter system set "_no_or_expansion"=TRUE scope=both sid='*'; alter system set "_optimizer_cost_based_transformation"=on scope=both sid='*'; alter system set "_pred_move_around"=FALSE scope=both sid='*';
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 24G物理内存参考参数: ?
alter system reset memory_target scope=spfile sid='*'; --出错表明该参数没有设置,请忽略 alter system reset memory_max_target scope=spfile sid='*'; ?--出错表明该参数没有设置,请忽略 alter system set sga_max_size=16G scope=spfile sid='*'; alter system set sga_target=16G scope=spfile sid='*'; alter system set db_cache_size=11G scope=spfile sid='*'; alter system set shared_pool_size=4G scope=spfile sid='*'; alter system set pga_aggregate_target=1G scope=spfile sid='*'; alter system set dml_locks=12000 scope=spfile ?sid='*'; alter system ?set optimizer_index_caching=90 scope=both sid='*'; alter system ?set optimizer_index_cost_adj=50 scope=both sid='*'; alter system ?set open_cursors=3000 scope=both sid='*'; alter system ?set processes=1200 scope=spfile sid='*'; alter system set "_b_tree_bitmap_plans"=FALSE scope=both sid='*'; alter system set "_complex_view_merging"=TRUE scope=both sid='*'; alter system set "_no_or_expansion"=TRUE scope=both sid='*'; alter system set "_optimizer_cost_based_transformation"=on scope=both sid='*'; alter system set "_pred_move_around"=FALSE scope=both sid='*';
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 32G物理内存参考参数: ? alter system reset memory_target scope=spfile sid='*'; ? ? ? --出错表明该参数没有设置,请忽略 alter system reset memory_max_target scope=spfile sid='*'; ? --出错表明该参数没有设置,请忽略 alter system set sga_max_size=22G scope=spfile sid='*'; alter system set sga_target=22G scope=spfile sid='*'; alter system set db_cache_size=14G scope=spfile sid='*'; alter system set shared_pool_size=6G scope=spfile sid='*'; alter system set pga_aggregate_target=2G scope=spfile sid='*'; alter system set dml_locks=12000 scope=spfile ?sid='*'; alter system ?set optimizer_index_caching=90 scope=both sid='*'; alter system ?set optimizer_index_cost_adj=50 scope=both sid='*'; alter system ?set open_cursors=3000 scope=both sid='*'; alter system ?set processes=1200 scope=spfile sid='*'; alter system set "_b_tree_bitmap_plans"=FALSE scope=both sid='*'; alter system set "_complex_view_merging"=TRUE scope=both sid='*'; alter system set "_no_or_expansion"=TRUE scope=both sid='*'; alter system set "_optimizer_cost_based_transformation"=on scope=both sid='*'; alter system set "_pred_move_around"=FALSE scope=both sid='*';
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 64G物理内存参考参数: ? alter system reset memory_target scope=spfile sid='*'; ?--出错表明该参数没有设置,请忽略 alter system reset memory_max_target scope=spfile sid='*'; ? --出错表明该参数没有设置,请忽略 alter system set sga_max_size=44G scope=spfile sid='*'; alter system set sga_target=44G scope=spfile sid='*'; alter system set db_cache_size=30G scope=spfile sid='*'; alter system set shared_pool_size=12G scope=spfile sid='*'; alter system set pga_aggregate_target=4G scope=spfile sid='*'; alter system set dml_locks=12000 scope=spfile ?sid='*'; alter system ?set optimizer_index_caching=90 scope=both sid='*'; alter system ?set optimizer_index_cost_adj=50 scope=both sid='*'; alter system ?set open_cursors=3000 scope=both sid='*'; alter system ?set processes=1200 scope=spfile sid='*'; alter system set "_b_tree_bitmap_plans"=FALSE scope=both sid='*'; alter system set "_complex_view_merging"=TRUE scope=both sid='*'; alter system set "_no_or_expansion"=TRUE scope=both sid='*'; alter system set "_optimizer_cost_based_transformation"=on scope=both sid='*'; alter system set "_pred_move_around"=FALSE scope=both sid='*';
alter system set cursor_sharing=force scope=both sid='*'; ? @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 96G物理内存参考参数: ? alter system reset memory_target scope=spfile sid='*'; ?--出错表明该参数没有设置,请忽略 alter system reset memory_max_target scope=spfile sid='*'; ? --出错表明该参数没有设置,请忽略 alter system set sga_max_size=67G scope=spfile sid='*'; alter system set sga_target=67G scope=spfile sid='*'; alter system set db_cache_size=46G scope=spfile sid='*'; alter system set shared_pool_size=18G scope=spfile sid='*'; alter system set pga_aggregate_target=3G scope=spfile sid='*'; alter system set dml_locks=12000 scope=spfile ?sid='*'; alter system ?set optimizer_index_caching=90 scope=both sid='*'; alter system ?set optimizer_index_cost_adj=50 scope=both sid='*'; alter system ?set open_cursors=3000 scope=both sid='*'; alter system ?set processes=1200 scope=spfile sid='*'; alter system set "_b_tree_bitmap_plans"=FALSE scope=both sid='*'; alter system set "_complex_view_merging"=TRUE scope=both sid='*'; alter system set "_no_or_expansion"=TRUE scope=both sid='*'; alter system set "_optimizer_cost_based_transformation"=on scope=both sid='*'; alter system set "_pred_move_around"=FALSE scope=both sid='*';
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 128G物理内存参考参数: alter system reset memory_target scope=spfile sid='*'; ? --出错表明该参数没有设置,请忽略 alter system reset memory_max_target scope=spfile sid='*'; ; ?--出错表明该参数没有设置,请忽略 alter system set sga_max_size=82G scope=spfile sid='*'; alter system set sga_target=82G scope=spfile sid='*'; alter system set db_cache_size=57G scope=spfile sid='*'; alter system set shared_pool_size=22G scope=spfile sid='*'; alter system set pga_aggregate_target=7G scope=spfile sid='*'; alter system set dml_locks=12000 scope=spfile ?sid='*'; alter system ?set optimizer_index_caching=90 scope=both sid='*'; alter system ?set optimizer_index_cost_adj=50 scope=both sid='*'; alter system ?set open_cursors=3000 scope=both sid='*'; alter system ?set processes=1200 scope=spfile sid='*'; alter system set "_b_tree_bitmap_plans"=FALSE scope=both sid='*'; alter system set "_complex_view_merging"=TRUE scope=both sid='*'; alter system set "_no_or_expansion"=TRUE scope=both sid='*'; alter system set "_optimizer_cost_based_transformation"=on scope=both sid='*'; alter system set "_pred_move_around"=FALSE scope=both sid='*'; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
220G物理内存调整: alter system reset memory_target scope=spfile sid='*'; ?--出错表明该参数没有设置,请忽略 alter system reset memory_max_target scope=spfile sid='*'; ? --出错表明该参数没有设置,请忽略 alter system set sga_max_size=160G scope=spfile sid='*'; alter system set sga_target=160G scope=spfile sid='*'; alter system set db_cache_size=110G scope=spfile sid='*'; alter system set shared_pool_size=30G scope=spfile sid='*'; alter system set pga_aggregate_target=15G scope=spfile sid='*'; alter system set dml_locks=12000 scope=spfile ?sid='*'; alter system ?set optimizer_index_caching=90 scope=both sid='*'; alter system ?set optimizer_index_cost_adj=50 scope=both sid='*'; alter system ?set open_cursors=3000 scope=both sid='*'; alter system ?set processes=1200 scope=spfile sid='*'; alter system set "_b_tree_bitmap_plans"=FALSE scope=both sid='*'; alter system set "_complex_view_merging"=TRUE scope=both sid='*'; alter system set "_no_or_expansion"=TRUE scope=both sid='*'; alter system set "_optimizer_cost_based_transformation"=on scope=both sid='*'; alter system set "_pred_move_around"=FALSE scope=both sid='*'; --alter system set cursor_sharing=force scope=both sid='*'; --上面行已经注释,如果硬解析过高,经常出现ORA-04031错误,请把cursor_sharing设置成force
256G物理内存参考参数: SQL> startup; ORA-27104: system-defined limits for shared memory was misconfigured 检查按大页设置的shmall可能太小,在按实际内存查询出来的值 ,再到后面加一个0即可 ?
alter system reset memory_target scope=spfile sid='*'; ?--出错表明该参数没有设置,请忽略 alter system reset memory_max_target scope=spfile sid='*'; ? --出错表明该参数没有设置,请忽略 alter system set sga_max_size=195G scope=spfile sid='*'; alter system set sga_target=195G scope=spfile sid='*'; alter system set db_cache_size=150G scope=spfile sid='*'; alter system set shared_pool_size=35G scope=spfile sid='*'; alter system set pga_aggregate_target=15G scope=spfile sid='*'; alter system set dml_locks=12000 scope=spfile ?sid='*'; alter system ?set optimizer_index_caching=90 scope=both sid='*'; alter system ?set optimizer_index_cost_adj=50 scope=both sid='*'; alter system ?set open_cursors=3000 scope=both sid='*'; alter system ?set processes=1200 scope=spfile sid='*'; alter system set "_b_tree_bitmap_plans"=FALSE scope=both sid='*'; alter system set "_complex_view_merging"=TRUE scope=both sid='*'; alter system set "_no_or_expansion"=TRUE scope=both sid='*'; alter system set "_optimizer_cost_based_transformation"=on scope=both sid='*'; alter system set "_pred_move_around"=FALSE scope=both sid='*';
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 512G物理内存参考参数: alter system reset memory_target scope=spfile sid='*'; ?--出错表明该参数没有设置,请忽略 alter system reset memory_max_target scope=spfile sid='*'; ? --出错表明该参数没有设置,请忽略 alter system set sga_max_size=400G scope=spfile sid='*'; alter system set sga_target=400G scope=spfile sid='*'; alter system set db_cache_size=330G scope=spfile sid='*'; alter system set shared_pool_size=50G scope=spfile sid='*'; alter system set pga_aggregate_target=20G scope=spfile sid='*'; alter system set dml_locks=12000 scope=spfile ?sid='*'; alter system ?set optimizer_index_caching=90 scope=both sid='*'; alter system ?set optimizer_index_cost_adj=50 scope=both sid='*'; alter system ?set open_cursors=3000 scope=both sid='*'; alter system ?set processes=1200 scope=spfile sid='*'; alter system set "_b_tree_bitmap_plans"=FALSE scope=both sid='*'; alter system set "_complex_view_merging"=TRUE scope=both sid='*'; alter system set "_no_or_expansion"=TRUE scope=both sid='*'; alter system set "_optimizer_cost_based_transformation"=on scope=both sid='*'; alter system set "_pred_move_around"=FALSE scope=both sid='*';
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 640G物理内存参考参数: alter system reset memory_target scope=spfile sid='*'; ?--出错表明该参数没有设置,请忽略 alter system reset memory_max_target scope=spfile sid='*'; ? --出错表明该参数没有设置,请忽略 alter system set sga_max_size=500G scope=spfile sid='*'; alter system set sga_target=500G scope=spfile sid='*'; alter system set db_cache_size=420G scope=spfile sid='*'; alter system set shared_pool_size=60G scope=spfile sid='*'; alter system set pga_aggregate_target=20G scope=spfile sid='*'; alter system set dml_locks=12000 scope=spfile ?sid='*'; alter system ?set optimizer_index_caching=90 scope=both sid='*'; alter system ?set optimizer_index_cost_adj=50 scope=both sid='*'; alter system ?set open_cursors=3000 scope=both sid='*'; alter system ?set processes=1200 scope=spfile sid='*'; alter system set "_b_tree_bitmap_plans"=FALSE scope=both sid='*'; alter system set "_complex_view_merging"=TRUE scope=both sid='*'; alter system set "_no_or_expansion"=TRUE scope=both sid='*'; alter system set "_optimizer_cost_based_transformation"=on scope=both sid='*'; alter system set "_pred_move_around"=FALSE scope=both sid='*';
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 768G物理内存参考参数: alter system reset memory_target scope=spfile sid='*'; ?--出错表明该参数没有设置,请忽略 alter system reset memory_max_target scope=spfile sid='*'; ? --出错表明该参数没有设置,请忽略 alter system set sga_max_size=540G scope=spfile sid='*'; alter system set sga_target=540G scope=spfile sid='*'; alter system set db_cache_size=460G scope=spfile sid='*'; alter system set shared_pool_size=60G scope=spfile sid='*'; alter system set pga_aggregate_target=20G scope=spfile sid='*'; alter system set dml_locks=12000 scope=spfile ?sid='*'; alter system ?set optimizer_index_caching=90 scope=both sid='*'; alter system ?set optimizer_index_cost_adj=50 scope=both sid='*'; alter system ?set open_cursors=3000 scope=both sid='*'; alter system ?set processes=1200 scope=spfile sid='*'; alter system set "_b_tree_bitmap_plans"=FALSE scope=both sid='*'; alter system set "_complex_view_merging"=TRUE scope=both sid='*'; alter system set "_no_or_expansion"=TRUE scope=both sid='*'; alter system set "_optimizer_cost_based_transformation"=on scope=both sid='*'; alter system set "_pred_move_around"=FALSE scope=both sid='*';
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
? 1TB物理内存参考参数: alter system reset memory_target scope=spfile sid='*'; ?--出错表明该参数没有设置,请忽略 alter system reset memory_max_target scope=spfile sid='*'; ? --出错表明该参数没有设置,请忽略 alter system set sga_max_size=800G scope=spfile sid='*'; alter system set sga_target=600G scope=spfile sid='*'; --sga_max_size设置800G,而sga_target设置600G ,sga_target如若不够,可以动态加大 alter system set db_cache_size=500G scope=spfile sid='*'; alter system set shared_pool_size=60G scope=spfile sid='*'; alter system set pga_aggregate_target=60G scope=spfile sid='*'; alter system set dml_locks=12000 scope=spfile ?sid='*'; alter system ?set optimizer_index_caching=90 scope=both sid='*'; alter system ?set optimizer_index_cost_adj=50 scope=both sid='*'; alter system ?set open_cursors=3000 scope=both sid='*'; alter system ?set processes=1200 scope=spfile sid='*'; alter system set "_b_tree_bitmap_plans"=FALSE scope=both sid='*'; alter system set "_complex_view_merging"=TRUE scope=both sid='*'; alter system set "_no_or_expansion"=TRUE scope=both sid='*'; alter system set "_optimizer_cost_based_transformation"=on scope=both sid='*'; alter system set "_pred_move_around"=FALSE scope=both sid='*'; ? ?
|