相关栏目: IT资讯 当前位置:主页 > IT资讯 >

MySQL单向同步实现

发布时间:2018-12-07 作者:凯发K 分类:IT资讯

实例主机:
dbasky=192.168.1.120
dbaskyback=192.168.1.121

目的:dbaskyback的主机去同步dbasky主机test库上的数据

安装mysql
[[email protected]]#wget ftp://ftp.cronyx.ru/pub/FreeBSD/ports/distfiles/mysql-5.0.45.tar.gz
[[email protected]]#cd /usr/local/mysql-5.0.45
[[email protected]]#groupadd mysql
[[email protected]]#useradd -g mysql mysql
[[email protected]]#mkdir /opt/mysql-data
[[email protected]sky]#CFLAGS="-O3 " CXX=gcc CXXFLAGS="-O3 -felide-constructors
 -fno-exceptions -fno-rtti" ./configure             --prefix=/usr/local/mysql --enable-assembler             --with-charset=utf8             --with-extra-charsets=gbk,gb2312,latin1             --localstatedir=/opt/mysql-data             --with-mysqld-user=mysql --enable-large-files --with-big-tables             --without-debug --enable-thread-safe-client             --with-fast-mutexes             --with-innodb
[[email protected]]#make
[[email protected]]#make install
[[email protected]]#cd /etc
[[email protected]]#rz my.cnf
[[email protected]]#chown -R mysql .
[[email protected]]#chgrp -R mysql .
[[email protected]]#chown -R mysql /opt/mysql-data
[[email protected]]#chgrp -R mysql /opt/mysql-data
[[email protected]]#bin/mysql_install_db --user=mysql
[[email protected]]#chown -R root .
[[email protected]]#bin/mysqld_safe --user=mysql &
[[email protected]]#cd  /usr/local/mysql
[[email protected]]#echo "PATH=/usr/local/mysql/bin:$PATH" >> /etc/profile
[[email protected]]#echo "export PATH" >> /etc/profile
[[email protected]]#echo "alias vi="vim"" >> /etc/profile
[[email protected]]#echo "/usr/local/mysql/lib/mysql" > /etc/ld.so.conf.d/mysql.conf

在dbasky机器上
建立用户
mysql>create database test;
mysql>grant all on *.* to [email protected] identified by 123456;

     [[email protected]]#vi /etc/my.cnf
     server-id=1 #为master
     log-bin=/var/log/mysql/mysql.log
添加
    binlog-do-db=test #要同步的数据库名字

重新启动mysql
用 mysql>show master status 查看

在dbaskyback机器上
dbaskyback#vi /etc/my.cnf
  server-id=2 #为slave
  master-host=192.168.1.120
  master-user=xu
  master-password=123456
  master-port=3306
  master-connect-retry=60 #间隔60秒重新设置
  replicate-do-db=test

用mysql>show slave status 看同步情况,如果有错误也可以看得出来.

 

http://www.bkjia.com/Mysql/489786.htmlwww.bkjia.comtruehttp://www.bkjia.com/Mysql/489786.htmlTechArticle实例主机: dbasky=192.168.1.120 dbaskyback=192.168.1.121 目的:dbaskyback的主机去同步dbasky主机test库上的数据 安装mysql [[email protected]]#wget ftp://ftp.cronyx.r...

本文源自: 凯发国际

上一篇:四川高防服务器技能 下一篇:没有了

Copyright © 2005-2016 http://www.owlpma.com 凯发国际_凯发国际开户礼金_凯发注册送_新浪娱乐版权所有 凯发国际_凯发国际开户礼金_凯发注册送_新浪娱乐