Single-Machine multi-instance is said to maximize the use of hardware, who know, but the previous company like this, I recently also learn to copy what, the computer can not afford two virtual machines, just a single multi-instance to rescue me. Let's talk about the steps below.
Http://www.cnblogs.com/wingsless/p/4002806.html above, I have installed MySQL, but this is a single instance, to change can be, but worried about the problem, so I deleted the following things:
1 #rm-F/etc/init.dmysql
2 $rm-F/home/mysql/data
Create these directories:
$mkdir-P/home/mysql/mydata/data1/binlog/home/mysql/mydata/data1/relay_log/home/mysql/mydata/data1/socket
$mkdir-P/home/mysql/mydata/data2/binlog/home/mysql/mydata/data2/relay_log/home/mysql/mydata/data2/socket
Next, you can copy the $MYSQL_HOME/SUPPUORT-FILES/MY-DEFAULT.CNF to/etc:
#cp suppuort-files/my-default.cnf/etc/my.cnf
To modify this file, add the following content:
[mysqld_multi]mysqld =/usr/mysql/bin/ =/usr/mysql/bin/mysqladminlog =/home/mysql/ Mydata/log/mysqld_multi.logsocket =/home/mysql/mydata/data1/socket/mysqld.sockport = 3306 pid - Span style= "color: #0000ff;" >file =/home/mysql/mydata/data1/mysqld.piddatadir =/home/mysql/ Mydata/data1[mysqld2]socket =/home/mysql/mydata/data2/socket/mysqld.sockport = 3307 pid - Span style= "color: #0000ff;" >file =/home/mysql/mydata/data2/mysqld.piddatadir =/home/mysql/ Mydata/data2
With this configuration, you can ensure that 3306 of the listening is the main library, while 3307 is listening from the library.
The following can initialize the database, still use $mysql_home/script/mysql_install_db:
./mysql_install_db--basedir=/usr/mysql--datadir=/home/mysql/mydata/data1
./mysql_install_db--basedir=/usr/mysql--datadir=/home/mysql/mydata/data2
After the execution, there will be many files automatically generated in these two directories:
Then execute:
#cp $MYSQL _home/support-files/mysqld_multi.server/etc/init.d/mysql
To this step, all the pre-work has been done, the following can start the database, two libraries to start the command is:
#service MySQL Start
That's fine. Below is how to configure master-slave replication.
First Login 3306:
$mysql-uroot-h127.0.0.1-p3306
To create a replication user:
Mysql>grant replication Slave, replication client on * * to [e-mail protected] ' localhost ' identified by ' repl ';
Mysql>flush privileges;
Log in from the library:
$mysql-uroot-h127.0.0.1-p3307
Mysql>change master to master_host= ' localhost ', master_port=3306, master_user= ' repl ', master_password= ' repl ', Master_log_file= ' mysql-bin.000001 ', master_log_pos=0;
Execute on the main library:
Mysql>show Master Status\g
Mysql>show processlist;
The main library should be like this. On the run from the library:
Mysql>show slave Status\g
There should be such a string, show processlist;
This will be configured as well. The following can be verified by creating a table on the main library:
Use test; Create Table Test ( int);
At this time from the library should have a corresponding table has also been copied over:
Insert data on Main library: INSERT into test select 1;
Automatically updated from the library:
This configures a pair of active database, other optimization parameters can refer to "high-performance MySQL", this book is really good, can be said to be MySQL in addition to official documents of the only classic.
By the way, master and slave This configuration installs what, official MySQL and Percona server I have tried, no difference.
MySQL standalone multi-instance installation and configuration master-slave replication