美女爱找茬:双实例mysql数据库my.cnf的配置参数

doondroar 2014-07-14 09:48:13
目前我云上面的服务器的配置是4个CPU,16G内存,2T的空间;前期日均ip是10~30W,日均pv大概50-150W。
现在搭建了一个双实例的MYSQL5.5.38的服务器,平台是64位的LINUX操作系统,我的my.cnf配置是这样的,不知道是否正确,请有懂的人斧正:

# vi etc/my.cnf
[client]
default-character-set = utf8 #设置客户端的字符编码

[mysqld_multi]
mysqld=/opt/mysql/bin/mysqld_safe
mysqladmin=/opt/mysql/bin/mysqladmin
log=/opt/mysql/log/mysqld_multi.log
user=root

[mysqld1]
port = 3306
socket = /opt/mysql/tmp/mysqld.sock
pid-file = /opt/mysql/run/mysqld.pid
log=/opt/mysql/log/mysqld1.log
datadir = /opt/mysql/data

## These support master - master replication
#auto-increment-increment = 4
#auto-increment-offset = 1 ## Since it is master 1
#log-bin = /opt/mysql/binlogs/bin-log-mysqld1
#log-bin-index = /opt/mysql/binlogs/bin-log-mysqld1.index
#binlog-do-db = ## Leave this blank if you want to control it on slave
#max_binlog_size = 1024M

## This is exlusively for mysqld2
## It is on 3307 with data directory /opt/mysqld/data2
[mysqld2]
port = 3307
socket = /opt/mysql/tmp/mysqld.sock2
pid-file = /opt/mysql/run/mysqld.pid2
log=/opt/mysql/log/mysqld2.log
datadir = /opt/mysql/data2

## These support master - slave replication
log-bin = /opt/mysql/binlogs/bin-log-mysqld2
log-bin-index = /opt/mysql/binlogs/bin-log-mysqld2.index
#binlog-do-db = ## Leave this blank if you want to control it on slave
max_binlog_size = 1024M

[mysqld]
# generic configuration options
port = 3306
basedir = /opt/mysql
datadir = /opt/mysql/data
tmpdir = /opt/mysql/tmp
socket = /opt/mysql/run/mysqld.sock
pid-file = /opt/mysql/run/mysqld.pid
lc-messages-dir = /opt/mysql/share/english

#*** char set ***
character-set-server = utf8 #设置服务器端的字符编码
collation-server = utf8_unicode_ci

#*** network ***
back_log = 512
skip-external-locking
#skip-networking #默认没有开启
max_connections = 3000
max_connect_errors = 30
table_open_cache = 4096
#external-locking #默认没有开启
max_allowed_packet = 32M
max_heap_table_size = 128 M

# *** global cache ***
read_buffer_size = 8M
read_rnd_buffer_size = 64M
sort_buffer_size = 16M
join_buffer_size = 16M

# *** thread ***
thread_cache_size = 16
thread_concurrency = 8
thread_stack = 512K

# *** query cache ***
query_cache_size = 128M
query_cache_limit = 4M

# *** index ***
ft_min_word_len = 8

#memlock #默认没有开启
default-storage-engine = INNODB
transaction_isolation = REPEATABLE-READ

# *** tmp table ***
tmp_table_size = 64M

# *** bin log ***
log-bin=mysql-bin
binlog_cache_size = 4M
binlog_format=mixed
#log_slave_updates #默认没有开启
#log #默认没有开启,此处是查询日志,开启会影响服务器性能
log_warnings #开启警告日志

# *** slow query log ***
slow_query_log
long_query_time = 10

# *** Replication related settings
server-id = 1
#server-id = 2
#master-host = <hostname>
#master-user = <username>
#master-password = <password>
#master-port = <port>
#read_only
#*** MyISAM Specific options
key_buffer_size = 128M
bulk_insert_buffer_size = 256M
myisam_sort_buffer_size = 256M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover

# *** INNODB Specific options ***
#skip-innodb #默认没有开启
innodb_additional_mem_pool_size = 64M
innodb_buffer_pool_size = 6G #注意在32位系统上你每个进程可能被限制在 2-3.5G 用户层面内存限制, 所以不要设置的太高.
innodb_data_file_path = ibdata1:10M:autoextend
#innodb_data_home_dir = <directory>
innodb_write_io_threads = 8
innodb_read_io_threads = 8
#innodb_force_recovery=1
innodb_thread_concurrency = 16
innodb_flush_log_at_trx_commit = 2
#innodb_fast_shutdown
innodb_log_buffer_size = 16M
innodb_log_file_size = 512M
innodb_log_files_in_group = 3
#innodb_log_group_home_dir
innodb_max_dirty_pages_pct = 90
#innodb_flush_method=O_DSYNC
innodb_lock_wait_timeout = 120
innodb_file_per_table= 1//独立表空间的开启
[mysqldump]
quick
max_allowed_packet = 32M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 2048M
sort_buffer_size = 2048M
read_buffer = 32M
write_buffer = 32M
[mysqlhotcopy] c
interactive-timeout
[mysqld_safe]
open-files-limit = 8192
...全文
251 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

3,286

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 实用资料发布区
社区管理员
  • 实用资料发布区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧