注:本文来源: 《oracle数据库内存调整之增加内存》
模拟操作系统内存从2G增加为8G后,调整数据库内存参数,示例中参数不作为实际生产环境参考,因为因需所取,调整参数需要根据数据库相应调整,避免小牛拉大车,大牛拉小车的现象。
查看原始配置数据
1 [oracle@rac1 ~]$ sqlplus / sysdba 2 3 *Plus: Release 11.2.0.4.0 Production Sat Jan 7 18:42:30 2017 4 5 Copyright (c) 1982, 2013, Oracle. rights reserved. 6 7 Connected : 8 Oracle 11g Enterprise Edition Release 11.2.0.4.0 - 64 Production 9 the Partitioning, Application Clusters, Automatic Storage Management, OLAP, 10 Data Mining Application Testing options 11 12 > show parameter sga; 13 14 NAME TYPE 15 ------------------------------------ ----------- ------------------------------ 16 lock_sga boolean 17 pre_page_sga boolean 18 sga_max_size big 700M 19 sga_target big 0 20 > show parameter pga 21 22 NAME TYPE 23 ------------------------------------ ----------- ------------------------------ 24 pga_aggregate_target big 0 25 > show parameter mem 26 27 NAME TYPE 28 ------------------------------------ ----------- ------------------------------ 29 hi_shared_memory_address 0 30 memory_max_target big 1G 31 memory_target big 1G 32 shared_memory_address 0 33 > ho cat /etc/sysctl.conf | grep shmmax 34 # oracle-rdbms-server-11gR2-preinstall setting kernel.shmmax 4398046511104 x86_64 35 # oracle-rdbms-server-11gR2-preinstall setting kernel.shmmax 4294967295 i386 36 kernel.shmmax = 4398046511104 37 kernel.shmmax = 4294967295 38 39 > 4294967295/1024/1024 dual; 40 41 4294967295/1024/1024 42 -------------------- 43 4096 44 45 > 8*1024*1024*1024 dual; 46 47 8*1024*1024*1024 48 ---------------- 49 8589934592 50 51 > 52 [oracle@rac1 ~]$ 53 [root@rac1 ~]# /oracle/app/grid/11.2.0.3/bin/crsctl stop crs 54 [root@rac1 ~]# halt 55 关机后增加物理内存,开机后修改参数 56 [root@rac1 ~]# echo "kernel.shmmax = 8589934592" >> /etc/sysctl.conf 57 [root@rac1 ~]# sysctl -p 58 [root@rac1 ~]# df -ThP 59 Filesystem Type Used Avail % Mounted 60 /dev/sda5 ext4 87G 20G 63G 24% / 61 tmpfs tmpfs 4.0G 0 4.0G 0% /dev/shm 62 /dev/sda1 ext4 504M 61M 418M 13% /boot 63 /dev/sda2 ext4 7.7G 146M 7.2G 2% /tmp 64 [root@rac1 ~]# grep tmpfs /etc/fstab 65 tmpfs /dev/shm tmpfs defaults 0 0 66 [root@rac1 ~]# vim /etc/fstab 67 [root@rac1 ~]# grep tmpfs /etc/fstab 68 tmpfs /dev/shm tmpfs defaults,=8192m 0 0 69 [root@rac1 ~]# mount -o remount tmpfs 70 [root@rac1 ~]# df -ThP 71 Filesystem Type Used Avail % Mounted 72 /dev/sda5 ext4 87G 20G 63G 24% / 73 tmpfs tmpfs 8.0G 116M 7.9G 2% /dev/shm 74 /dev/sda1 ext4 504M 61M 418M 13% /boot 75 /dev/sda2 ext4 7.7G 146M 7.2G 2% /tmp 76 调整 77 > 7*1024 dual; 78 79 7*1024 80 ---------- 81 7168 82 83 > 8*0.56*1024 dual; 84 85 8*0.56*4.48*1024 86 ---------------- 87 4587.52 88 89 > system memory_max_target=7168M scope=spfile; 90 91 System altered. 92 93 > system memory_target=7168M scope=spfile; 94 95 System altered. 96 97 > system sga_max_size=4587M scope=spfile; 98 99 System altered.100 101 > system sga_target=4587M scope=spfile;102 103 System altered.104 105 > 106 closed.107 dismounted.108 ORACLE instance shut down.109 > startup110 ORACLE instance started.111 112 Total System Area 4793552896 bytes113 Fixed 2261328 bytes114 Variable 1124077232 bytes115 Buffers 3657433088 bytes116 Redo Buffers 9781248 bytes117 mounted.118 opened.119 > show parameter sga120 121 NAME TYPE 122 ------------------------------------ ----------- ------------------------------123 lock_sga boolean 124 pre_page_sga boolean 125 sga_max_size big 4592M126 sga_target big 4592M127 > show parameter pga128 129 NAME TYPE 130 ------------------------------------ ----------- ------------------------------131 pga_aggregate_target big 0132 > show parameter mem133 134 NAME TYPE 135 ------------------------------------ ----------- ------------------------------136 hi_shared_memory_address 0137 memory_max_target big 7G138 memory_target big 7G139 shared_memory_address 0140 141 >