遵照一位朋友的说明文档,自己实践了一把,记录如下:
服务器说明
192.168.208.118 mysql master id 1
192.168.208.119 mysql slave id 2
192.168.208.120 mysql slave id 3
分别在 192.168.208.118 、192.168.208.119、192.168.208.120安装mysql
一 、在三台服务器上安装mysql-server
mysql mysql-server
二、修改配置文件
1.配置主 192.168.208.118
vi /etc/my.cnf
server-id = 1
1.) 启动msyql
service mysqld start
2.) 分别给两台slave授权
mysql> GRANT REPLICATION SLAVE ON *.* TO 'slave208120'@'192.168.208.120' identified by '123456';
mysql> GRANT REPLICATION SLAVE ON *.* TO 'slave208119'@'192.168.208.119' identified by '123456';
2.分别配置两台slave
1.) 第一台(ip 192.168.208.119)
vi /etc/my.cnf
server-id = 2
master-host = 192.168.208.118
master-user = slave208119
master-password = 123456
启动msyql
service mysqld start
进入mysql 输入以下命令
mysql> START slave;
mysql> quit;
2.)第二台(ip 192.168.208.120)
vi /etc/my.cnf
server-id = 3
master-host = 192.168.208.118
master-user = slave208120
master-password = 123456
启动msyql
service mysqld start
进入mysql 输入以下命令
mysql> START slave;
mysql> quit;
三 测试
在master上建立一个新的数据库,然后在两台slave上效验是否有数据库生成。
mysql> create database test;
进入两台slave机器;
mysql
mysql> show databases;
--------------------
Database
--------------------
information_schema
mysql
test
+--------------------+4 rows in set (0.00 sec)
安装测试成功。
Labels parameters