多文件mysql Multi-Instance

多个cnf文件的配置模板
[client]
port=3308
socket=/data/mysql/datadir/3308/data/mysql.sock
[mysqld]
port=3308
user=mysql
explicit_defaults_for_timestamp=true
socket=/data/mysql/datadir/3308/data/mysql.sock
pid-file=/data/mysql/datadir/3308/data/mysql.pid
basedir=/data/mysql/installdir
datadir=/data/mysql/datadir/3308/data
tmpdir=/data/mysql/tmpdir08
log_error=/data/mysql/logdir/3308/error_log/mysql3.err
server-id = 3
log_bin = /data/mysql/logdir/3308/bin_log/binlog
general_log_file=/data/mysql/logdir/3308/general_log/general.log
general_log = 1
slow_query_log = ON
long_query_time = 2
slow_query_log_file = /data/mysql/logdir/3308/query_log/query.log
log_queries_not_using_indexes = ON
binlog-ignore-db=mysql
binlog_cache_size=512M
expire_logs_days=0
#gtid
gtid_mode = ON
enforce_gtid_consistency = ON
master_info_repository = TABLE
relay_log_info_repository = TABLE
binlog_checksum = NONE
log_slave_updates = ON
binlog_format = ROW
#group replication
transaction_write_set_extraction = XXHASH64
loose-group_replication_group_name = ‘aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa1’
loose-group_replication_start_on_boot = off
loose-group_replication_local_address = ‘10.6.248.199:33063’
loose-group_replication_group_seeds = ‘10.6.248.199:33061,10.6.248.199:33062,10.6.248.199:33063’
loose-group_replication_bootstrap_group = off
loose-group_replication_single_primary_mode = FALSE
loose-group_replication_enforce_update_everywhere_checks = on
auto_increment_increment=10
auto_increment_offset=3

解释:
端口需要不一样
socket表示密码
basedir:安装基本目录一样
datadir:数据目录需要不一样
general_log_file:mysql 连接用户记录日志
log-bin:mysql 更改语句日志
slow_query_log_file:慢日志查询日志,默认未开启
log-error:错误日志
tmpdir:临时表路径
pid-file:mysql的文件的pid存放路径
server-id:mysql唯一识别号
user:mysql 用户

并且以上的路径需要重新进行创建且区别于其它实例的路径,除了basedir外!
并且加上权限
#chown -R mysql:mysql /data
#chmod -R 775 /data

然后对实例进行初始化
mysqld --defaults-file=/etc/my07.cnf --user=mysql --basedir=/data/mysql/installdir --datadir=/data/mysql/datadir/3307/data/ --initialize-insecure
注意:–initialize-insecure 此两个参数一定要放在后面,否则在启动数据库实例的时候就会产生错误!
说明:可以没有basedir 这个选项,但是一定要有datadir这个选项
问题:
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
解决方法:
#开启查询缓存(my.cnf中)
explicit_defaults_for_timestamp=true
启动实例
mysqld_safe --defaults-file=/etc/my07.cnf &

解决办法:chown -R mysql:mysql /data
或者:vim mysql3.err 并加上用户及组

错误:
Fatal error: Can’t open and lock privilege tables: Table ‘mysql.user’ doesn’t exist
解决办法:是由于–initialize-insecure 位置不对而导致的错误

查看是否启动
ps -ef|grep mysql
netstat -ano | grep ‘3307|3308’

设置密码(初始化密码)
mysqladmin -uroot -p password 密码 -S /data/3308/mysql.sock
继续回车

本地登录
mysql -uroot -p -S /data/3308/mysql.sock

mysql 实例的关闭
mysqladmin -uroot -p -S /data/3308/mysql.sock shutdown
启动
mysqld_safe --defaults-file=/etc/my80.cnf

你可能感兴趣的:(多文件mysql Multi-Instance)