一台机器上部署多个mysql实例

需求背景

有时候我们的日志记录比较复杂,而且数据的读写比较频繁,因此把日志和业务分开不同的库进行操作较为合适,因此部署多个mysql实例还是有必要的,以下操作是在安装完成mysql前提进行的

配置mysql

[mysql]
port=3306
socket = /tmp/mysql3306.sock

[mysqld]
secure_file_priv=
symbolic-links=0
federated
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
[mysqld_multi]
#如果/usr/bin/mysqld_mulit stop 1-2 无效就需要进行user,pass设置
user=root                                                                                              
pass=123456 

mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
[mysqld1]
datadir = /usr/local/mysql/data
port = 3306
socket = /tmp/mysql3306.sock
log-error=/var/log/mysqld3306.log
#pid-file=/var/run/mysqld/mysqld3306.pid
[mysqld2]
datadir = /var/log/mysql/data
port = 3307
socket = /tmp/mysql3307.sock
log-error=/var/log/mysqld3307.log
[mysqld_safe]
long_query_time = 1
log-slow-queries = /var/log/slow_query_3306.log
[client]
socket=/tmp/mysql3306.sock

初始化[mysqld2] 的datadir目录

cd /usr/local/mysql/
scripts/mysql_install_db --user=mysql --datadir=/var/log/mysql/data

mysql启动,停止

/usr/bin/mysqld_mulit start 1-2
/usr/bin/mysqld_mulit stop 1-2

你可能感兴趣的:(一台机器上部署多个mysql实例)