Thursday, March 14, 2024

Oracle SHMMAX and SHMALL parameters

SHMMAX and SHMALL parameters


QUESTION 1

===========

What is the maximum value of SHMMAX for a 32-bit (x86) Linux system?


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.




QUESTION 2

===========

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


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




System Parameters


SHMMAX - kernel parameter controlling maximum size of one shared memory segment


SHMMNI - kernel parameter controlling maximum number of shared memory segments in the system


SHMSEG - kernel parameter controlling maximum number of shared memory segments a process can attach


SEMMNS - kernel parameter controlling maximum number of semaphores in the system


SEMMNI - kernel parameter controlling maximum number of semaphore sets. Semaphores in Unix are allocated in sets of 1 to SEMMSL.


SEMMSL - kernel parameter controlling maximum number of semaphores in a semaphore set.


SHMLBA - kernel parameter controlling alignment of shared memory segments; all segments must be attached at multiples of this value.

Typically, non-tunable.



SHMMAX is the maximum size of a single shared memory segment set in "bytes"


[root@ip-10.1.1.1.1 ~]# cat /proc/sys/kernel/shmmax

18446744073692774399

[root@ip-10.1.1.1.1 ~]#


SHMALL is the total size of Shared Memory Segments System wide set in "pages".

[root@ip-10.1.1.1.1 ~]#  cat /proc/sys/kernel/shmall

18446744073692774399

[root@ip-10.1.1.1.1 ~]#


The key thing to note here is the value of SHMMAX is set in “bytes” but the value of SHMMALL is set in “pages”.



As SHMALL is the total size of Shard Memory Segments System wide, it should always be less than the Physical Memory on the System and should be greater than sum of SGA’s of all the oracle databases on the server. Once this value (sum of SGA’s) hit the limit, i.e. the value of shmall, then any attempt to start a new database (or even an existing database with a resized SGA) will result in an “out of memory” error (below). This is because there won’t be any more shared memory segments that Linux can allocate for SGA.


ORA-27102: out of memory

Linux-x86_64 Error: 28: No space left on device.


Setting the value for SHMALL to optimal is straight forward. All you want to know is how much “Physical Memory” (excluding Cache/Swap) you have on the system and how much of it should be set aside for Linux Kernel and to be dedicated to Oracle Databases




example 


[root@ip-10.1.1.1.1 ~]# free -g

               total        used        free      shared  buff/cache   available

Mem:               7           0           5           0           1           7

Swap:              0           0           0

[root@ip-10.1.1.1.1 ~]#



 Let say the Physical Memory of a system is 7GB, out of which you want to set aside 2GB for Linux Kernel for OS Operations and dedicate the rest of 5GB to Oracle Databases. Then here’s how you will get the value for SHMALL.

 


[root@ip-10.1.1.1.1 ~]# getconf PAGE_SIZE

4096

[root@ip-10.1.1.1.1 ~]#


or


[root@ip-10.1.1.1.1 ~]# cat /proc/sys/kernel/shmmni

4096

[root@ip-10.1.1.1.1 ~]#


Convert 5GB into bytes and divide by page size


 5gb = 5*1024*1024*1024 =  5,368,709,120 bytes /4096

 

 = 1310720

 






[root@ip-10.1.1.1.1 ~]# ipcs -lm


------ Shared Memory Limits --------

max number of segments = 4096

max seg size (kbytes) = 18014398509465599

max total shared memory (kbytes) = 18446744073709551612

min seg size (bytes) = 1






What’s the optimal value for SHMMAX?


Oracle makes use of one of the 3 memory management models to create the SGA during database startup and it does this in following sequence. First Oracle attempts to use the one-segment model and if this fails, it proceeds with the next one which’s the contiguous multi-segment model and if that fails too, it goes with the last option which is the non-contiguous multi-segment model.


So let’s say if you know the max size of SGA of any database on the server stays below 2GB, you can set shmmax to 2 GB. But say if you have SGA sizes for different databases spread between 512MB to 5GB, then set shmmax to 5Gigs and so on.



Half the size of physical memory in bytes



SHMMNI: parameter recommended as 4096.


SHMALL: parameter recommended as %40 size of physical memory in pages.


Display Kernel Parameter Values for Red-hat Linux (RHEL 9)

 

Command to see Kernel Parameter Values 

ParameterCommand
semmslsemmnssemopm, and semmni# /sbin/sysctl -a | grep sem

This command displays the value of the semaphore parameters in the order listed.

shmallshmmax, and shmmni# /sbin/sysctl -a | grep shm

This command displays the details of the shared memory segment sizes.

file-max# /sbin/sysctl -a | grep file-max

This command displays the maximum number of file handles.

ip_local_port_range# /sbin/sysctl -a | grep ip_local_port_range

This command displays a range of port numbers.

rmem_default# /sbin/sysctl -a | grep rmem_default
rmem_max# /sbin/sysctl -a | grep rmem_max
wmem_default# /sbin/sysctl -a | grep wmem_default
wmem_max# /sbin/sysctl -a | grep wmem_max
aio-max-nr# /sbin/sysctl -a | grep aio-max-nr

Minimum Kernel Parameter Settings for Oracle Database 19c Installation - Redhat Linux

 

For Oracle Database kernel parameter and shell limit values


ParameterValueFile

semmsl

semmns

semopm

semmni

250

32000

100

128

/proc/sys/kernel/sem
shmall

Greater than or equal to the value of shmmax, in pages.

/proc/sys/kernel/shmall
shmmax

Half the size of physical memory in bytes

See My Oracle Support Note 567506.1 for additional information about configuring shmmax.

/proc/sys/kernel/shmmax
shmmni

4096

/proc/sys/kernel/shmmni
panic_on_oops

1

/proc/sys/kernel/panic_on_oops
file-max

6815744

/proc/sys/fs/file-max
aio-max-nr

1048576

Note: This value limits concurrent outstanding requests and should be set to avoid I/O subsystem failures.

/proc/sys/fs/aio-max-nr
ip_local_port_range

Minimum: 9000

Maximum: 65500

/proc/sys/net/ipv4/ip_local_port_range
rmem_default

262144

/proc/sys/net/core/rmem_default
rmem_max

4194304

/proc/sys/net/core/rmem_max
wmem_default

262144

/proc/sys/net/core/wmem_default
wmem_max

1048576

/proc/sys/net/core/wmem_max

Thursday, March 7, 2024

How to Initiate the AWS Oracle RDS Data Guard switchover using the AWS CLI

Switch primary to read replica (standby ) and vice-versa


AWS CLI :

aws rds switchover-read-replica --db-instance-identifier ora-orcl-demo2 --region us-west-2



aws rds switchover-read-replica --db-instance-identifier ora-orcl-demo1  --region us-east-1


aws rds describe-db-instances --db-instance-identifier ora-orcl-demo1 


AWS Link 

https://aws.amazon.com/blogs/database/managed-oracle-data-guard-switchover-with-amazon-rds-for-oracle/