Mysql5.7 基础

硬件BISO设置

服务器出厂时,BIOS 默认达到了性能和能耗之间的良好平衡,以适应一般环境,但是在高负载环境中,就需要对服务器进行优化不需要节能模式(720xd 机器load到20+就尼玛自己hang了),以获得最大的吞吐量或最低的延迟
以下是dell R710的配置调整
* 可测试自身的环境,以确定 Turbo 模式是否有利于您的负载。
 R710 调整最大性能模式:F2进入BIOS-powerManagement-Maximun performance
dell r720 在实际使用中发现,如果不修改为最大性能模式,屏幕上会报出如下信息,服务器无法达到最大性能
May 29 15:43:37 file180 kernel: CPU4: Package power limit notification (totalevents = 1437869)
May 29 15:43:37 file180 kernel: CPU10: Package power limit notification (totalevents = 1437849)
May 29 15:43:37 file180 kernel: CPU11: Package power limit notification (totalevents = 1437913)
bios-system profile 中选择performance项就可以了
由于现场都是生产服务器,不能重启所以以上内容来自(http://hxl2009.blog.51cto.com/779549/1660507/)

RAID 卡设置(PCI-E除外)

RAID 10 (推荐):RAID10也被称为镜象阵列条带。像RAID0一样,数据跨磁盘抽取;像RAID1一样,每个磁盘都有一个镜象磁盘, 所以RAID 10的另一种会说法是 RAID 1+0。RAID10提供100%的数据冗余,支持更大的卷尺寸,但价格也相对较高。对大多数只要求具有冗余度而不必考虑价格的应用来说,RAID10提供最好的性能。使用RAID10,可以获得更好的可靠性,因为即使两个物理驱动器发生故障,每个阵列中都有一个,数据仍然可以得到保护。RAID10需要4 + 2*N 个磁盘驱动器(N >=0), 而且只能使用其中一半或更小的磁盘用量, 例如 4 个 250G 的硬盘使用RAID10 阵列, 实际容量是 500G

WB(推荐):写道缓存里就返回速度会有很大的提升,注意阵列卡电池需要有电(BIOS 设置是wb  force)

WT:直接写道硬盘上,返回值会相对慢。

系统环境检查

1.关闭numa

编辑grub配置文件在当前运行内核后添加numa=off

root@wxl ~]# vim /etc/grub.conf 

[root@wxl ~]# vim /etc/grub.conf

default=0
timeout=5
splashimage=(hd0,4)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (3.10.107-1.el6.elrepo.x86_64)
root (hd0,4)
kernel /boot/vmlinuz-3.10.107-1.el6.elrepo.x86_64 ro root=UUID=95b6c59e-dd38-4fcd-81b3-9fdb4b663f97 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=128M KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet numa=off
View Code

2.限制设置/etc/security/limits.conf 

1、vim /etc/profile
增加 ulimit -n 65535
进程数限制  ulimit –u   不同版本不一样
source /etc/profile 重新启动就不需要运行这个命令了。 2、修改/etc/security/limits.conf 增加 * hard nofile 65535
*      soft     nofile     65535

3.网络优化

增加本地端口,以应对大量连接
echo '1024    65000' >/proc/sys/net/ipv4/ip_local_port_range    ---表示端口的范围,为指定的内容
增加队列的连接数
echo '8192' > /proc/sys/net/ipv4/tcp_max_syn_backlog
设置mysql连接请求队列中允许存放的最大请求数
back_log = 150
设置连接超时时间
echo60' >/proc/sys/net/ipv4/tcp_fin_timeou

4.Swap

推荐禁止swap使用 或者分给4G

/proc/sys/vm/swappiness的内容改成0(临时),/etc/sysctl.conf上添加vm.swappiness=0(永久)

5.IO调度

sas:echo dealine >/sys/block/{DEV-NAME}/queue/scheduler
ssd:echo noop>/sys/block/{DEV-NAME}/queue/scheduler
文件目录/data 文件系统:xfs

6.selinux &防火墙(iptales or  firewalld)

禁掉

[root@wxl ~]# setenforce 0 //临时禁止selinux
[root@wxl ~]# vim /etc/selinux/config 
SELINUX=disabled //永久关闭
SELINUXTYPE=targeted
防火墙
[root@wxl ~]# /etc/init.d/iptables  stop ;chkconfig iptables off /6系列一下
[root@wxl ~]# systemctl stop firewalld ;systemctl disable firewalld/7系列

 MySQL启动和关闭(二进制方式

系统启动:

[root@wxl ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld 
[root@wxl ~]# /etc/init.d/mysqld strat|stop|restrat

手工启动方式:

[root@wxl ~]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &
[1] 5311
[root@wxl ~]# 2017-09-07T01:08:25.274672Z mysqld_safe Logging to '/data/mysql/mysql3306/data/error.log'.
2017-09-07T01:08:25.333368Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/mysql3306/data
[root@wxl ~]# mysql -pwuxinglai
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
.......
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
root@localhost [(none)]>quit
mysqld 简单的mysqlsever启动进程
mysqld_safe 守护mysql server 进程
关闭的两种方式
[root@wxl ~]# /etc/init.d/mysqld   stop
Shutting down MySQL..2017-09-07T01:10:15.507244Z mysqld_safe mysqld from pid file /data/mysql/mysql3306/data/mysql.pid ended
                                                           [  OK  ]
[1]+  Done                    /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf
[root@wxl ~]# /usr/local/mysql/bin/mysqld_safe 或者 mysqld --defaults-file=/etc/my.cnf &
[1] 6312
[root@wxl ~]# 2017-09-07T01:10:33.155873Z mysqld_safe Logging to '/data/mysql/mysql3306/data/error.log'.
2017-09-07T01:10:33.239449Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/mysql3306/data
[root@wxl ~]# 
[root@wxl ~]# 
[root@wxl ~]# 
[root@wxl ~]# mysqladmin -S /tmp/mysql3306.sock -pwuxinglai shutdown
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
[root@wxl ~]# 2017-09-07T01:10:59.393191Z mysqld_safe mysqld from pid file /data/mysql/mysql3306/data/mysql.pid ended

[1]+  Done                    /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf

 账号安全加固

root@localhost [mysql]>delete from mysql.user where user!='root' or host!='localhost';
root@localhost [mysql]>truncate mysql.db;

 

posted @ 2017-09-07 18:57  91King  阅读(90)  评论(0)    收藏  举报