灵当CRM

 找回密码
 立即注册
查看: 5501|回复: 0

Linux系统内核优化以及mysql优化后的参考配置文件

[复制链接]

1660

主题

1709

帖子

5万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
59054
发表于 2017-9-7 11:08:41 | 显示全部楼层 |阅读模式
Linux系统内核优化以及mysql优化后的参考配置文件


# 优化服务器配置

1.内核参数

vi /etc/sysctl.conf

net.ipv4.tcp_syncookies = 1

net.ipv4.tcp_tw_reuse = 1

net.ipv4.tcp_tw_recycle = 1

net.ipv4.ip_local_port_range = 1024 65000

net.ipv4.tcp_max_syn_backlog = 8192

net.ipv4.tcp_max_tw_buckets = 5000

net.ipv4.tcp_max_syn_backlog = 65536

net.core.netdev_max_backlog =  32768

net.core.somaxconn = 32768

net.core.wmem_default = 8388608

net.core.rmem_default = 8388608

net.core.rmem_max = 16777216

net.core.wmem_max = 16777216

net.ipv4.tcp_timestamps = 0

net.ipv4.tcp_synack_retries = 2

net.ipv4.tcp_syn_retries = 2

net.ipv4.tcp_tw_recycle = 1

net.ipv4.tcp_tw_reuse = 1

net.ipv4.tcp_mem = 94500000 915000000 927000000

net.ipv4.tcp_max_orphans = 3276800

/sbin/sysctl -p

/sbin/sysctl -w net.ipv4.route.flush=1

2.修改下ulimit,添加在后面

vi /etc/security/limits.conf

*        soft   nproc  65535

*        hard   nproc  65535

*        soft   nofile  65535

*        hard   nofile  65535

vi /etc/security/limits.d/90-nproc.conf(修改下)

*          soft    nproc    65535

然后记得重启下服务器

reboot

#修改mysql配置文件my.cnf

===============================================================================================

[mysqld]

basedir = /usr/local/mysql

datadir = /home/mysql/data

port = 3306

server_id =1

socket = /tmp/mysql.sock

#innodb

user=mysql

innodb_buffer_pool_size=6G

innodb_log_file_size=4G

innodb_log_buffer_size = 8M

innodb_flush_log_at_trx_commit=2

innodb_file_per_table=1

innodb_file_io_threads=4

innodb_flush_method=O_DIRECT

innodb_io_capacity=2000

innodb_io_capacity_max=6000

innodb_lru_scan_depth=2000

innodb_thread_concurrency = 0

innodb_additional_mem_pool_size=16M

innodb_autoinc_lock_mode = 2

# Binary log/replication

# log-bin

# sync_binlog=1

# sync_relay_log=1

# relay-log-info-repository=TABLE

# master-info-repository=TABLE

# expire_logs_days=15

# binlog_format=ROW

# transaction-isolation=READ-COMMITTED
  
#cache

tmp_table_size=512M

character-set-server=utf8

collation-server=utf8_general_ci

skip-external-locking

back_log=1024

key_buffer_size=1024M

thread_stack=256k

read_buffer_size=8M

thread_cache_size=64

query_cache_size=128M

max_heap_table_size=256M

query_cache_type=1

binlog_cache_size = 2M

table_open_cache=128

thread_cache=1024

thread_concurrency=8

wait_timeout=30

join_buffer_size = 1024M

sort_buffer_size = 8M

read_rnd_buffer_size = 8M

#connect

max-connect-errors=100000

max-connections=1000

explicit_defaults_for_timestamp=true

sql-mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

lower_case_table_names=1

===============================================================================



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

灵当CRM

GMT+8, 2024-3-29 06:09 , Processed in 0.050454 second(s), 17 queries .

Powered by Discuz! X3.4

Copyright © 2008-2022, Tencent Cloud.

沪ICP备08110973号-2

快速回复 返回顶部 返回列表