Issues that need to be considered when upgrading the memory of the database server.

Background of the project:

The original database server runs on HP DL388G7 server with 32G memory . Due to business growth, memory is tight, and server hardware failures occur from time to time. Since it is a single instance and single server, there is a single point of discovery, so I plan to take some measures to improve it:

1 ) Upgrade server memory

2 ) And build a server operating system level dual machine

3 ) Migrate database data to new server

 

 

I have written an article related to data migration, titled " EXP/IMP Migration Data ", the link is as follows: http: //blog.csdn .NET /laven54/article/details/8877940

I have written an article related to data migration before, titled " SUSE Linux HA dual-machine construction ", the link is as follows: http: //blog.csdn .Net /laven54/article/details/8878048
 

————————————————————————————————————————————

 

 

 

 If the business volume of your system increases, the pressure on the database server increases, and the physical host needs to add memory, how much should be added, and how should the parameters be adjusted? This article teaches you how to do it step by step.

  •  1 Theoretical approach

The parameters that need to be adjusted include SGA, PGA, process, session values, as well as shmall and shmmax in the kernel parameters.

  • 1.1 Calculation methods of SGA and PGA


SGA = total physical memory * 50%
PGA = total physical memory * 20%
and the remaining 30% is reserved for the operating system. If the memory resources are relatively tight, and the cost of the system needs to be considered, if the database pressure is not too large, you can actually set the sizes of sga and pga to be smaller, and adjust them little by little. For example, 20% of the physical memory is allocated to the SGA, 5% to the PGA, and then adjusted according to the actual situation.

  • 1.2 Calculation method of kernel parameter setting

Explain how to set the parameters of shmall and shmmax in the kernel:
shmmax<=number of physical memory(G)*1024*1024*1024(bytes)

shmall>=sga(G)*1024*1024*1024/page_size It
is recommended that you directly use the sum of SGA and PGA for calculation.

page_size can be queried with the following command:
getconf PAGE_SIZE

 

shmmax<=number of physical memory (G)*1024*1024*1024 (bytes)
refers to the maximum value of a single shared memory segment, the unit is bytes, which is commonly known as B. Generally recommended as half of the physical memory, it can be slightly larger, I like to set the size to the sum of sga and pga.

shmall=SGA(G)/page_size(bytes)=sga(G)*1024*1024*1024/page_size, for example, sga size is 22G, page_size=4kb=4096bytes, then shmall=22*1024*1024*1024bytes/4096bytes= 5767168
shmall refers to the total number of shared memory pages, shared memory you can connect as SGA, because for Oracle , PGA is not shared, well, just when I say nonsense.
The size of the page is generally 4KB, and the unit is bytes. The value found through the command get page_size is generally 4096bytes

Summary: Pay attention to the unit, shmmax refers to the memory value, there is a unit, the unit is bytes, the unit of page_size is bytes, and shmall has no unit, it is just a number, indicating the number of pages.

 

Unit conversion table:
1 byte (B) = 8 bits (b) Byte=8 binary bits
1 Kilobyte(K/KB)=2^10 bytes=1,024 bytes Kilobyte
1 Megabyte(M/MB)=2^ 20 bytes=1,048,576 bytes
1 Gigabyte(G/GB)=2^30 bytes=1,073,741,824 bytes
1 Terabyte(T/TB)=2^40 bytes=1,099,511,627,776 bytes

 

  • 2 Operation example

  • 2.1 Collect the status quo of database memory allocation

# free -m
             total       used       free     shared    buffers     cached
Mem:         32096      29072       3024          0         49      22406
-/+ buffers/cache:       6616      25480
Swap:        32765        847      31918
su - oracle
 sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Fri Mar 29 16:09:42 2013

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show parameter sga

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
lock_sga                             boolean     FALSE
pre_page_sga                         boolean     FALSE
sga_max_size                         big integer 8000M
sga_target                           big integer 8000M
SQL> show parameter pga

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
pga_aggregate_target                 big integer 5606M


SQL> show parameter processes

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
aq_tm_processes                      integer     0
db_writer_processes                  integer     8
gcs_server_processes                 integer     0
job_queue_processes                  integer     10
log_archive_max_processes            integer     2
processes                            integer     900

SQL> show parameter sessions

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
java_max_sessionspace_size           integer     0
java_soft_sessionspace_limit         integer     0
license_max_sessions                 integer     0
license_sessions_warning             integer     0
logmnr_max_persistent_sessions       integer     1
sessions                             integer     995
shared_server_sessions               integer

 

数据库内存分配现状:
总内存32G
SGA:8G
PGA:5.6G

计划调整之后的内存分配数值情况:
总内存32G
SGA:16G
PGA:5.6G

  • 2.2 调整操作步骤

备份spfile文件:
cd /eb_db/oracle/product/10.2/db/dbs/
cp spfileebai.ora spfileebai.ora.bak20130330

备份内核参数文件:
cp /etc/sysctl.conf /etc/sysctl.conf.bak20130330

修改内核文件:
vi /etc/sysctl.conf
kernel.shmall = 5767168

解释一下内核中这俩参数的设置规定:
shmmax<=物理内存数(G)*1024*1024*1024(bytes)

shmall>=sga(G)*1024*1024*1024/page_size
这里推荐大家直接使用SGA和PGA的和来计算比较好。

page_size可以通过如下命令查询:
getconf PAGE_SIZE

更加具体的shmall和shmmax的设置细节标准请参看后边的内容.
sqlplus / as sysdba

create pfile from spfile;

alter system set sga_target=16384m scope=spfile;

alter system set sga_max_size=16384m scope=spfile;

alter system set processes=1600 scope=spfile;

alter system set sessions=1765 scope=spfile;

alter system  checkpoint;

shutdown immediate;

startup;

show parameter processes

show parameter sessions

 

  • 3 shmall和shmmax的设置方法

如何设置shmall:
SQL> startup nomount
ORA-27102: out of memory
Linux-x86_64 Error: 28: No space left on device
Ask Questions, Get Help, And Share Your Experiences With This Article
Would you like to explore this topic further with other Oracle Customers, Oracle Employees, and Industry Experts?

Click here to join the discussion where you can ask questions, get help from others, and share your experiences with this specific article.
Discover discussions about other articles and helpful subjects by clicking here to access the main My Oracle Support Community page for Database Install/Upgrade.

Changes
shmall is too small, most likely is set to the default setting of 2097152

$ cat /proc/sys/kernel/shmall
2097152
Cause
shmall is the total amount of shared memory, in pages, that the system can use at one time.

Solution
Set shmall equal to the sum of all the SGAs on the system, divided by the page size.

The page size can be determined using the following command:

$ getconf PAGE_SIZE
4096For example, if the sum of all the SGAs on the system is 16Gb and the result of  '$ getconf PAGE_SIZE' is 4096 (4Kb) then set shmall to 4194304 pages

As the root user set the shmall to 4194304 in the /etc/sysctl.conf file:

kernel.shmall = 4194304
then run the following command:

$ sysctl -p
$ cat /proc/sys/kernel/shmall
4194304NOTE:

The above command loads the new value and a reboot is not necessary.


如何设置shmmax:
Goal
QUESTION 1
===========
What is the maximum value of SHMMAX for a 32-bit (x86) Linux system?


QUESTION 2
===========
What is the maximum value of SHMMAX for a 64-bit (x86-64) Linux system?

Fix
ANSWER 1
============
Oracle Global Customer Support officially recommends a " maximum" for SHMMAX of just less than 4Gb, or 4294967295.

The maximum size of a shared memory segment is limited by the size of the available user address space. On 32-bit systems, this is a theoretical 4GB. The maximum possible value for SHMMAX is just less than 4Gb, or 4294967295. Setting SHMMAX to 4GB exactly will give you 0 bytes as max, as this value is interpreted as a 32-bit number and it wraps around.


ANSWER 2
===========
Oracle Global Customer Support officially recommends a " maximum" for SHMMAX of "1/2 of physical RAM".

The maximum size of a shared memory segment is limited by the size of the available user address space. On 64-bit systems, this is a theoretical 2^64bytes. So the "theoretical limit" for SHMMAX is the amount of physical RAM that you have.  However, to actually attempt to use such a value could potentially lead to a situation where no system memory is available for anything else.  Therefore a more realistic "physical limit" for SHMMAX would probably be "physical RAM - 2Gb".

In an Oracle RDBMS application, this "physical limit" still leaves inadequate system memory for other necessary functions. Therefore, the common "Oracle maximum" for SHMMAX that you will often see is "1/2 of physical RAM". Many Oracle customers chose a higher fraction, at their discretion.

Occasionally, Customers may erroneously think that that setting the SHMMAX as recommended in this NOTE limits the total SGA.   That is not true.  Setting the SHMMAX as recommended only causes a few more "shared memory segments" to be used for whatever total SGA that you subsequently configure in Oracle.For additional detail, please see

Document 15566.1, "SGA, SHMMAX, Semaphores and Shared Memory Explained"

Also to be taken into consideration for memory configuration is the kernel parameter for kernel.shmall which is the total amount of shared memory, in pages, that the system can use at one time.  Review:

Document 301830.1 Upon startup of Linux database get ORA-27102: out of memory Linux-X86_64 Error: 28: No space left on device


 

 常见错误:

ORA-27102: out of memory
Linux-x86_64 Error: 28: No space left on device

This situation is generally caused by incorrectly setting kernel parameters.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326454517&siteId=291194637