1: Two cloud hosts have been purchased in advance
10.4.14.168 101.69.178.208 [Unicom] Master
10.4.5.9 101.69.178.219 [Unicom] Slave
2: MySQL installed separately
The code is as follows |
Copy Code |
#yum Install Mysql-server–enablerepo=remi
#yum Install Mysql-devel |
3: View MySQL Installation
The code is as follows |
Copy Code |
[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: Start MySQL
The code is as follows |
Copy Code |
Service mysqld Start
|
5: Login MySQL and modify the password and delete the empty user
The code is as follows |
Copy Code |
mysql> UPDATE mysql.user SET password = password (' ge0513.mysql ') -> WHERE user = ' root '; Query OK, 3 Rows Affected (0.00 sec) Rows Matched:3 Changed:3 warnings:0 Mysql> SELECT User,host,password from Mysql.user; +------+-------------+-------------------------------------------+ | user | Host | password | +------+-------------+-------------------------------------------+ | Root | localhost | *7ae39be5035d5c32361400ff7dedd757aa76896a | | Root | 10-4-14-168 | *7ae39be5035d5c32361400ff7dedd757aa76896a | | Root | 127.0.0.1 | *7ae39be5035d5c32361400ff7dedd757aa76896a | | | localhost | | | | 10-4-14-168 | | +------+-------------+-------------------------------------------+ 5 rows in Set (0.00 sec) mysql> DROP user ' @localhost; Query OK, 0 rows Affected (0.00 sec) mysql> DROP user ' @ ' 10-4-14-168 '; Query OK, 0 rows Affected (0.00 sec) |
6 need to change the configuration file
The code is as follows |
Copy Code |
Bind-address = 10.6.20.1 Port = 3306 Character_set_server = UTF8 Max_connect_errors = 1000000 Max_connections = 500 DataDir =/data/mysql Log-error =/var/log/mysql/mysql-error.log-error Skip_name_resolve Back_log = 2000 Log-bin =/data/mysql Binlog-format = MIXED Expire_logs_days = 2
|
7: Create a replication user on the main library
The code is as follows |
Copy Code |
GRANT REPLICATION SLAVE on *.* to gechong@10.4.14.168 identified by ' Gechong '; |
8: Executing on the main library
The code is as follows |
Copy Code |
Mysql> Show master status; +---------------+----------+--------------+------------------+ | File | Position | binlog_do_db | binlog_ignore_db | +---------------+----------+--------------+------------------+ | binlog.000003 | 412 | | | +---------------+----------+--------------+------------------+ 1 row in Set (0.00 sec) |
9: Restart the service after adding it from the library's configuration file
The code is as follows |
Copy Code |
Master-host = 10.4.14.168 Master-user = Gechong Master-password = Gechong BINLOG-DO-DB = Test
|
10: Performing from the Library
The code is as follows |
Copy Code |
mysql> start slave; Query OK, 0 rows affected, 1 Warning (0.00 sec) |
11: Try adding a new table to the main library to see if it will also appear from the library