已索引
关于修复脚本
完全可以使用修改脚本来设置资源限制和内核参数。
资源限制
设置资源限制时,可以参考如下设置:
* soft nofile 65536
* hard nofile 65536
* soft nproc 16384
* hard nproc 16384
* soft stack 32768
* hard stack 32768
* soft memlock unlimited
* hard memlock unlimited
* soft core unlimited
* hard core unlimited
关于 shmmax、shmall、shmmni 共享内存
shmmax:Maximum size in bytes for a shared memory segment.
Half the size of physical memory in bytes. 文档567506.1可查看更详细说明 (19C 安装手册最小值要求)
shmall:The total system wide amount of shared memory, in pages.
Greater than or equal to the value of shmmax, in pages. (19C 安装手册最小值要求)
shmmni:System wide maximum number of shared memory segments.
4096 (19C 安装手册最小值要求)
关于 kernel.sem 信号量
semaphores是信号令,可以理解为十字路口的交警,谁可走,谁不可以走。
它用来协调对共享资源的访问。信号令就类似于举旗子,举个红旗,进程A走,举个绿旗,进程B走。
kernel.sem = SEMMSL SEMMNS SEMOPM SEMMNI
kernel.sem = 250 32000 100 128 (19C 安装手册最小值要求)
kernel.sem = 500 300000 500 6000
第1个参数表示每个信号令数组中的信号令个数(max semaphores per array)。
第2个参数表示整个系统最多有多少个信号令存在(max semaphores system wide)。
第3个参数是每个信号令可以发出的system call有几个(max ops per semop call)。
第4个参数表示信号令数组的最大数(max number of arrays)。
下面一段是关于一点关于信号量的系统参数 kernel.sem 的解释:
The kernel parameter sem consists of 4 tokens, SEMMSL, SEMMNS, SEMOPM and SEMMNI.
SEMMNS is the result of SEMMSL multiplied by SEMMNI.
The database manager requires that the number of arrays (SEMMNI) be increased as necessary.
Typically, SEMMNI should be twice the maximum number of connections allowed (MAXAGENTS) multiplied by the number of logical partitions on the database server computer plus the number of local application connections on the database server computer.
系统内核包括四个标记参数,SEMMSL, SEMMNS, SEMOPM 和 SEMMNI。SEMMNS应该是SEMMSL 乘以 SEMMNI的结果。数据库管理程序需要SEMMNI根据需要进行相应的增加。通常说来,SEMMNI 应该是 2(服务器允许最大连接数) (数据库服务器逻辑分区数)+ (数据库允许最大本地应用连接数)。
核心参数-使用版
# Only for Redis. besides, disable transparant hugepages.
# vm.overcommit_memory = 1
# Swap opportunity
vm.swappiness = 20
# Defines the maximum size in bytes of a single message queue.
kernel.msgmnb = 65536
# Defines the maximum allowable size in bytes of any single message in a message queue.
kernel.msgmax = 65536
# The length of time an orphaned connecton (no longer referenced by any application)
# will remain in the FIN_WAIT_2 state before it is aborted at the local end.
# Default value is 60 seconds both in RHEL6 and RHEL7
net.ipv4.tcp_fin_timeout = 30
# How often TCP sends out keepalive messages when keepalive is enabled.
# Default value is 7200 seconds both in RHEL6 and RHEL7
net.ipv4.tcp_keepalive_time = 1200
# This is to prevent against the common 'SYN flood attack'
# Default value is 0 in RHEL6, 1 in RHEL7
net.ipv4.tcp_syncookies = 1
# Maximal number of remembered connection request, which have not received an acknowledgment from connecting client.
net.ipv4.tcp_max_syn_backlog = 8192
# Limit of socket listen() backlog, known in userspace as SOMAXCONN.
net.core.somaxconn = 10240
# ------------------------------------------------- Oracle DB Requirement Begin ----------------------------------------------------------------------------------
# Oracle 11gR2 和 19c 的最小值建议都是 250 32000 100 128。
# There is no fixed script for APP Server。
kernel.sem = 500 300000 500 6000
# 这几个值对于应用程序使用默认值即可,Oracle 由修复脚本决定是否调整
# kernel.shmall, kernel.shmmax, kernel.shmmni
# 19 要求设置为 1,11gR2 没有此要求,在 RHEL6 和 RHEL7 中默认值都是 1
kernel.panic_on_oops = 1
# Determines the maximum number of file handles for the entire system.
# There is no fixed script for APP Server。
fs.file-max = 6815744
# aio-max-nr
# Defines the maximum allowed number of events in all active asynchronous input/output contexts.
# There is no fixed script for APP Server。
fs.aio-max-nr = 1048576
# net.ipv4.ip_local_port_range
# Defines the local port range that is used by TCP and UDP to choose the local port.
# If possible, it is better these numbers have different parity. (one even and one odd values)
# RHEL6 的默认值是 32768 61000, RHEL7 的默认值是 32768 60999
# Oracle 11gR2 和 19c 的最小值建议都是 9000 65500
net.ipv4.ip_local_port_range = 9000 65500
# net.core.rmem_default
# The default setting of the socket receive buffer in bytes
# Oracle 11gR2 和 19c 的最小值建议都是 262144, RHEL6 和 RHEL7 的默认值一般都比这个小
# There is no fixed script for APP Server。
net.core.rmem_default = 262144
# net.core.rmem_max
# The maximum receive socket bufer size in bytes
# Oracle 11gR2 和 19c 的最小值建议都是 4194304, RHEL6 和 RHEL7 的默认值一般都比这个小
# There is no fixed script for APP Server。
net.core.rmem_max = 4194304
# The default setting (in bytes) of the socket send buffer.
# Oracle 11gR2 和 19c 的最小值建议都是 262144, RHEL6 和 RHEL7 的默认值一般都比这个小
# There is no fixed script for APP Server。
net.core.wmem_default = 262144
# The maximum send socket buffer size in bytes.
# Oracle 11gR2 和 19c 的最小值建议都是 4194304, RHEL6 和 RHEL7 的默认值一般都比这个小
# There is no fixed script for APP Server。
net.core.wmem_max = 1048576
# ------------------------------------------------- Oracle DB Requirement End ----------------------------------------------------------------------------------
核心参数-解释版
# Only for Redis,Redis 建议把这个值设置为 1,是为了防止让 fork 操作能够在低内存下也执行成功
# vm.overcommit_memory = 1
# Swap opportunity
vm.swappiness = 20
# Defines the maximum size in bytes of a single message queue.
# Default value is 16384 seconds both in RHEL6 and RHEL7
# DB2 数据库的建议值及 core-app 的值为 65536
kernel.msgmnb = 65536
# Defines the maximum allowable size in bytes of any single message in a message queue.
# This value must not exceed the size of the queue (msgmnb)
# Default value is 8192 seconds both in RHEL6 and RHEL7
# DB2 数据库的建议值及 core-app 的值为 65536
kernel.msgmax = 65536
# Defines the maximum number of message queue identifiers, and therefore the maximum number of queues.
# DB2 数据库的建议值是 16384,但实际上 RHEL6 和 RHEL7 的默认值都比 16384 大
# kernel.msgmni = 16384
# The length of time an orphaned connecton (no longer referenced by any application)
# will remain in the FIN_WAIT_2 state before it is aborted at the local end.
# Default value is 60 seconds both in RHEL6 and RHEL7
net.ipv4.tcp_fin_timeout = 30
# How often TCP sends out keepalive messages when keepalive is enabled.
# Default value is 7200 seconds both in RHEL6 and RHEL7
net.ipv4.tcp_keepalive_time = 1200
# This is to prevent against the common 'SYN flood attack'
# Default value is 0 in RHEL6, 1 in RHEL7
net.ipv4.tcp_syncookies = 1
# Allow to reuse TIME-WAIT sockets for new connections when it is safe from protocol viewpoint.
# It should not be changed without advice/request of technical experts.
# Default value is 0 both in RHEL6 and RHEL7
# net.ipv4.tcp_tw_reuse = 1
# Enable fast recycling TIME-WAIT sockets.
# It should not be changed without advice/request of technical experts.
# Default value is 0 both in RHEL6 and RHEL7
# net.ipv4.tcp_tw_recycle = 1
# Maximal number of remembered connection request, which have not received an acknowledgment from connecting client.
# 所能接受SYN同步包的最大客户端数量(即SYN队列的最大长度),即半连接上限
# 对于低内存机器,该参数的最小值是128,该值会根据机器内存大小自动设置,但通常比较保守,需要调高
net.ipv4.tcp_max_syn_backlog = 8192
# Limit of socket listen() backlog, known in userspace as SOMAXCONN.
# Default value is 128 both in RHEL6 and RHEL7
# 服务端所能ACCEPT即处理数据的最大客户端数量,即完成连接上限,该值比较保守,需要调高
net.core.somaxconn = 10240
#rp_filter - INTEGER
# 0 - No source validation.
# 1 - Strict mode as defined in RFC3704 Strict Reverse Path
# Each incoming packet is tested against the FIB and if the interface
# is not the best reverse path the packet check will fail.
# By default failed packets are discarded.
# 2 - Loose mode as defined in RFC3704 Loose Reverse Path
# Each incoming packet's source address is also tested against the FIB
# and if the source address is not reachable via any interface
# the packet check will fail.
#
# Current recommended practice in RFC3704 is to enable strict mode
# to prevent IP spoofing from DDos attacks. If using asymmetric routing
# or other complicated routing, then loose mode is recommended.
#
# The max value from conf/{all,interface}/rp_filter is used
# when doing source validation on the {interface}.
#
# Default value is 0. Note that some distributions enable it in startup scripts.
#
# 该参数在 RHEL6 中的默认值为:
# net.ipv4.conf.all.rp_filter = 0
# net.ipv4.conf.default.rp_filter = 0
# net.ipv4.conf.eth0.rp_filter = 0
# net.ipv4.conf.lo.rp_filter = 0
#
# 该参数在 RHEL7 中的默认值为:
# net.ipv4.conf.all.rp_filter = 1
# net.ipv4.conf.default.rp_filter = 1
# net.ipv4.conf.ens192.rp_filter = 1
# net.ipv4.conf.lo.rp_filter = 0
#
# 在容器环境需要进行测试是否设置为 0
# accept_source_route - BOOLEAN
# https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt
# Accept packets with SRR option.
# conf/all/accept_source_route must also be set to TRUE to accept packets
# with SRR option on the interface
# default TRUE (router)
# FALSE (host)
# 在 RHEL7 中 all/default 默认值都是 0,在 RHEL6 中,all 是 0,default 是 1
# ------------------------------------------------- Oracle DB Requirement Begin ----------------------------------------------------------------------------------
# 在 11g 安装手册上有这么一句话:
# If the current value of any parameter is higher than the value
# listed in this table, then do not change the value of that parameter.
#
# 在 19c 安装手册上有这么一句话:
# If the current value for any parameter is greater than the value listed
# in this table, then the Fixup scripts do not change the value of that
# parameter.
# kernel.sem=<SEMMSL> <SEMMNS> <SEMOPM> <SEMMNI>
# SEMMSL: the maximum number of semaphores per semaphore array
# SEMMNS: the maximum number of semaphores allowed
# SEMOPM: the maximum number of allowed operations per semaphore system call
# SEMMNI: the maximum number of semaphore arrays
# SEMMNS is the result of SEMMSL multiplied by SEMMNI
# kernel.sem = 250 32000 32 128 # Default value in both RHEL6 and RHEL7
# kernel.sem = 250 32000 100 128 # Oracle 11gR2 和 19c 的最小值建议都是
# kernel.sem = 250 1024000 32 4096 # DB2 10.1.0
# kernel.sem = 250 128000 32 1024 # ltts-app,不规范,SEMMNS 不等于 EMMSL * SEMMNI
# kernel.sem = 500 300000 500 6000 # SCRCU
# kernel.shmall
# Defines the total amount of shared memory pages that can be used on the system at one time. (RedHat website)
# The total system wide amount of shared memory, in pages (RHCA)
# The SHMALL limit is the maximum allocation of shared memory pages on a system (DB2 website)
# Oracle 11gR2 最小值建议是: 2097152, 19C 是: Greater than or equal to the value of shmmax, in pages.
# kernel.shmmax
# Defines the maximum size (in bytes) of a single shared memory segment allowed by the kernel. (RedHat website)
# Maximum size in bytes for a shared memory segment (RHCA)
# The SHMMAX limit is the maximum size of a shared memory segment on a Linux system (DB2 website)
# Oracle 11gR2, Minimum: 536870912 Maximum: A value that is 1 byte less than the physical memory,Recommended: More than half the physical memory
# Oracle 19C 没有了Minimum 和 Maximum 的建议,只写了: Half the size of physical memory in bytes.
# DB2 10.1.0, It is recommended to set the SHMMAX value to be equal to the amount of physical memory on your system.
# However, the minimum required on x86 systems is 268435456 (256 MB) and for 64-bit systems, it is 1073741824 (1 GB).
# kernel.shmmni
# Defines the system-wide maximum number of shared memory segments. The default value is 4096 on all systems. (RedHat website)
# System wide maximum number of shared memory segments
# RHEL6 和 RHEL7 中的默认值都是 4096
# Oracle 11gR2 和 19c 中,以及 DB2 10.1.0, 最小建议值都是 4096
# Controls the kernel's behaviour when an oops or BUG is encountered.
# 0: try to continue operation
# 1: panic immediately. If the kernel.panic(default value is 0 both in RHEL6 and RHEL7) is also non-zero then the machine will be rebooted.
# 19 要求设置为 1,11gR2 没有此要求,在 RHEL6 和 RHEL7 中默认值都是 1
# kernel.panic_on_oops = 1
# Determines the maximum number of file handles for the entire system. The default value on Red Hat Enterprise Linux 7 is the maximum of either 8192, or one tenth of the free memory pages available at the time the kernel starts. Raising this value can resolve errors caused by a lack of available file handles.
# Oracle 11gR2 和 19c 的最小值建议都是 6815744,RHEL6 和 RHEL7 中的默认值通常都比这个值小
fs.file-max = 6815744
# aio-max-nr
# Defines the maximum allowed number of events in all active asynchronous input/output contexts. The default value is 65536. Modifying this value does not pre-allocate or resize any kernel data structures.
# This value limits concurrent outstanding requests and should be set to avoid I/O subsystem failures. (Oracle installation manual)
# aio-nr shows the current system-wide number of asynchronous io requests. aio-max-nr allows you to change the maximum value aio-nr can grow to.
# Oracle 11gR2 和 19c 的最小值建议都是 1048576
# RHEL6 和 RHEL7 中的默认值都是 65536
fs.aio-max-nr = 1048576
# net.ipv4.ip_local_port_range
# Defines the local port range that is used by TCP and UDP to choose the local port.
# The first number is the first, the second the loast local port number.
# If possible, it is better these numbers have different parity. (one even and one odd values)
# RHEL6 的默认值是 32768 61000, RHEL7 的默认值是 32768 60999
# Oracle 11gR2 和 19c 的最小值建议都是 9000 65500
net.ipv4.ip_local_port_range = 9000 65500
# net.core.rmem_default
# The default setting of the socket receive buffer in bytes
# Oracle 11gR2 和 19c 的最小值建议都是 262144, RHEL6 和 RHEL7 的默认值一般都比这个小
net.core.rmem_default = 262144
# net.core.rmem_max
# The maximum receive socket bufer size in bytes
# Oracle 11gR2 和 19c 的最小值建议都是 4194304, RHEL6 和 RHEL7 的默认值一般都比这个小
net.core.rmem_max = 4194304
# The default setting (in bytes) of the socket send buffer.
# Oracle 11gR2 和 19c 的最小值建议都是 262144, RHEL6 和 RHEL7 的默认值一般都比这个小
net.core.wmem_default = 262144
# The maximum send socket buffer size in bytes.
# Oracle 11gR2 和 19c 的最小值建议都是 4194304, RHEL6 和 RHEL7 的默认值一般都比这个小
net.core.wmem_max = 1048576
# ------------------------------------------------- Oracle DB Requirement End ----------------------------------------------------------------------------------