1:已經事先購買了兩台雲主機
10.4.14.168 101.69.178.208 [聯通] Master
10.4.5.9 101.69.178.219 [聯通] Slave
2:分別安裝MySQL
代碼如下 復制代碼
#yum install mysql-server –enablerepo=remi
#yum install mysql-devel
3:查看MySQL安裝情況
代碼如下 復制代碼[root@10-4-14-168 ~]# rpm -qa | grep mysql*
mysql-5.1.73-3.el6_5.x86_64
mysql-libs-5.1.73-3.el6_5.x86_64
mysql-server-5.1.73-3.el6_5.x86_64
mysql-devel-5.1.73-3.el6_5.x86_64
4:啟動MySQL
代碼如下 復制代碼 service mysqld start
5:登陸MySQL並且修改密碼並且刪除空用戶
代碼如下 復制代碼 mysql> UPDATE mysql.user SET password = PASSWORD('ge0513.mysql')
6 需改配置文件
代碼如下 復制代碼 bind-address = 10.6.20.1
7:主庫上創建復制用戶
代碼如下 復制代碼GRANT REPLICATION SLAVE ON *.* TO [email protected] IDENTIFIED BY 'gechong';
8:在主庫上執行
代碼如下 復制代碼mysql> show master status;
+---------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+---------------+----------+--------------+------------------+
| binlog.000003 | 412 | | |
+---------------+----------+--------------+------------------+
1 row in set (0.00 sec)
9:在從庫的配置文件中添加之後重啟服務
代碼如下 復制代碼 master-host = 10.4.14.168
10:在從庫上執行
代碼如下 復制代碼mysql> start slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)
11:嘗試在主庫上添加新表,看是否從庫上也會出現