710661809 发表于 2018-9-30 08:45:06

MySQL基础day06_mysql服务器的主从同步-MySQL 5.6

  1,查看主服务器server1的偏移量
  # mysql -p tarena          //登录主服务器查看偏移量
  mysql> show master status;                  //查询主服务器的偏移量
  +--------------------+----------+--------------+------------------+-------------------+
  | File               | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
  +--------------------+----------+--------------+------------------+-------------------+
  | server1-bin.000001 |      120 |            |                  |                   |
  +--------------------+----------+--------------+------------------+-------------------+
  1 row in set(0.00 sec)
  mysql> quit
  Bye
  #
  2,在server2服务器进行从服务器的配置
  # mysql -ptarena         //登录本机服务器进行设置
  mysql>change master to
  ->master_host="192.168.1.200",       //指定主服务器ip地址
  -> master_user="userslave",          //指定授权登录用户名
  -> master_password="123",         //指定授权登录用户密码
  ->master_log_file="server1-bin.000001",      //指定server1的日志文件
  -> master_log_pos=120;         //指定binlog日志的偏移量(pos)
  Query OK, 0rows affected, 2 warnings (0.07 sec)
  mysql>quit
  Bye
  # ll
  total 110636
  -rw-rw---- 1mysql mysql       56 Mar 20 14:18auto.cnf
  -rw-rw---- 1mysql mysql 12582912 Mar 20 20:47 ibdata1
  -rw-rw---- 1mysql mysql 50331648 Mar 20 20:48 ib_logfile0
  -rw-rw---- 1mysql mysql 50331648 Mar 20 14:18 ib_logfile1
  -rw-rw----1 mysql mysql       93 Mar 20 21:00master.info    //连接主服务器server1的信息
  drwx--x--x 2mysql mysql   4096 Mar 20 14:18 mysql
  srwxrwxrwx 1mysql mysql      0 Mar 20 20:47mysql.sock
  drwx------ 2mysql mysql   4096 Mar 20 14:18performance_schema
  -rw-rw----1 mysql mysql       59 Mar 20 21:00relay-log.info   //中继日志信息
  -rw-r--r-- 1rootroot       111 Mar 20 14:18 RPM_UPGRADE_HISTORY
  -rw-r--r-- 1mysql mysql      111 Mar 20 14:18RPM_UPGRADE_MARKER-LAST
  -rw-rw---- 1mysql mysql      6 Mar 20 20:47server2.example.com.pid
  -rw-rw----1 mysql mysql      120 Mar 20 21:00server2-relay-bin.000001    //中继binlog日志
  -rw-rw----1 mysql mysql       27 Mar 20 21:00server2-relay-bin.index   //存放已有的中继日志名
  drwx------ 2mysql mysql   4096 Mar 20 20:00 test
  #
  注:绿色显示的四个文件为start slave之后新添加的文件

页: [1]
查看完整版本: MySQL基础day06_mysql服务器的主从同步-MySQL 5.6