- 浏览: 126313 次
- 性别:
- 来自: 杭州
文章分类
最新评论
mysql master slave
slave
GRANT ALL PRIVILEGES ON *.* TO 'repl'@'192.168.1.3' IDENTIFIED BY 'repl' WITH GRANT OPTION;
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
server_id=10
lower_case_table_names=1
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
解决办法二、
首先停掉Slave服务:slave stop
到主服务器上查看主机状态:
记录File和Position对应的值
进入master
mysql> show master status;
+----------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+----------------------+----------+--------------+------------------+
| localhost-bin.000094 | 33622483 | | |
+----------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
slave手动同步:
mysql> change master to master_host='192.168.1.3', master_user='repl',master_password='repl', master_port=3306, master_log_file='mysql-bin.000003', master_log_pos=671 ;
1 row in set (0.00 sec)
mysql> slave start;
master 上 show master status; empty ??
server-id = 1
datadir = /var/lib/mysql
relay-log = /var/lib/mysql/mysql-relay-bin
relay-log-index = /var/lib/mysql/var/mysql-relay-bin.index
log-error = /var/lib/mysql/mysql.err
master-info-file = /var/lib/mysql/mysql-master.info
relay-log-info-file = /var/lib/mysql/mysql-relay-log.info
log-bin = /var/lib/mysql/mysql-bin
amoeba.xml
<?xml version="1.0" encoding="gbk"?>
<!DOCTYPE amoeba:configuration SYSTEM "amoeba.dtd">
<amoeba:configuration xmlns:amoeba="http://amoeba.meidusa.com/">
<proxy>
<!-- service class must implements com.meidusa.amoeba.service.Service -->
<service name="Amoeba for Mysql" class="com.meidusa.amoeba.net.ServerableConnectionManager">
<!-- port -->
<property name="port">8066</property>
<!-- bind ipAddress -->
<property name="ipAddress">192.168.1.3</property>
<property name="manager">${clientConnectioneManager}</property>
<property name="connectionFactory">
<bean class="com.meidusa.amoeba.mysql.net.MysqlClientConnectionFactory">
<property name="sendBufferSize">128</property>
<property name="receiveBufferSize">64</property>
</bean>
</property>
<property name="authenticator">
<bean class="com.meidusa.amoeba.mysql.server.MysqlClientAuthenticator">
<property name="user">root</property>
<property name="password">root</property>
<property name="filter">
<bean class="com.meidusa.amoeba.server.IPAccessController">
<property name="ipFile">${amoeba.home}/conf/access_list.conf</property>
</bean>
</property>
</bean>
</property>
</service>
<!-- server class must implements com.meidusa.amoeba.service.Service -->
<service name="Amoeba Monitor Server" class="com.meidusa.amoeba.monitor.MonitorServer">
<!-- port -->
<!-- default value: random number
<property name="port">9066</property>
-->
<!-- bind ipAddress -->
<property name="ipAddress">127.0.0.1</property>
<property name="daemon">true</property>
<property name="manager">${clientConnectioneManager}</property>
<property name="connectionFactory">
<bean class="com.meidusa.amoeba.monitor.net.MonitorClientConnectionFactory"></bean>
</property>
</service>
<runtime class="com.meidusa.amoeba.mysql.context.MysqlRuntimeContext">
<!-- proxy server net IO Read thread size -->
<property name="readThreadPoolSize">20</property>
<!-- proxy server client process thread size -->
<property name="clientSideThreadPoolSize">30</property>
<!-- mysql server data packet process thread size -->
<property name="serverSideThreadPoolSize">30</property>
<!-- per connection cache prepared statement size -->
<property name="statementCacheSize">500</property>
<!-- query timeout( default: 60 second , TimeUnit:second) -->
<property name="queryTimeout">60</property>
</runtime>
</proxy>
<!--
Each ConnectionManager will start as thread
manager responsible for the Connection IO read , Death Detection
-->
<connectionManagerList>
<connectionManager name="clientConnectioneManager" class="com.meidusa.amoeba.net.MultiConnectionManagerWrapper">
<property name="subManagerClassName">com.meidusa.amoeba.net.ConnectionManager</property>
<!--
default value is avaliable Processors
<property name="processors">5</property>
-->
</connectionManager>
<connectionManager name="defaultManager" class="com.meidusa.amoeba.net.MultiConnectionManagerWrapper">
<property name="subManagerClassName">com.meidusa.amoeba.net.AuthingableConnectionManager</property>
<!--
default value is avaliable Processors
<property name="processors">5</property>
-->
</connectionManager>
</connectionManagerList>
<!-- default using file loader -->
<dbServerLoader class="com.meidusa.amoeba.context.DBServerConfigFileLoader">
<property name="configFile">${amoeba.home}/conf/dbServers.xml</property>
</dbServerLoader>
<queryRouter class="com.meidusa.amoeba.mysql.parser.MysqlQueryRouter">
<property name="ruleLoader">
<bean class="com.meidusa.amoeba.route.TableRuleFileLoader">
<property name="ruleFile">${amoeba.home}/conf/rule.xml</property>
<property name="functionFile">${amoeba.home}/conf/ruleFunctionMap.xml</property>
</bean>
</property>
<property name="sqlFunctionFile">${amoeba.home}/conf/functionMap.xml</property>
<property name="LRUMapSize">1500</property>
<property name="defaultPool">server1</property>
<property name="writePool">server1</property>
<property name="readPool">server2</property>
<property name="needParse">true</property>
</queryRouter>
</amoeba:configuration>
dbServer.xml
<?xml version="1.0" encoding="gbk"?>
<!DOCTYPE amoeba:dbServers SYSTEM "dbserver.dtd">
<amoeba:dbServers xmlns:amoeba="http://amoeba.meidusa.com/">
<!--
Each dbServer needs to be configured into a Pool,
If you need to configure multiple dbServer with load balancing that can be simplified by the following configuration:
add attribute with name virtual = "true" in dbServer, but the configuration does not allow the element with name factoryConfig
such as 'multiPool' dbServer
-->
<dbServer name="abstractServer" abstractive="true">
<factoryConfig class="com.meidusa.amoeba.mysql.net.MysqlServerConnectionFactory">
<property name="manager">${defaultManager}</property>
<property name="sendBufferSize">64</property>
<property name="receiveBufferSize">128</property>
<!-- mysql port -->
<property name="port">3306</property>
<!-- mysql schema -->
<property name="schema">bvt_codetest</property>
<!-- mysql user -->
<property name="user">root</property>
<!-- mysql password-->
<property name="password">111111</property>
</factoryConfig>
<poolConfig class="com.meidusa.amoeba.net.poolable.PoolableObjectPool">
<property name="maxActive">500</property>
<property name="maxIdle">500</property>
<property name="minIdle">10</property>
<property name="minEvictableIdleTimeMillis">600000</property>
<property name="timeBetweenEvictionRunsMillis">600000</property>
<property name="testOnBorrow">true</property>
<property name="testWhileIdle">true</property>
</poolConfig>
</dbServer>
<dbServer name="server1" parent="abstractServer">
<factoryConfig>
<!-- mysql ip -->
<property name="ipAddress">192.168.1.3</property>
</factoryConfig>
</dbServer>
<dbServer name="server2" parent="abstractServer">
<factoryConfig>
<!-- mysql ip -->
<property name="ipAddress">192.168.1.10</property>
</factoryConfig>
</dbServer>
<dbServer name="multiPool" virtual="true">
<poolConfig class="com.meidusa.amoeba.server.MultipleServerPool">
<!-- Load balancing strategy: 1=ROUNDROBIN , 2=WEIGHTBASED , 3=HA-->
<property name="loadbalance">1</property>
<!-- Separated by commas,such as: server1,server2,server1 -->
<property name="poolNames">server1,server2</property>
</poolConfig>
</dbServer>
</amoeba:dbServers>
access_list.conf
#配置IP访问控制
#
# 优先级别从上往下,前面的优先级别高,每条一行
192.168.1.1-239:yes
#比如192.34.1.238则可以访问,否则将不能访问。
#218.85.*.*:no
127.0.0.1:yes
slave
GRANT ALL PRIVILEGES ON *.* TO 'repl'@'192.168.1.3' IDENTIFIED BY 'repl' WITH GRANT OPTION;
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
server_id=10
lower_case_table_names=1
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
解决办法二、
首先停掉Slave服务:slave stop
到主服务器上查看主机状态:
记录File和Position对应的值
进入master
mysql> show master status;
+----------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+----------------------+----------+--------------+------------------+
| localhost-bin.000094 | 33622483 | | |
+----------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
slave手动同步:
mysql> change master to master_host='192.168.1.3', master_user='repl',master_password='repl', master_port=3306, master_log_file='mysql-bin.000003', master_log_pos=671 ;
1 row in set (0.00 sec)
mysql> slave start;
master 上 show master status; empty ??
server-id = 1
datadir = /var/lib/mysql
relay-log = /var/lib/mysql/mysql-relay-bin
relay-log-index = /var/lib/mysql/var/mysql-relay-bin.index
log-error = /var/lib/mysql/mysql.err
master-info-file = /var/lib/mysql/mysql-master.info
relay-log-info-file = /var/lib/mysql/mysql-relay-log.info
log-bin = /var/lib/mysql/mysql-bin
amoeba.xml
<?xml version="1.0" encoding="gbk"?>
<!DOCTYPE amoeba:configuration SYSTEM "amoeba.dtd">
<amoeba:configuration xmlns:amoeba="http://amoeba.meidusa.com/">
<proxy>
<!-- service class must implements com.meidusa.amoeba.service.Service -->
<service name="Amoeba for Mysql" class="com.meidusa.amoeba.net.ServerableConnectionManager">
<!-- port -->
<property name="port">8066</property>
<!-- bind ipAddress -->
<property name="ipAddress">192.168.1.3</property>
<property name="manager">${clientConnectioneManager}</property>
<property name="connectionFactory">
<bean class="com.meidusa.amoeba.mysql.net.MysqlClientConnectionFactory">
<property name="sendBufferSize">128</property>
<property name="receiveBufferSize">64</property>
</bean>
</property>
<property name="authenticator">
<bean class="com.meidusa.amoeba.mysql.server.MysqlClientAuthenticator">
<property name="user">root</property>
<property name="password">root</property>
<property name="filter">
<bean class="com.meidusa.amoeba.server.IPAccessController">
<property name="ipFile">${amoeba.home}/conf/access_list.conf</property>
</bean>
</property>
</bean>
</property>
</service>
<!-- server class must implements com.meidusa.amoeba.service.Service -->
<service name="Amoeba Monitor Server" class="com.meidusa.amoeba.monitor.MonitorServer">
<!-- port -->
<!-- default value: random number
<property name="port">9066</property>
-->
<!-- bind ipAddress -->
<property name="ipAddress">127.0.0.1</property>
<property name="daemon">true</property>
<property name="manager">${clientConnectioneManager}</property>
<property name="connectionFactory">
<bean class="com.meidusa.amoeba.monitor.net.MonitorClientConnectionFactory"></bean>
</property>
</service>
<runtime class="com.meidusa.amoeba.mysql.context.MysqlRuntimeContext">
<!-- proxy server net IO Read thread size -->
<property name="readThreadPoolSize">20</property>
<!-- proxy server client process thread size -->
<property name="clientSideThreadPoolSize">30</property>
<!-- mysql server data packet process thread size -->
<property name="serverSideThreadPoolSize">30</property>
<!-- per connection cache prepared statement size -->
<property name="statementCacheSize">500</property>
<!-- query timeout( default: 60 second , TimeUnit:second) -->
<property name="queryTimeout">60</property>
</runtime>
</proxy>
<!--
Each ConnectionManager will start as thread
manager responsible for the Connection IO read , Death Detection
-->
<connectionManagerList>
<connectionManager name="clientConnectioneManager" class="com.meidusa.amoeba.net.MultiConnectionManagerWrapper">
<property name="subManagerClassName">com.meidusa.amoeba.net.ConnectionManager</property>
<!--
default value is avaliable Processors
<property name="processors">5</property>
-->
</connectionManager>
<connectionManager name="defaultManager" class="com.meidusa.amoeba.net.MultiConnectionManagerWrapper">
<property name="subManagerClassName">com.meidusa.amoeba.net.AuthingableConnectionManager</property>
<!--
default value is avaliable Processors
<property name="processors">5</property>
-->
</connectionManager>
</connectionManagerList>
<!-- default using file loader -->
<dbServerLoader class="com.meidusa.amoeba.context.DBServerConfigFileLoader">
<property name="configFile">${amoeba.home}/conf/dbServers.xml</property>
</dbServerLoader>
<queryRouter class="com.meidusa.amoeba.mysql.parser.MysqlQueryRouter">
<property name="ruleLoader">
<bean class="com.meidusa.amoeba.route.TableRuleFileLoader">
<property name="ruleFile">${amoeba.home}/conf/rule.xml</property>
<property name="functionFile">${amoeba.home}/conf/ruleFunctionMap.xml</property>
</bean>
</property>
<property name="sqlFunctionFile">${amoeba.home}/conf/functionMap.xml</property>
<property name="LRUMapSize">1500</property>
<property name="defaultPool">server1</property>
<property name="writePool">server1</property>
<property name="readPool">server2</property>
<property name="needParse">true</property>
</queryRouter>
</amoeba:configuration>
dbServer.xml
<?xml version="1.0" encoding="gbk"?>
<!DOCTYPE amoeba:dbServers SYSTEM "dbserver.dtd">
<amoeba:dbServers xmlns:amoeba="http://amoeba.meidusa.com/">
<!--
Each dbServer needs to be configured into a Pool,
If you need to configure multiple dbServer with load balancing that can be simplified by the following configuration:
add attribute with name virtual = "true" in dbServer, but the configuration does not allow the element with name factoryConfig
such as 'multiPool' dbServer
-->
<dbServer name="abstractServer" abstractive="true">
<factoryConfig class="com.meidusa.amoeba.mysql.net.MysqlServerConnectionFactory">
<property name="manager">${defaultManager}</property>
<property name="sendBufferSize">64</property>
<property name="receiveBufferSize">128</property>
<!-- mysql port -->
<property name="port">3306</property>
<!-- mysql schema -->
<property name="schema">bvt_codetest</property>
<!-- mysql user -->
<property name="user">root</property>
<!-- mysql password-->
<property name="password">111111</property>
</factoryConfig>
<poolConfig class="com.meidusa.amoeba.net.poolable.PoolableObjectPool">
<property name="maxActive">500</property>
<property name="maxIdle">500</property>
<property name="minIdle">10</property>
<property name="minEvictableIdleTimeMillis">600000</property>
<property name="timeBetweenEvictionRunsMillis">600000</property>
<property name="testOnBorrow">true</property>
<property name="testWhileIdle">true</property>
</poolConfig>
</dbServer>
<dbServer name="server1" parent="abstractServer">
<factoryConfig>
<!-- mysql ip -->
<property name="ipAddress">192.168.1.3</property>
</factoryConfig>
</dbServer>
<dbServer name="server2" parent="abstractServer">
<factoryConfig>
<!-- mysql ip -->
<property name="ipAddress">192.168.1.10</property>
</factoryConfig>
</dbServer>
<dbServer name="multiPool" virtual="true">
<poolConfig class="com.meidusa.amoeba.server.MultipleServerPool">
<!-- Load balancing strategy: 1=ROUNDROBIN , 2=WEIGHTBASED , 3=HA-->
<property name="loadbalance">1</property>
<!-- Separated by commas,such as: server1,server2,server1 -->
<property name="poolNames">server1,server2</property>
</poolConfig>
</dbServer>
</amoeba:dbServers>
access_list.conf
#配置IP访问控制
#
# 优先级别从上往下,前面的优先级别高,每条一行
192.168.1.1-239:yes
#比如192.34.1.238则可以访问,否则将不能访问。
#218.85.*.*:no
127.0.0.1:yes
发表评论
-
mysql 相关
2013-09-08 23:31 5941、查看链接数明细 mysqladmin -uroot ... -
vpn anycall 后linux 无法上网
2013-09-08 14:23 916vpn anycall 后linux 无法上网 ... -
phash jni
2013-04-28 23:48 1382phash jni 只需要图片的支持 jni 的 ... -
apt-get info
2013-04-28 12:55 1035# apt-get update——在修改/etc/apt ... -
linux 支持eclipse gbk
2013-04-26 23:12 810今天,把windows下的工程导入到了Linux下ecli ... -
linux disk io moniter shell
2013-04-14 17:58 1198转 http://wangchengtai.blog.he ... -
MongoDB C++ DRIVER 编译
2013-04-08 22:04 2106转自 http://nosql-db.com/topic/ ... -
ubuntu 12.04 vmware player 安装后加载虚拟机死机 打补丁
2013-04-08 21:51 1453ubuntu 12.04 vmware player 安装 ... -
ubuntu 12.4 close the touchpad sudo rmmod psmouse
2013-04-06 17:06 880ubuntu 12.4 close the touchp ... -
ubunt 开机启动 起vncsever 加分辨率 vncserver -geometry 640x480
2013-03-31 20:38 1127转自 http://www.dotblogs.com.tw ... -
ubuntu 下的 vi 和vim
2013-03-23 11:17 752之前用 redhat 的vi 感觉很好 现在再ubuntu ... -
linux eventx 模拟鼠标 单击和双击的方法
2013-03-12 22:36 2226网上有很多模拟键盘和鼠标的例子,单单击和双击的很少 ... -
Linux命令输出结果作为输入参数
2013-03-11 22:00 1597Linux命令输出结果作为输入参数 一 ech ... -
nat 么子对内转发依据
2013-01-23 20:11 810局域网共享模式 看了好多文章 都说 nat 出去 ... -
vmware linux 手动安装
2013-01-21 22:32 745vmware linux 自动安装 分区自动处理不能满足需 ... -
gconf-editor
2012-12-30 20:34 781gconf-editor u盘 自动挂载 /a ... -
牛逼只是一个接口,装逼也是它的一种实现
2012-10-16 20:32 736看到的 oo 最好描述 牛逼只是一个接口,装逼也是 ... -
OpenTLD + opencv 2.3.1 编译 成功
2012-10-06 20:06 1318cd OpenTLD mkdir build cd ... -
转 的可以控制鼠标和输入的代码
2012-10-06 20:01 721#include <string.h> # ... -
redhat 关闭随机启动的服务
2012-10-03 18:05 815chnconfig指令: 通过chkconfig -- ...
相关推荐
里面实现的是动态切换数据源,大家都是知道,spring2之后添加AbstractRoutingDataSource这个东西,这个就可以实现切换数据源,实现思路是:先按照搭建MySQL的MasterSlave架构.doc>>(我上传有资源),搭建好,然后动态...
Master-Slave的数据库机构解决了很多问题,特别是read/write比较高的web2.0应用: 1、写操作全部在Master结点执行,并由Slave数据库结点定时(默认60s)读取Master的bin-log 2、将众多的用户读请求分散到更多的...
MySQL的Master-Slave架构是一种常见的数据库高可用性和负载均衡解决方案。它允许数据从一个主服务器(Master)实时同步到一个或多个从服务器(Slave)。在这种架构中,所有的写操作都在主服务器上执行,而从服务器则...
MySQL的主从复制(Master-Slave Replication)是一种常用的数据冗余和负载均衡策略,它允许数据库系统在多个服务器之间同步数据。当一个MySQL服务器(主服务器,Master)接收到写操作时,这些更改会被记录到二进制...
5. **启动复制**:在从服务器上,使用`START SLAVE`命令启动复制进程。此时,从服务器将开始读取主服务器的binlog并执行相应的SQL语句。 二、主从复制工作原理 1. **写操作**:在主服务器上,任何数据修改都会被...
MySQL Master-Slave 同步配置是数据库高可用性架构中的常见实践,它允许数据从一个主节点(Master)实时复制到一个或多个从节点(Slave)。这种配置主要用于数据备份、负载均衡和故障恢复。以下是对MySQL Master-...
Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs This error generally occur when we clone the master to slaver. Delete auto.cnf of mysql, and then ...
MySQL的主从(Master-Slave)数据同步配置是一种常见的数据库高可用性和负载均衡解决方案,它允许数据在多个服务器之间复制,确保数据的一致性,并且可以在主服务器故障时提供故障转移。以下是对这一主题的详细说明...
ActiveMQ支持多种高可用的主从配置模式,包括Shared File System Master/Slave、JDBC Master/Slave和Replicated LevelDB Store。文章主要介绍了使用JDBC Master/Slave模式来实现ActiveMQ的高可用配置。 在JDBC ...
### MySQL 5.5 Master-Slave (Replication) 配置详解 #### 一、基础知识简介 在深入了解具体的配置步骤之前,我们首先简要回顾一下MySQL中的Master-Slave复制机制的基础概念。 - **主从复制(Master-Slave ...
mysql slave切换为master 测试
ActiveMQ 集群——JDBC Master Slave + Broker Cluster ActiveMQ 集群是指将多个 ActiveMQ 服务器组合在一起,以提高系统的可扩展性和可靠性。在这个集群中,我们可以使用 JDBC Master Slave 模式和 Broker Cluster...
MySQL数据库复制Master-Slave架构是一种常见的数据库高可用性和扩展性的解决方案。在这一架构中,数据库被分为一个主服务器(Master)和一个或多个从服务器(Slave)。主服务器接收并处理所有的写操作,如INSERT、...
MySQL的主主复制(Master-Master Replication)是一种高可用性解决方案,它允许两个或多个数据库服务器互相复制数据,形成一个集群。在这种模式下,每个节点既是主节点,也是从节点,可以接受读写操作。当一个节点...
此资源为shardingsphere 调研...内容:一个master mysql docker实例,一个slave docker实例 内置3个库,mydb,mydb0,mydb1。仅开启了这三个库的主从。如果三个库主从不够用,自行配置。 使用:1.解压 2.执行build.sh