环境:server1 rhel6.5
server2 rhel6.5
[root@server1 ~]# cd mysql5.7/
[root@server1 mysql5.7]# ls
mysql-community-client-5.7.17-1.el6.x86_64.rpm
mysql-community-common-5.7.17-1.el6.x86_64.rpm
mysql-community-devel-5.7.17-1.el6.x86_64.rpm
mysql-community-embedded-5.7.17-1.el6.x86_64.rpm
mysql-community-embedded-devel-5.7.17-1.el6.x86_64.rpm
mysql-community-libs-5.7.17-1.el6.x86_64.rpm
mysql-community-libs-compat-5.7.17-1.el6.x86_64.rpm
mysql-community-server-5.7.17-1.el6.x86_64.rpm
mysql-community-test-5.7.17-1.el6.x86_64.rpm
repodata
[root@server1 mysql5.7]# yum install -y mysql-community-client-5.7.17-1.el6.x86_64.rpm mysql-community-common-5.7.17-1.el6.x86_64.rpm mysql-community-libs-5.7.17-1.el6.x86_64.rpm mysql-community-libs-compat-5.7.17-1.el6.x86_64.rpm mysql-community-server-5.7.17-1.el6.x86_64.rpm
[root@server1 mysql5.7]# vim /etc/my.cnf

[root@server1 mysql5.7]# /etc/init.d/mysqld start
[root@server1 mysql5.7]# grep password /var/log/mysqld.log 查看密码
2018-08-11T01:42:03.837872Z 1 [Note] A temporary password is generated for root@localhost: Et,=8ah+havI
[root@server1 mysql5.7]# mysql_secure_installation ##初始化改密码
[root@server1 mysql5.7]# mysql -p
mysql> grant replication slave on . to cara@'172.25.135.2' identified by 'Caonimei@478';
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> flush privileges; ##刷新策率
Query OK, 0 rows affected (0.01 sec)
[root@server2 ~]# mysql -ucara -p -h 172.25.135.1 ##测试远程登陆
mysql> show master status; ##master上查看
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000007 | 154 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

mysql> change master to ##slave上连接 master_host='172.25.135.1',master_user='cara',master_password='Caonimei@478',master_log_file='mysql-bin.000007',master_log_pos=154;
Query OK, 0 rows affected, 2 warnings (0.11 sec)
mysql> show slave status\G;
1. row
Slave_IO_State:
Master_Host: 172.25.135.1
Master_User: cara
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000007
Read_Master_Log_Pos: 154
Relay_Log_File: server2-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: mysql-bin.000007
Slave_IO_Running: No
Slave_SQL_Running: No
mysql> start slave
mysql> show slave status\G;
主master上添加写数据
mysql> create database westos;
从slave上就可以看到
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| westos |
+--------------------+