e_machine_mysql_replication
2:http://robinwu.javaeye.com/blog/310839
如果机器上已经用apt-get install安装了mysql,则可以用以下方式去除
1 apt-get –purge remove mysql-server
2 apt-get –purge remove mysql-common
创建文件夹/misu:
tar xzvf /mysql-5.0.67.tar.gz.tar.gz
cd /misc//mysql-5.0.67.tar.gz
./configure –prefix=/usr/local/mysql-master
make
make install
cd /usr/local/mysql-master/bin
./mysql_install_db
(it will create a var folder )
cd ../var
cp /misc//mysql-5.0.67.tar.gz/support-files/my-medium.cnf my.cnf
cd ..
groupadd mysql
useradd -g mysql mysql
chown -R root .
chown -R mysql var
chgrp -R mysql
查看my.cnf
[mysqld]
port = 3306
socket = /usr/local/mysql-master/mysql.sock
#skip-networking // we have skip this in our case as we are doing both master and slave on same machine.
# Replication Master Server (default)
# binary logging is required for replication
log-bin
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 1
cd /usr/local/mysql-master/bin
./mysqld_safe –defaults-file=/usr/local/mysql-master/var/my.cnf
MySQL Slave:
Now extract mysql-4.1.12.tar.gz at different dir,
cd /opt/mysql-4.1.12
./configure –prefix=/usr/local/mysql-slave
make
make install
cd /usr/local/mysql-slave
cd bin
./mysql_install_db
(it will create a var folder )
cd ../var
cp /opt/mysql-4.1.12/support-files/my-medium.cnf my.cnf
cd ..
groupadd mysql
useradd -g mysql mysql
chown -R root .
chown -R mysql var
chgrp -R mysql .
Edit my.cnf in the var folder
[mysqld]
port = 3307
socket = /usr/local/mysql-slave/var/mysql.sock
#skip-networking
server-id = 2
# The replication master for this slave – required
master-host = localhost
master-user = slavedb
master-password = q1w2e3r4t5
master-port = 3306
Now starts the mysql server by:
cd /usr/local/mysql-slave/bin
./mysqld_safe –defaults-file=/usr/local/mysql-slave/var/my.cnf &
Configure Replication:
connect to mysql master by:
mysql –sock=/usr/local/mysql-master/mysql.sock
Create account at master for slave:
mysql> GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO slavedb@”192.168.1.27/255.255.255.0″ identified by ‘q1w2e3r4t5′;Query OK, 0 rows affected (0.28 sec)
connect to mysql slave by:
mysql –sock=/usr/local/mysql-slave/mysql.sock
mysql> slave start;
Query OK, 0 rows affected, 1 warning (0.04 sec)