Deploying Ali Cobar server under Linux

Source: Internet
Author: User
Tags log4j

1,cobar Project

The official website has been migrated to GitHub.
Https://github.com/alibaba/cobar
Download:
Https://github.com/alibaba/cobar/wiki/%E4%B8%8B%E8%BD%BD

Cobar is a distributed processing system of relational data that can look like a traditional database in a distributed environment to provide you with massive data services.

2,cobar Solve the problem

Distributed: Cobar is distributed primarily by placing tables in different libraries:
1. Cobar supports splitting a table horizontally into multiple copies into separate libraries to achieve horizontal split of the table
2. Cobar also supports placing different tables in different libraries
3. In most cases, users will mix the above two ways. It is important to emphasize that Cobar does not support splitting a table, such as the test table, into Test_1, test_2, test_3 .... In the same library, the split tables must be placed in separate libraries for distribution.

HA: In the case of the user configured MySQL heartbeat, Cobar can automatically send the heartbeat to the back-end connection MySQL, judge the MySQL health, once the operation is abnormal, Cobar can automatically switch to the standby machine work. However, it should be emphasized that:

1. Cobar的主备切换有两种触发方式,一种是用户手动触发,一种是Cobar的心跳语句检测到异常后自动触 发。那么,当心跳检测到主机异常,切换到备机,如果主机恢复了,需要用户手动切回主机工作,Cobar不 会在主机恢复时自动切换回主机,除非备机的心跳也返回异常。2. Cobar只检查MySQL主备异常,不关心主备之间的数据同步,因此用户需要在使用Cobar之前在MySQL主 备上配置双向同步,详情可以参阅MySQL参考手册。

dataSource:dataNode:数据节点,由主、备数据源,数据源的HA以及连接池共同组成,可以将一个dataNode理解为一 个分库。table:tableRule:路由规则,用于判断SQL语句被路由到具体哪些datanode执行。 schema:cobar可以定义包含拆分表的schema(如schema1),也可以定义无拆分表的schema(如 schema2)。 以上层次关系具有较强的灵活性,用户可以将表自由放置不同的datanode,也可将不同的datasource放置在 同一MySQL实例上。
3, Service Catalog

After decompression, enter the cobar-server-1.2.4 directory, you can see the main directory of Cobar as follows:

#包含Cobar的启动、重启、停止等脚本文件 #包含Cobar所有配置文件lib#包含Cobar及其依赖的jar文件#包含Cobar所有日志文件

????????? Start Script Cobar All of the start-stop scripts in the bin directory, into the bin directory, you can see:

startup.sh#Linux环境启动脚本 restart.sh#Linux环境重启脚本 shutdown.sh#Linux环境停止脚本

All configuration files for profile Cobar are placed in the Conf directory, and into the Conf directory, you can see:

server.xml#Cobar系统、用户、集群等相关配置 schema.xml#schema,dataNode,dataSource相关配置 rule.xml#分布式规则定义log4j.xml#日志相关配置

For more detailed reference documentation:
http://blog.csdn.net/shagoo/article/details/8191346

4,cobar Admin follows

https://github.com/alibaba/cobar/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E7%AD%94
Written in the FAQ:

1.Modify Web-inf/or source code Src/main/resource/log4j log output path, log level is adjusted to info and above2.The Web-inf/or source code Src/main/resource/Cluster in the.XML, Cobar.XML, the user.XML, property.XMLCopy to a fixed directory, such as/home/admin/XML/  3.Modify Web-inf/xmlpath.The contents of the file in the properties are Xmlpath=/home/admin/XML/  4.Source package, put the war package into the Web container to execute5.User.XMLThe initial user name and password for the record is root/123456

Restart Tomcat and enter the login screen:

Enter Password root,123456

Enter the system. You can view configuration, access conditions.

At the same time can increase the Cobar node, the password configuration of the node inside the conf/server.xml.

<!-- 用户访问定义,用户名、密码、schema等信息。 -->  <user name="test">    <property name="password">test</property>    <property name="schemas">dbtest</property>  </user>

(http://img.blog.csdn.net/20150302194710221)
After adding success, you can see it in node management.

5, Start Cobar-server

Modify the Conf/schema.xml database connection address.
Then start the error:

#!Cobar#dnTest2 init failure

The data table was not created.

#创建dbtest1 Drop database if exists dbtest1; Create database dbtest1;Use Dbtest1; #在dbtest1上创建tb1 Create table tb1 (id int  not null, GMT datetime);#创建dbtest2 Drop database if exists dbtest2; Create database dbtest2;Use Dbtest2; #在dbtest2上创建tb2 Create table tb2 (id int  not null, val varchar(
     
      256));
     #创建dbtest3 Drop database if exists dbtest3; Create database dbtest3;Use DBTEST3; #在dbtest3上创建tb2 Create table tb2 (id int  not null, val varchar(256));

* * A problem is found if you use MARIADB 5.5 to query for data tables.
You must use the MYSQ database. The database I installed on CENTOS6 (MySQL 5.1.73) is not available on the MariaDB database above the CENTOS7 (MariaDB 5.5.40). **

The test data was successful.

# mysql-h127.0.0.1-utest-ptest-p8066-ddbtestreading table information for completion of table and column namesyou can  Turn off this feature to get a quicker startup With-awelcome to the MySQL Monitor. Commands End With; or \g.your MySQL connection ID is 2Server version:5.1.48-cobar-1.2.7 cobar Server (ALIBABA) Copyright (c) #, Orac Le and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names trademarks of their respectiveowners. Type' help; 'Or' \h 'For help. Type' \c 'To clear the current input statement.mysql> Show tables;+------------------+| Tables_in_dbtest |+------------------+| tb1 || tb2 |+------------------+2 rows in Set (0.00 sec) mysql> Insert to TB1 (ID, GMT) VALUES (1, now ()); Query OK, 1 row affected (0.02 sec) mysql> INSERT into TB2 (ID, Val) VALUES (1, "part1"); Query OK, 1 row affected (0.01 sec) mysql> INSERT into TB2 (ID, Val) VALUES (2, "Part1"), (513, "part2"); Query OK, 2 rows affected (0.03 sec)mysql> SELECT * from tb1;+----+---------------------+| id | GMT |+----+---------------------+| 1 | 2015-03-02 19:36:18 |+----+---------------------+1 row in Set (0.01 sec)mysql> SELECT * FROM tb2;+-----+-------+| id | val |+-----+-------+| 1 |   Part1 | | 2 | Part1 || 513 | part2 |+-----+-------+3 Rows in Set (0.00 sec)
5, summary

Cobar preliminary tests have been completed. The horizontal and vertical extensions have been well addressed.
And only need to modify the configuration can be implemented. It's perfectly smooth to switch over.
Next, explore the cluster scenario.

Deploying Ali Cobar server under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.