加入收藏 | 设为首页 | 会员中心 | 我要投稿 大连站长网 (https://www.0411zz.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

MaxScale binlog server的创建

发布时间:2022-06-25 10:49:23 所属栏目:MySql教程 来源:互联网
导读:Node1上创建复制权限的账户: grant replication client,replication slave,select on *.* to rpl@192.168.2.% identified by rpl; # 这是给从库复制用的账号,同时也是maxscale拉取binlog的账户,它比常规的slave 账户多了一个select权限。 先把Node2挂到
  Node1上创建复制权限的账户:
 
  > grant replication client,replication slave,select on *.* to 'rpl'@"192.168.2.%" identified by 'rpl';
 
  # 这是给从库复制用的账号,同时也是maxscale拉取binlog的账户,它比常规的slave 账户多了一个select权限。
 
  先把Node2挂到node1下,模拟没有binlog server之前的架构:
 
  过程无非就是导出node1的全量数据,在node2上恢复并change master 到node1,具体步骤略过。
  
  # version_string 参数用于将主库的版本信息传递到从库,MaxScale sends server handshakepacket to clients
 
  router_options=server-id=13,heartbeat=30,transaction_safety=1,rcompatibility=1,send_slave_heartbeat=1
 
  binlogdir=/data/binlog   # 这个目录属主属组必须是maxscale
 
  user=rpl
 
  passwd=rpl
 
  #说明:
 
  #server-id 设置的是maxscale的id,不能与主库或者从库重名。
 
  #heartbeat=30表示当maxscale在30秒内没有接收到主库推送的binlog日志,发送心跳检查
 
  #transaction_safety=1 用于启用binlog日志中的不完整事务检测。当MariaDBMaxScale启动时,如果当前binlog文件已损坏或找到不完整的事务,则可能会出现错误消息。在正常工作期间,binlog事件不会分配到从库,直到事务已经提交。默认值为off,设置transaction_safety= on以启用不完全事务检测。【类似relay_log_recovery = ON的作用】
 
  #send_slave_heartbeat=1开启心跳检查
 
  ## 提供给slave连接的信息
 
  [ReplicationListener]
 
  type=listener
 
  service=Replication
 
  protocol=MySQLClient
 
  port=5308
 
  ## maxscale后端管理端口
 
  [MaxAdmin Service]
 
  type=service
 
  router=cli
 
  [MaxAdmin Listener]
 
  type=listener
 
  service=MaxAdmin Service
 
  protocol=maxscaled
 
  socket=default
 
  vim /data/binlog/master.ini 加上如下的内容:
 
  [binlog_configuration]
 
  master_host=192.168.2.11   # 主库地址
 
  master_port=3306             #主库端口号
 
  master_user=rpl              #master的复制账号
 
  master_password=rpl       # master的复制密码
 
  filestem=mysql    # 表示拉过来的binlog文件以mysql.***这种命名方式。我的主库也是mysql.*这种命名方式
 
  添加这个master.ini文件,以便启动maxscale后自动去拉取主库的目前的全部binlog文件(即便后来主库的binlog过期后被自动purge掉了,maxscale服务器上的binlog还会保存着的)
 
  然后,在node3上开启maxscale服务:
 
  /etc/init.d/maxscale start
 
  稍等片刻,node3会把主库的全部binlog都拉过来。

(编辑:大连站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!