In the past, when using mysql, it was mostly used to use only one mysql schema, or multiple schemas, but generally they were in the same database instance, that is, the same port.
# Machine B. Then in the two-way hot backup, B also needs to be configured as the master, and A is configured as the slave. To put it bluntly, hot backup is configured twice. OK, now the hot backup of machine A has been completed, and it is B's turn. We mentioned that there is also a mysql schema (C) on machine B, which also needs to be configured as master, and the backup schema is placed on machine A, but here comes the problem: the backup mysql schema (B) has just been configured with mysql when configuring hot standby. Port number and master
The role is bound. At this time, if C is configured as master, the previous configuration of B as master will be overwritten; then when C's backup database (D) is configured as master on machine A, A will be configured as master. Operation covered.
[mysqld_multi] mysqld = /opt/mysql/server-5.6/bin/mysqld_safe #根据自己的mysql目录配置 mysqladmin = /opt/mysql/server-5.6/bin/mysqladmin [mysqld1] port = 3307 socket = /tmp/mysql.sock1 pid-file = /opt/mysql/server-5.6/data3307/cloud3.pid3 basedir=/opt/mysql/server-5.6 datadir=/opt/mysql/server-5.6/data3307 log-bin=mysql1-9003-bin user=cloud1 [mysqld2] port = 3308 socket = /tmp/mysql.sock2 pid-file = /opt/mysql/server-5.6/data3308/cloud3.pid2 basedir=/opt/mysql/server-5.6 datadir=/opt/mysql/server-5.6/data3308 log-bin=mysql2-9003-bin user=cloud1
(3) Initialize the database directory (point to the directory according to the configuration)
cd /opt/mysql/server-5.6/;./scripts/mysql_install_db --datadir=/opt/mysql/server-5.6/data3307 --user=cloud1 cd /opt/mysql/server-5.6/;./scripts/mysql_install_db --datadir=/opt/mysql/server-5.6/data3308 --user=cloud1
(4) Start the instance
mysqld_multi [options] [GNR[,GNR]...]
mysqld_multi --defaults-file=/opt/mysql/server-5.6/my.cnf start 1-2 或者 mysqld_multi --defaults-file=/opt/mysql/server-5.6/my.cnf start 1 mysqld_multi --defaults-file=/opt/mysql/server-5.6/my.cnf start 2
mysqladmin -u root -p -P 3307 -S /tmp/mysql.sock1 password //刚开始默认没有密码,如果要输入密码,直接回车 mysql -u root -p -P 3307 -S /tmp/mysql.sock1
The above is the detailed content of Linux uses mysqld_multi to start multiple MySQL instances on a single machine. For more information, please follow other related articles on the PHP Chinese website!