jdxyzlh 发表于 2018-9-29 12:36:11

MySQL单机多实例配置

# cd /usr/local/mysql  
# cp support-files/my-small.cnf /etc/my.cnf
  
# vi /etc/my.cnf
  
# The following options will be passed to all MySQL clients
  

  
#password= your_password
  
port= 3306
  
socket= /tmp/mysql.sock
  
default-character-set = utf8
  

  
# Here follows entries for some specific programs
  
## This server may run 2+ separate instances
  
## So we use mysqld_multi to manage their services
  

  
mysqld = /usr/local/mysql/bin/mysqld_safe
  
mysqladmin = /usr/local/mysql/bin/mysqladmin
  
log = /mydata/data/mysqld_multi.log
  
user = root    ## Used for stopping the server via mysqladmin
  
# 如果该地方不是root用户,下面则需要在数据库为该用户添加shutdown权限,否则mysqld_multi将无法关闭实例。
  
#password =
  

  

  
port= 3306
  
socket = /tmp/mysqld_3306.sock
  
pid-file= /mydata/data/3306/mysqld.pid
  
datadir= /mydata/data/3306
  
basedir= /usr/local/mysql
  
lc-messages-dir= /usr/local/mysql/share/english
  

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

  

  
port            = 3307
  
socket          = /tmp/mysqld_3307.sock
  
pid-file      = /mydata/data/3307/mysqld.pid
  
datadir         = /mydata/data/3307
  
basedir         = /usr/local/mysql
  
lc-messages-dir = /usr/local/mysql/share/english
  

  
### Disable DNS lookups
  
#skip-name-resolve
  

  
### These support master - slave replication
  
#log-bin = /data/mysql/binlogs/bin-log-mysqld2
  
#log-bin-index = /data/mysql/binlogs/bin-log-mysqld2.index
  
#binlog-do-db =# Leave this blank if you want to control it on slave
  
#max_binlog_size = 1024M
  
### Relay log settings
  
#relay-log = /data/mysql/log/relay-log-mysqld2
  
#relay-log-index = /data/mysql/log/relay-log-mysqld2.index
  
#relay-log-space-limit = 4G
  

  
### Slow query log settings
  
#log-slow-queries = /data/mysql/log/slow-log-mysqld2
  
#long_query_time = 2
  
#log-queries-not-using-indexes
  

  

  
# The MySQL server
  

  
port= 3306
  
socket= /tmp/mysql.sock
  
pid-file= /mydata/data/mysqld.pid
  
datadir= /mydata/data
  
basedir= /usr/local/mysql
  
lc-messages-dir = /usr/local/mysql/share/english
  

  
skip-external-locking
  
key_buffer_size = 16K
  
max_allowed_packet = 1M
  
table_open_cache = 4
  
sort_buffer_size = 64K
  
read_buffer_size = 256K
  
read_rnd_buffer_size = 256K
  
net_buffer_length = 2K
  
thread_stack = 128K
  

  
### Incrase the max connections
  
max_connections = 200
  

  
### Set expiration time for logs, including binlogs
  
expire_logs_days = 14
  

  
### set the character as utf8
  
character-set-server = utf8
  
collation-server = utf8_unicode_ci
  

  
#skip-networking
  
server-id= 1
  

  
# Uncomment the following if you want to log updates
  
#log-bin=mysql-bin
  

  
# binary logging format - mixed recommended
  
#binlog_format=mixed
  

  
### set engine
  
default-storage-engine = INNODB
  

  
## enable per table data for innodb to shrink ibdata
  
innodb_file_per_table = 1
  

  
# Uncomment the following if you are using InnoDB tables
  
#innodb_data_home_dir = /usr/local/mysql/data
  
#innodb_data_file_path = ibdata1:10M:autoextend
  
#innodb_log_group_home_dir = /usr/local/mysql/data
  
# You can set .._buffer_pool_size up to 50 - 80 %
  
# of RAM but beware of setting memory usage too high
  
innodb_buffer_pool_size = 16M
  
innodb_additional_mem_pool_size = 2M
  
# Set .._log_file_size to 25 % of buffer pool size
  
innodb_log_file_size = 5M
  
innodb_log_buffer_size = 8M
  
innodb_flush_log_at_trx_commit = 1
  
innodb_lock_wait_timeout = 50
  

  

  
quick
  
max_allowed_packet = 16M
  

  

  
no-auto-rehash
  
# Remove the next comment character if you are not familiar with SQL
  
#safe-updates
  

  

  
key_buffer_size = 8M
  
sort_buffer_size = 8M
  

  

  
interactive-timeout
  

  

  
user = mysql
  

  

  
log-error = /mydata/data/mysqld.log
  
pid-file= /mydata/data/mysqld.pid
  
open-files-limit = 8192


页: [1]
查看完整版本: MySQL单机多实例配置