MySQL多实例配置
Posted hopeless-dream
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL多实例配置相关的知识,希望对你有一定的参考价值。
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多实例配置的主要内容,如果未能解决你的问题,请参考以下文章
如何为 XSLT 代码片段配置 CruiseControl 的 C# 版本?