mysql +cobar_mysql分布式中间件cobar

本文介绍了Cobar的分布式特性,主要通过水平拆分表并分配到不同数据库实现。内容包括如何创建数据库和表,并展示了Cobar的安装步骤。在示例中,同一表`t1`被水平拆分为三份,分别存放在test01、test02和test03数据库中,以实现分布式环境。Cobar的配置文件如`schema.xml`用于定义数据库连接信息。
摘要由CSDN通过智能技术生成

Cobar的分布式主要是通过将表放入不同的库来实现:

1.Cobar支持将一张表水平拆分成多份分别放入不同的库来实现表的水平拆分

2.Cobar也支持将不同的表放入不同的库

3.多数情况下,用户会将以上两种方式混合使用

4.Cobar不支持将一张表,例如test表拆分成test_1, test_2, test_3.....放在同一个库中,必须将拆分后的表分别放入不同的库来实现分布式

环境规划:

IP                         数据库      表

192.168.1.247        test01       t1

192.168.1.247        test02       t1

192.168.1.247        test03       t1

1.创建数据库和表

[[email protected] ~]# /usr/local/mysql-5.6.23/bin/mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 6028

Server version: 5.6.23-log MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql> create database test01;                 --创建数据库test01,02,03

Query OK, 1 row affected (0.03 sec)

mysql> create database test02;

Query OK, 1 row affected (0.03 sec)

mysql> create database test03;

Query OK, 1 row affected (0.03 sec)

mysql> \u test01

Database changed

mysql> create table t1(a int,b char(5));             --在三个数据库创建相同的表

Query OK, 0 rows affected (0.34 sec)

mysql> \u test02

Database changed

mysql> create table t1(a int,b char(5));

Query OK, 0 rows affected (0.31 sec)

mysql> \u test03

Database changed

mysql> create table t1(a int,b char(5));

Query OK, 0 rows affected (0.30 sec)

mysql> show tables;

+------------------+

| Tables_in_test03 |

+------------------+

| t1               |

+------------------+

1 row in set (0.00 sec)

mysql> exit

Bye

[[email protected] ~]#

2.下载安装cobar

[[email protected] ~]# tar xvf cobar-server-1.2.7.tar.gz  -C /usr/local/

[[email protected] ~]# cd /usr/local/cobar-server-1.2.7/

[[email protected] cobar-server-1.2.7]# ll

total 36

drwxr-xr-x. 2 root root  4096 Dec 29  2012 bin

drwxr-xr-x. 2 root root  4096 Dec 29  2012 conf

-rwsrwsrwt. 1 root root   575 Dec 29  2012 COPYRIGHT

drwxr-xr-x. 3 root root  4096 May 14 10:13 lib

-rwsrwsrwt. 1 root root 11549 Dec 29  2012 LICENSE

drwxr-xr-x. 2 root root  4096 Dec 29  2012 logs

-rwsrwsrwt. 1 root root   428 Dec 29  2012 README

[[email protected] cobar-server-1.2.7]# cd conf/

[[email protected] conf]# ll

total 16

-rw-r--r--. 1 root root 2604 Dec 29  2012 log4j.xml

-rw-r--r--. 1 root root 1262 Dec 29  2012 rule.xml

-rw-r--r--. 1 root root 1966 Dec 29  2012 schema.xml    --mysql数据库的IP,端口

-rw-r--r--. 1 root root 2292 Dec 29  2012 server.xml

[[email protected] conf]# vim schema.xml

原文:http://tongcheng.blog.51cto.com/6214144/1651162

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值