当前位置:Gxlcms > 数据库问题 > mysql 多实例构建

mysql 多实例构建

时间:2021-07-01 10:21:17 帮助过:15人阅读


socket=/data/mysql3307/mysql.sock
server_id=7
log_bin=/data/binlog3307/mysql-bin
binlog_format=row
port=3307
autocommit=0
log_error=/tmp/mysql3307_error.log
gtid-mode=on
enforce-gtid-consistency=true
slow_query_log=1
slow_query_log_file=/data/mysql3307/slow.log
long_query_time=0.1
log_queries_not_using_indexes

3- 初始化多实例数据库

mv /etc/my.cnf /etc/my.cnf.bak
mysqld --initialize-insecure --user=mysql --datadir=/data/mysql3307/data --basedir=/application/mysql
mysqld --initialize-insecure --user=mysql --datadir=/data/mysql3308/data --basedir=/application/mysql
mysqld --initialize-insecure --user=mysql --datadir=/data/mysql3309/data --basedir=/application/mysql

4- systemctl启动数据库配置

[root@db01 ~]# cat /etc/systemd/system/mysqld3307.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
# 修改为:--defaults-file=/data/mysql3307/my.cnf
ExecStart=/application/mysql/bin/mysqld --defaults-file=/data/mysql3307/my.cnf
LimitNOFILE = 5000
EOF
(1)目录授权
[root@db01 ~]# chown -R mysql.mysql /data
(2) 启动数据库
systemctl start mysqld3307.service
systemctl start mysqld3308.service
systemctl start mysqld3309.service

5- 验证多实例

netstat -lnp|grep 330
mysql -S /data/3307/mysql.sock -e "select @@server_id"
mysql -S /data/3308/mysql.sock -e "select @@server_id"
mysql -S /data/3309/mysql.sock -e "select @@server_id"

 

mysql 多实例构建

标签:sock   not   chown   alt   stat   emd   service   get   syslog   

人气教程排行