码迷,mamicode.com
首页 > 数据库 > 详细

MySQL多实例配置

时间:2020-05-25 00:17:23      阅读:79      评论:0      收藏:0      [点我收藏+]

标签:mysq   cat   targe   service   bsp   col   ecs   html   systemctl   

1.1 准备配置文件

[root@localhost ~]# mkdir /data/330{7..9}/data -p

[root@localhost ~]# mkdir -p /data/mysql/binlog_330{7..9}

[root@localhost ~]# chown -R mysql.mysql /data/*

[root@localhost ~]# cat >> /data/3307/my.cnf <<EOF

> [mysqld]

> user=mysql

> basedir=/usr/local/mysql8

> datadir=/data/3307/data

> socket=/tmp/mysql3307.sock

> server_id=7

> log_bin=/data/mysql/binlog_3307

> port=3307

> EOF

 

[root@localhost ~]# cat >> /data/3308/my.cnf <<EOF

> [mysqld]

> user=mysql

> basedir=/usr/local/mysql8

> datadir=/data/3308/data

> socket=/tmp/mysql3308.sock

> server_id=8

> log_bin=/data/mysql/binlog_3308

> port=3308

> EOF

 

[root@localhost ~]# cat >> /data/3309/my.cnf <<EOF

> [mysqld]

> user=mysql

> basedir=/usr/local/mysql8

> datadir=/data/3309/data

> socket=/tmp/mysql3309.sock

> server_id=7

> log_bin=/data/mysql/binlog_3309

> port=3309

> EOF

 

1.2 初始化数据

[root@localhost ~]# mysqld --initialize-insecure --user=mysql --datadir=/data/3307/data --basedir=/usr/local/mysql8

[root@localhost ~]# mysqld --initialize-insecure --user=mysql --datadir=/data/3308/data --basedir=/usr/local/mysql8

[root@localhost ~]# mysqld --initialize-insecure --user=mysql --datadir=/data/3309/data --basedir=/usr/local/mysql8

1.3 准备启动脚本

[root@localhost ~]# cat >> /etc/systemd/system/mysqld3307.service <<EOF

> [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

> ExecStart=/usr/local/mysql8/bin/mysqld --defaults-file=/data/3307/my.cnf

> LimitNOFILE = 5000

> EOF

 

[root@localhost ~]# cat >> /etc/systemd/system/mysqld3308.service <<EOF

[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

ExecStart=/usr/local/mysql8/bin/mysqld --defaults-file=/data/3308/my.cnf

LimitNOFILE = 5000

EOF

 

[root@localhost ~]# cat >> /etc/systemd/system/mysqld3309.service <<EOF

[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

ExecStart=/usr/local/mysql8/bin/mysqld --defaults-file=/data/3309/my.cnf

LimitNOFILE = 5000

EOF

1.4 启动多实例

[root@localhost ~]# systemctl start mysqld3307

[root@localhost ~]# systemctl start mysqld3308

[root@localhost ~]# systemctl start mysqld3309

 

MySQL多实例配置

标签:mysq   cat   targe   service   bsp   col   ecs   html   systemctl   

原文地址:https://www.cnblogs.com/zh-dream/p/12953260.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!