| 用户限制参数(mysql可以不设置以下配置) vim    /etc/security/limits.conf     * soft nproc 65535     * hard nproc 65535     * soft nofile 65535     * hard nofile 65535 
 5.6 应用优化业务应用和数据库应用独立, 防火墙:iptables、selinux等其他无用服务(关闭): chkconfig --level 23456 acpid off    chkconfig --level 23456 anacron off    chkconfig --level 23456 autofs off    chkconfig --level 23456 avahi-daemon off    chkconfig --level 23456 bluetooth off    chkconfig --level 23456 cups off    chkconfig --level 23456 firstboot off    chkconfig --level 23456 haldaemon off    chkconfig --level 23456 hplip off    chkconfig --level 23456 ip6tables off    chkconfig --level 23456 iptables  off    chkconfig --level 23456 isdn off    chkconfig --level 23456 pcscd off    chkconfig --level 23456 sendmail  off    chkconfig --level 23456 yum-updatesd  off 
 安装图形界面的服务器不要启动图形界面 runlevel 3 另外,思考将来我们的业务是否真的需要MySQL,还是使用其他种类的数据库。用数据库的最高境界就是不用数据库。 6 数据库优化
SQL优化方向: 架构优化方向: 高可用架构、高性能架构、分库分表 6.1 数据库参数优化调整: 实例整体(高级优化,扩展): thread_concurrency       # 并发线程数量个数     sort_buffer_size         # 排序缓存     read_buffer_size         # 顺序读取缓存     read_rnd_buffer_size     # 随机读取缓存     key_buffer_size          # 索引缓存     thread_cache_size        # (1G—>8, 2G—>16, 3G—>32, >3G—>64) 
 连接层(基础优化) 设置合理的连接客户和连接方式 max_connections           # 最大连接数,看交易笔数设置     max_connect_errors        # 最大错误连接数,能大则大     connect_timeout           # 连接超时     max_user_connections      # 最大用户连接数     skip-name-resolve         # 跳过域名解析     wait_timeout              # 等待超时     back_log                  # 可以在堆栈中的连接数量 
 SQL层(基础优化) query_cache_size:查询缓存   >>>  OLAP类型数据库,需要重点加大此内存缓存,但是一般不会超过GB 对于经常被修改的数据,缓存会立马失效。我们可以实用内存数据库(redis、memecache),替代他的功能。 
 6.2 存储引擎层(innodb基础优化参数)default-storage-engine innodb_buffer_pool_size       #没有固定大小,50%测试值,看看情况再微调。但是尽量设置不要超过物理内存70% innodb_file_per_table=(1,0) innodb_flush_log_at_trx_commit=(0,1,2) # 1是最安全的,0是性能最高,2折中 binlog_sync Innodb_flush_method=(O_DIRECT, fdatasync) innodb_log_buffer_size        # 100M以下 innodb_log_file_size          # 100M 以下 innodb_log_files_in_group     # 5个成员以下,一般2-3个够用(iblogfile0-N) innodb_max_dirty_pages_pct   # 达到百分之75的时候刷写 内存脏页到磁盘。log_bin max_binlog_cache_size         # 可以不设置 max_binlog_size               # 可以不设置 innodb_additional_mem_pool_size    #小于2G内存的机器,推荐值是20M。32G内存以上100M 
 
 (编辑:南平站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |