欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

mysql分布式中间件cobar

程序员文章站 2024-02-14 08:25:16
...

Cobar的分布式主要是通过将表放入不同的库来实现:1.Cobar支持将一张表水平拆分成多份分别放入不同的库来实现表的水平拆分2.Cobar也支持将不同的表放入不..

Cobar的分布式主要是通过将表放入不同的库来实现:
1.Cobar支持将一张表水平拆分成多份分别放入不同的库来实现表的水平拆分
2.Cobar也支持将不同的表放入不同的库
3.多数情况下,用户会将以上两种方式混合使用
4.Cobar不支持将一张表,例如test表拆分成test_1, test_2, test_3.....放在同一个库中,必须将拆分后的表分别放入不同的库来实现分布式


缺点:

1.不支持跨库的关联操作:join、分页、排序、子查询

2.不支持SAVEPOINT操作

3.不支持SET语句的执行,,事务和字符集设置语句除外

4.只支持MySQL数据节点

5.对于拆分表,插入操作须给出列名,必须包含拆分字段

环境规划:

IP 数据库 表

192.168.1.247 test01 t1

192.168.1.247 test02 t1

192.168.1.247 test03 t1

说明:在本服务器创建三个数据库,数据库中创建相同的表和表类型,将t1表中的数据拆分到teat01,02,03数据库中.

1.创建数据库和表

[root@tong1 ~]# /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> grant all privileges on *.* to tong@'localhost' identified by 'system';
Query OK, 0 rows affected (0.05 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.06 sec)

mysql> exit
Bye
[root@tong1 bin]#

2.安装java开发软件包

[root@tong1 ~]# tar xvf jdk-7u71-linux-x64.tar.gz -C /usr/local/

[root@tong1 ~]# cd /usr/local/

[root@tong1 local]# chown -R root:root jdk1.7.0_71/

[root@tong1 local]# vim /etc/profile --添加环境变量

export PATH=$PATH:/usr/local/protobuf-2.5.0/bin:/usr/local/jdk1.7.0_71/bin
export JAVA_HOME=/usr/local/jdk1.7.0_71/
export CLASS_HOME=/usr/local/jdk1.7.0_71/lib

[root@tong1 local]# . /etc/profile

[root@tong1 local]# java -version --查看java是否安装成功
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
[root@tong1 local]#

3.下载安装cobar

下载地址:

[root@tong1 ~]# tar xvf cobar-server-1.2.7.tar.gz -C /usr/local/

[root@tong1 ~]# cd /usr/local/cobar-server-1.2.7/
[root@tong1 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

[root@tong1 cobar-server-1.2.7]# cd conf/
[root@tong1 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

[root@tong1 conf]# vim schema.xml