cobar配置安装_MySQL
bitsCN.com
1、下载cobar http://code.alibabatech.com/wiki/display/cobar/release
2、进入cobar-server-1.2.4目录,可以看到Cobar的主要目录如下:
bin #包含Cobar的启动、重启、停止等脚本文件
conf #包含Cobar所有配置文件
lib #包含Cobar及其依赖的jar文件
logs #包含Cobar所有日志文件
3、Cobar的所有配置文件全部放在conf目录中,进入conf目录,可以看到:
server.xml #Cobar系统、用户、集群等相关配置
schema.xml #schema,dataNode,dataSource相关配置
rule.xml #分布式规则定义
log4j.xml #日志相关配置
4、mysql中数据准备
配置两台机器的mysql,ip地址分别为:192.168.1.110 、 192.168.1.113 端口为3306 用户名 root 密码为空。我们需要在 192.168.1.110上创建database:dbtest1,dbtest2,dbtest3;table:tb1(在dbtest1上),tb2(dbtest2、dbtest3上)。在192.168.1.113上创建database:dbtest31,dbtest32;table:tb1(dbtest31上),tb2(dbtest32上)
数据库创建脚本:
#########################################192.168.1.110 #创建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)); #########################################192.168.1.113 #创建dbtest31 drop database if exists dbtest1; create database dbtest1; use dbtest31; #在dbtest1上创建tb1 create table tb1( id int not null, gmt datetime); #创建dbtest32 drop database if exists dbtest2; create database dbtest2; use dbtest32; #在dbtest2上创建tb2 create table tb2( id int not null, val varchar(256)); |
5、配置schema.xml
参考:http://code.alibabatech.com/wiki/pages/viewpage.action?pageId=7671478
请确保机器上设置了JAVA环境变量JAVA_HOME
|
此处要注意开启远程连接root用户的权限
grant all privileges on *.* to root#'%'
6、配置rule.xml
tableRule
tableRule主要作用是用来判断SQL语句路由到哪些datanode执行,Cobar是通过在SQL中提取一个或多个字段的值,并根据这些字段的值来决定路由到哪个库执行。因此,tableRule定义两个要素:
1)按表中的哪个字段路由?------下文中我们称此字段为路由字段
2)有了字段值,如何路由?------即路由函数
|
function
参考:http://code.alibabatech.com/wiki/pages/viewpage.action?pageId=7671871
|
7、配置server.xml
System
|
User
-->
-->
|
Cluster
在实际应用中,经常需要部署一个Cobar集群,我们称集群中的一台Cobar为一个Cobar节点。
|
用户只需登录Cobar的服务端口(8066),运行Cobar自带的查询命令show cobar_cluster,便可查询集群中所有节点的运行情况以及权重,并根据查询结果做负载均衡。
mysql -h192.168.1.110 -utest -ptest -P8066
mysql>show cobar_cluster; #查询cluster配置中正常的Cobar节点
+---------------+--------+
| HOST | WEIGHT |
+---------------+--------+
| 192.168.1.110 | 1 |
| 192.168.1.113 | 2 |
+---------------+--------+
注意:
1)如果需要配置Cobar集群,当前Cobar自身也需要作为一个节点配置在cluster中,Cobar不会默认向自己发心跳;
2)show cobar_cluster只显示cluster配置中得正常Cobar节点,如果节点异常(如超时或错误),结果中便不会包含此节点。
8、访问方式
由于Cobar遵循MySQL协议,访问Cobar的方式与访问MySQL数据库完全相同。
支持MySQL命令行方式访问
#命令行
mysql -h192.168.1.110 -utest -ptest -P8066 -Ddb_shard
bitsCN.com
Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

When you log in to someone else's steam account on your computer, and that other person's account happens to have wallpaper software, steam will automatically download the wallpapers subscribed to the other person's account after switching back to your own account. Users can solve this problem by turning off steam cloud synchronization. What to do if wallpaperengine downloads other people's wallpapers after logging into another account 1. Log in to your own steam account, find cloud synchronization in settings, and turn off steam cloud synchronization. 2. Log in to someone else's Steam account you logged in before, open the Wallpaper Creative Workshop, find the subscription content, and then cancel all subscriptions. (In case you cannot find the wallpaper in the future, you can collect it first and then cancel the subscription) 3. Switch back to your own steam

Recently, many users have been asking the editor, how to download links starting with 115://? If you want to download links starting with 115://, you need to use the 115 browser. After you download the 115 browser, let's take a look at the download tutorial compiled by the editor below. Introduction to how to download links starting with 115:// 1. Log in to 115.com, download and install the 115 browser. 2. Enter: chrome://extensions/ in the 115 browser address bar, enter the extension center, search for Tampermonkey, and install the corresponding plug-in. 3. Enter in the address bar of 115 browser: Grease Monkey Script: https://greasyfork.org/en/

The superpeople game can be downloaded through the steam client. The size of this game is about 28G. It usually takes one and a half hours to download and install. Here is a specific download and installation tutorial for you! New method to apply for global closed testing 1) Search for "SUPERPEOPLE" in the Steam store (steam client download) 2) Click "Request access to SUPERPEOPLE closed testing" at the bottom of the "SUPERPEOPLE" store page 3) After clicking the request access button, The "SUPERPEOPLECBT" game can be confirmed in the Steam library 4) Click the install button in "SUPERPEOPLECBT" and download

Many users need to download files when using Quark Network Disk, but we want to save them locally, so how to set this up? Let this site introduce to users in detail how to save files downloaded from Quark Network Disk back to the local computer. How to save files downloaded from Quark network disk back to your local computer 1. Open Quark, log in to your account, and click the list icon. 2. After clicking the icon, select the network disk. 3. After entering Quark Network Disk, click My Files. 4. After entering My Files, select the file you want to download and click the three-dot icon. 5. Check the file you want to download and click Download.

If you have successfully downloaded the installation file of Baidu Netdisk, but cannot install it normally, it may be that there is an error in the integrity of the software file or there is a problem with the residual files and registry entries. Let this site take care of it for users. Let’s introduce the analysis of the problem that Baidu Netdisk is successfully downloaded but cannot be installed. Analysis of the problem that Baidu Netdisk downloaded successfully but could not be installed 1. Check the integrity of the installation file: Make sure that the downloaded installation file is complete and not damaged. You can download it again, or try to download the installation file from another trusted source. 2. Turn off anti-virus software and firewall: Some anti-virus software or firewall programs may prevent the installation program from running properly. Try disabling or exiting the anti-virus software and firewall, then re-run the installation

foobar2000 is a software that can listen to music resources at any time. It brings you all kinds of music with lossless sound quality. The enhanced version of the music player allows you to get a more comprehensive and comfortable music experience. Its design concept is to play the advanced audio on the computer The device is transplanted to mobile phones to provide a more convenient and efficient music playback experience. The interface design is simple, clear and easy to use. It adopts a minimalist design style without too many decorations and cumbersome operations to get started quickly. It also supports a variety of skins and Theme, personalize settings according to your own preferences, and create an exclusive music player that supports the playback of multiple audio formats. It also supports the audio gain function to adjust the volume according to your own hearing conditions to avoid hearing damage caused by excessive volume. Next, let me help you

As a convenient and practical network disk tool, Quark can help users easily obtain their favorite resources. What if you want to download a file locally? Let the editor tell you now, let’s learn it together! How to download Quark Network Disk to local sharing method 1. First open the Quark software, enter the homepage, and click the [Cloud Icon] on the lower right; 2. Then on the Quark Network Disk page, we click the [Document] function; 3. Then go to the document page, select the file you want to download, and click the [three-dot icon]; 4. After the final click, we click [Download] in the pop-up dialog box;

Installing Android applications on Linux has always been a concern for many users. Especially for Linux users who like to use Android applications, it is very important to master how to install Android applications on Linux systems. Although running Android applications directly on Linux is not as simple as on the Android platform, by using emulators or third-party tools, we can still happily enjoy Android applications on Linux. The following will introduce how to install Android applications on Linux systems.
