OceanBase 初探学习历程之二——操作系统参数最佳实践

        本文章分享OB操作系统参数最佳实践值,相关参数部分来自PK项目得知,仅供参考,实际参数设置仍需结合现有设备条件及业务系统特点是否有必要如此设置,但我任务大部分场景均可用(仅本人个人观点)。

1、磁盘配置

[root@ob2 ~]# cat /etc/fstab 
#
# /etc/fstab
# Created by anaconda on Thu Aug 18 09:03:09 2022
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/uos-root    /                       ext4    defaults        1 1
UUID=ada6bb64-387c-4526-b525-73f897c9ceba /boot                   ext4    defaults        1 2
UUID=0493-3126          /boot/efi               vfat    umask=0077,shortname=winnt 0 2
/dev/mapper/uos-home    /home                   ext4    defaults        1 2
/dev/vgob/log    /data/log1    ext4    defaults,noatime,nodiratime,nodelalloc,barrier=0  0 0
/dev/vgob/data    /data/1   ext4    defaults,noatime,nodiratime,nodelalloc,barrier=0  0 0
/dev/vgob/admin    /home/admin   ext4    defaults,noatime,nodiratime,nodelalloc,barrier=0  0 0

2、文件限制配置

[root@ob2 ~]# more /etc/security/limits.d/oceanbase_limits.conf
*   soft    nofile  655360
*   hard    nofile  655360
*   soft    nproc   655360
*   hard    nproc   655360
*   hard    core    unlimited
*   soft    core    unlimited
*   hard    stack   10240
*   soft    stack   10240
*   hard    cpu     unlimited
*   soft    cpu     unlimited
root   soft    nofile  655360
root   hard    nofile  655360
root   soft    nproc   655360
root   hard    nproc   655360
root   hard    core    unlimited
root   soft    core    unlimited
root   hard    stack   10240
root   soft    stack   10240
root   hard    cpu     unlimited
root   soft    cpu     unlimited

3、SWAP设置

[root@ob2 ~]# free -g
              total        used        free      shared  buff/cache   available
Mem:            381         340           0           0          40          38
Swap:             0           0           0

4、selinux设置

[root@ob2 ~]# sestatus 
SELinux status:                 disabled

5、内核参数配置

[root@ob2 ~]# cat /etc/sysctl.conf 
kernel.sem = 4096 4194304 32768 1024

vm.dirty_ratio = 10
vm.dirty_background_ratio = 5
vm.vfs_cache_pressure = 50
vm.swappiness = 1
net.ipv4.ip_local_port_range = 3500 65535
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 262144
net.ipv4.tcp_wmem = 262144 262144 4194304
net.ipv4.tcp_rmem = 4194304 4194304 6291456
vm.nr_hugepages = 384
####################################################
#  for oceanbase
net.core.somaxconn = 2048
net.core.netdev_max_backlog = 10000
net.core.rmem_default = 16777216
net.core.wmem_default = 16777216
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216

net.ipv4.ip_local_port_range = 3500 65535
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.tcp_syncookies = 0
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_slow_start_after_idle=0
net.ipv4.ip_local_reserved_ports = 62881-63881

vm.swappiness = 0
kernel.core_pattern = /data/1/core-%e-%p-%t
vm.min_free_kbytes = 2097152
vm.overcommit_memory = 0

fs.aio-max-nr=1048576
vm.max_map_count=655360
vm.nr_hugepages = 0

6、登录设置

[root@ob2 ~]# cat  /etc/pam.d/login
#%PAM-1.0
auth       substack     system-auth
auth       include      postlogin
account    required     pam_nologin.so
account    include      system-auth
password   include      system-auth
# pam_selinux.so close should be the first session rule
session    required     pam_selinux.so close
session    required     pam_loginuid.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session    required     pam_selinux.so open
session    required     pam_namespace.so
session    optional     pam_keyinit.so force revoke
session    include      system-auth
session    include      postlogin
-session   optional     pam_ck_connector.so

session  required  /lib64/security/pam_limits.so
session  required  pam_limits.so

7、透明大页numa设置

[root@ob2 ~]# cat /etc/default/grub 
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=false
GRUB_TERMINAL_OUTPUT="console"
GRUB_BACKGROUND="/boot/efi/EFI/UnionTech/themes/deepin/background.jpg"
GRUB_THEME="/boot/efi/EFI/UnionTech/themes/deepin/theme.txt"
GRUB_GFXMODE=1152x864,auto
DEEPIN_GFXMODE_NOT_SUPPORTED=2560x1600
GRUB_TERMINAL=gfxterm
LANG=C
GRUB_CMDLINE_LINUX="rd.lvm.lv=uos/root rd.lvm.lv=uos/swap video=VGA-1:640x480-32@60me rhgb console=tty0 crashkernel=1024M,high smmu.bypassdev=0x1000:0x17 smmu.bypassdev=0x1000:0x15 video=efifb:off numa=on"
GRUB_DISABLE_RECOVERY="false"


[admin@ob2 ~]$ cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]

8、I/O调度模式

BOOT_IMAGE=/vmlinuz-4.19.90-2201.4.0.0135.up1.uel20.aarch64 root=/dev/mapper/uos-root ro rd.lvm.lv=uos/root rd.lvm.lv=uos/swap video=VGA-1:640x480-32@60me rhgb console=tty0 crashkernel=1024M,high smmu.bypassdev=0x1000:0x17 smmu.bypassdev=0x1000:0x15 video=efifb:off numa=on

[root@ob2 ~]# cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-4.19.90-2201.4.0.0135.up1.uel20.aarch64 root=/dev/mapper/uos-root ro rd.lvm.lv=uos/root rd.lvm.lv=uos/swap video=VGA-1:640x480-32@60me rhgb console=tty0 crashkernel=1024M,high smmu.bypassdev=0x1000:0x17 smmu.bypassdev=0x1000:0x15 video=efifb:off numa=on
[root@ob2 ~]# cat /sys/block/nvme1n1/queue/scheduler 
[none] mq-deadline kyber bfq 

9、挂载点设置

root@ob2 ~]# lsblk
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda            8:0    0 558.4G  0 disk 
├─sda1         8:1    0     1G  0 part /boot/efi
├─sda2         8:2    0     1G  0 part /boot
└─sda3         8:3    0 556.4G  0 part 
  ├─uos-root 253:0    0    70G  0 lvm  /
  ├─uos-swap 253:1    0     4G  0 lvm  
  └─uos-home 253:5    0 482.4G  0 lvm  /home
nvme3n1      259:0    0   2.9T  0 disk 
├─vgob-log   253:2    0     2T  0 lvm  /data/log1
├─vgob-data  253:3    0   7.9T  0 lvm  /data/1
└─vgob-admin 253:4    0   500G  0 lvm  /home/admin
nvme0n1      259:1    0   2.9T  0 disk 
├─vgob-log   253:2    0     2T  0 lvm  /data/log1
├─vgob-data  253:3    0   7.9T  0 lvm  /data/1
└─vgob-admin 253:4    0   500G  0 lvm  /home/admin
nvme1n1      259:2    0   2.9T  0 disk 
├─vgob-log   253:2    0     2T  0 lvm  /data/log1
├─vgob-data  253:3    0   7.9T  0 lvm  /data/1
└─vgob-admin 253:4    0   500G  0 lvm  /home/admin
nvme2n1      259:3    0   2.9T  0 disk 
├─vgob-log   253:2    0     2T  0 lvm  /data/log1
├─vgob-data  253:3    0   7.9T  0 lvm  /data/1
└─vgob-admin 253:4    0   500G  0 lvm  /home/admin

10、用户变量配置

[admin@ob2 ~]$ cat .bash_profile 

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/admin/oceanbase/lib"
[admin@ob2 ~]$ id admin
uid=500(admin) gid=500(admin) groups=500(admin)

11、服务器性能模式

[admin@ob2 ~]$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor 
performance
performance
performance
performance
performance
performance
performance
performance
performance
performance
performance

12、络配置网卡的接受队列和发送队列

[admin@ob2 ~]$ cat /proc/sys/net/core/netdev_max_backlog 
10000

当然还有硬件层面一些提升的空间,这里暂时先不分享,下一期再分享,欢迎大家关注我,一起学习。

(若重要,处处都是办法;若不重要,比比皆是理由。)

你可能感兴趣的:(oceanbase,学习)