Chinaunix

标题: 优化Linux配置运行MySQL [打印本页]

作者: oracle狂热分子    时间: 2013-11-30 22:50
标题: 优化Linux配置运行MySQL
                                       优化Linux配置运行MySQL


       根据一项调查显示,目前大约有90%的MySQL服务器都是运行在Linux平台上的.Windows平台不到5%.
除非有很好的理由选择其他的平台,最好还是选择linux平台.

      主要考虑的几个因素有:支持性,稳定性,硬件的支持,市场占有率.主流的有:Redhat,Oracle,CentOS,Debian.

      一般的linux默认配置都能很好的运行mysql,对于几个重要方面还是需要做适当的调整

1,关闭SELINUX和iptables
      
[root@d2 ~]# cat /etc/sysconfig/selinux
# 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 - SELinux is fully disabled.
SELINUX=disabled   --改为disable

[root@d2 ~]# getenforce
Disabled

[root@d2 vm]# service iptables status   
Firewall is stopped.

2,修改内存参数

vm.swappiness=0       --减少swap的活动频繁程度
vm.dirty_ratio=5      --定义应用程序dirty page达到一定程度时候写入磁盘,建议设为5-10


3, 网络方面增加buffer 大小和网络队列

net.core.rmem_max=16777216
net.core.wmem_max=16777216
net.ipv4.tcp_rmem=4096 87380 16777216
net.ipv4.tcp_wmem=4096 65536 16777216
net.ipv4.ip_local_port_range="1024 65535"

[root@asm ~]# ifconfig eth0 txqueuelen 1000   --修改网络队列为1000

4,存储和文件子系统

msyql服务器尽量使用单独的分区或LUN,磁盘类型尽量选择RAID10

磁盘的调度选择deadline

title Red Hat Enterprise Linux Server (2.6.18-194.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet elevator=deadline
        initrd /initrd-2.6.18-194.el5.img

[root@d2 queue]# cat scheduler
noop anticipatory [deadline] cfq

增加请求队列长度

[root@d2 queue]# echo 100000 /sys/block/sda/queue/nr_requests   --假设硬盘是sda
100000 /sys/block/sda/queue/nr_requests






欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2