MySQL的Linux环境设置

关闭selinux

查看selinux状态:

[root@betacat selinux]# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          disabled
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      28

在配置文件中设置关闭selinux:

vi /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

SELINUX=enforcing改成SELINUX=disabled

系统IO调度模式改为deadline

查看当前模式:

[root@betacat ~]# dmesg | grep -i scheduler
[    0.334857] io scheduler noop registered
[    0.334860] io scheduler deadline registered
[    0.334899] io scheduler cfq registered (default)

如果默认已经是deadline就不需要改。
修改:

[root@betacat ~]# grubby --update-kernel=ALL --args="elevator=deadline"

重启系统

上面两点都是需要重启系统后才生效的:

[root@betacat ~]# reboot

设备swap分区大小

查看:

[root@betacat ~]# cat /proc/sys/vm/swappiness
20
[root@betacat ~]# sysctl -a | grep swap
sysctl: reading key "net.ipv6.conf.all.stable_secret"
sysctl: reading key "net.ipv6.conf.default.stable_secret"
sysctl: reading key "net.ipv6.conf.ens33.stable_secret"
sysctl: reading key "net.ipv6.conf.lo.stable_secret"
vm.swappiness = 20

修改:

[root@betacat ~]# vi /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
vm.swappiness=30

修改操作系统限制

查看:

[root@betacat ~]# ulimit -a 
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 7215
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024  ###<----单个进程最多可以打开1024个文件
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 7215   ###<---最多可以打开的进程数
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

修改系统的软硬限制:

[root@betacat ~]# vi /etc/security/limits.conf

加入以下内容,然后重启系统:

#
#<domain>      <type>  <item>         <value>
#

#*               soft    core            0
#*               hard    rss             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#@student        -       maxlogins       4

*        soft    nproc           65535
*        hard    nproc           65535
*        soft    nofile          65535
*        hard    nofile          65535

# End of file

煲煲菜
1.5k 声望155 粉丝

世上本没有bug,坑的人多了,也便成了bug