登录
首页 >  数据库 >  MySQL

MySQL的Linux环境设置

来源:SegmentFault

时间:2023-02-25 09:45:39 207浏览 收藏

怎么入门数据库编程?需要学习哪些知识点?这是新手们刚接触编程时常见的问题;下面golang学习网就来给大家整理分享一些知识点,希望能够给初学者一些帮助。本篇文章就来介绍《MySQL的Linux环境设置》,涉及到MySQL,有需要的可以收藏一下

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  ###

修改系统的软硬限制:

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

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

#
#
#

#*               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

以上就是本文的全部内容了,是否有顺利帮助你解决问题?若是能给你带来学习上的帮助,请大家多多支持golang学习网!更多关于数据库的相关知识,也可关注golang学习网公众号。

声明:本文转载于:SegmentFault 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>
评论列表