MySQL如何实现万亿级数据存储?

可以看到,我们在Mycat的schema.xml文件中配置的dataHost节点的信息,成功写入到Zookeeper中了。

为了验证Mycat的配置信息,是否已经同步到Zookeeper的其他节点上,我们也可以在binghe152和binghe153服务器上登录Zookeeper,查看Mycat配置信息是否写入成功。

  • binghe152服务器

[root@binghe152 ~]# zkCli.sh

Connecting to localhost:2181

#################省略N行输出信息################

[zk: localhost:2181(CONNECTED) 0] get /mycat/mycat-cluster-1/schema/dataHost

[{“balance”:1,“maxCon”:1000,“minCon”:10,“name”:“binghe151”,“writeType”:0,“switchType”:1,“slaveThreshold”:100,“dbType”:“mysql”,“dbDriver”:“native”,“heartbeat”:“select user()”,“writeHost”:[{“host”:“binghe51”,“url”:“192.168.175.151:3306”,“password”:“root”,“user”:“root”}]},{“balance”:1,“maxCon”:1000,“minCon”:10,“name”:“binghe152”,“writeType”:0,“switchType”:1,“slaveThreshold”:100,“dbType”:“mysql”,“dbDriver”:“native”,“heartbeat”:“select user()”,“writeHost”:[{“host”:“binghe52”,“url”:“192.168.175.152:3306”,“password”:“root”,“user”:“root”}]},{“balance”:1,“maxCon”:1000,“minCon”:10,“name”:“binghe153”,“writeType”:0,“switchType”:1,“slaveThreshold”:100,“dbType”:“mysql”,“dbDriver”:“native”,“heartbeat”:“select user()”,“writeHost”:[{“host”:“binghe53”,“url”:“192.168.175.153:3306”,“password”:“root”,“user”:“root”}]},{“balance”:1,“maxCon”:1000,“minCon”:10,“name”:“binghe154”,“writeType”:0,“switchType”:1,“slaveThreshold”:100,“dbType”:“mysql”,“dbDriver”:“native”,“heartbeat”:“select user()”,“writeHost”:[{“host”:“binghe54”,“url”:“192.168.175.154:3306”,“password”:“root”,“user”:“root”}]}]

可以看到,Mycat的配置信息成功同步到了binghe152服务器上的Zookeeper中。

  • binghe153服务器

[root@binghe153 ~]# zkCli.sh

Connecting to localhost:2181

#####################此处省略N行输出信息#####################

[zk: localhost:2181(CONNECTED) 0] get /mycat/mycat-cluster-1/schema/dataHost

[{“balance”:1,“maxCon”:1000,“minCon”:10,“name”:“binghe151”,“writeType”:0,“switchType”:1,“slaveThreshold”:100,“dbType”:“mysql”,“dbDriver”:“native”,“heartbeat”:“select user()”,“writeHost”:[{“host”:“binghe51”,“url”:“192.168.175.151:3306”,“password”:“root”,“user”:“root”}]},{“balance”:1,“maxCon”:1000,“minCon”:10,“name”:“binghe152”,“writeType”:0,“switchType”:1,“slaveThreshold”:100,“dbType”:“mysql”,“dbDriver”:“native”,“heartbeat”:“select user()”,“writeHost”:[{“host”:“binghe52”,“url”:“192.168.175.152:3306”,“password”:“root”,“user”:“root”}]},{“balance”:1,“maxCon”:1000,“minCon”:10,“name”:“binghe153”,“writeType”:0,“switchType”:1,“slaveThreshold”:100,“dbType”:“mysql”,“dbDriver”:“native”,“heartbeat”:“select user()”,“writeHost”:[{“host”:“binghe53”,“url”:“192.168.175.153:3306”,“password”:“root”,“user”:“root”}]},{“balance”:1,“maxCon”:1000,“minCon”:10,“name”:“binghe154”,“writeType”:0,“switchType”:1,“slaveThreshold”:100,“dbType”:“mysql”,“dbDriver”:“native”,“heartbeat”:“select user()”,“writeHost”:[{“host”:“binghe54”,“url”:“192.168.175.154:3306”,“password”:“root”,“user”:“root”}]}]

可以看到,Mycat的配置信息成功同步到了binghe153服务器上的Zookeeper中。

[](()配置Mycat支持Zookeeper启动


1.在binghe151服务器上配置Mycat

在binghe151服务器上进入Mycat安装目录的conf目录下,查看文件信息,如下所示。

[root@binghe151 ~]# cd /usr/local/mycat/conf/

[root@binghe151 conf]# ll

total 108

-rwxrwxrwx 1 root root 92 Feb 26 17:10 autopartition-long.txt

-rwxrwxrwx 1 root root 51 Feb 26 17:10 auto-sharding-long.txt

-rwxrwxrwx 1 root root 67 Feb 26 17:10 auto-sharding-rang-mod.txt

-rwxrwxrwx 1 root root 340 Feb 26 17:10 cacheservice.properties

-rwxrwxrwx 1 root root 3338 Feb 26 17:10 dbseq.sql

-rwxrwxrwx 1 root root 3532 Feb 26 17:10 dbseq - utf8mb4.sql

-rw-r–r-- 1 root root 86 Mar 1 22:37 dnindex.properties

-rwxrwxrwx 1 root root 446 Feb 26 17:10 ehcache.xml

-rwxrwxrwx 1 root root 2454 Feb 26 17:10 index_to_charset.properties

-rwxrwxrwx 1 root root 1285 Feb 26 17:10 log4j2.xml

-rwxrwxrwx 1 root root 183 Feb 26 17:10 migrateTables.properties

-rwxrwxrwx 1 root root 271 Feb 26 17:10 myid.properties

-rwxrwxrwx 1 root root 16 Feb 26 17:10 partition-hash-int.txt

-rwxrwxrwx 1 root root 108 Feb 26 17:10 partition-range-mod.txt

-rwxrwxrwx 1 root root 988 Mar 1 16:59 rule.xml

-rwxrwxrwx 1 root root 3883 Mar 3 23:59 schema.xml

-rwxrwxrwx 1 root root 440 Feb 26 17:10 sequence_conf.properties

-rwxrwxrwx 1 root root 84 Mar 3 23:52 sequence_db_conf.properties

-rwxrwxrwx 1 root root 29 Feb 26 17:10 sequence_distributed_conf.properties

-rwxrwxrwx 1 root root 28 Feb 26 17:10 sequence_http_conf.properties

-rwxrwxrwx 1 root root 53 Feb 26 17:10 sequence_time_conf.properties

-rwxrwxrwx 1 root root 2420 Mar 4 15:14 server.xml

-rwxrwxrwx 1 root root 18 Feb 26 17:10 sharding-by-enum.txt

-rwxrwxrwx 1 root root 4251 Feb 28 20:51 wrapper.conf

drwxrwxrwx 2 root root 4096 Feb 28 21:17 zkconf

drwxrwxrwx 2 root root 4096 Feb 28 21:17 zkdownload

可以看到,在Mycat的conf目录下,存在一个myid.properties文件,接下来,使用vim编辑器编辑这个文件,如下所示。

vim myid.properties

编辑后的myid.properties文件的内容如下所示。

loadZk=true

zkURL=192.168.175.151:2181,192.168.175.152:2181,192.168.175.153:2181

clusterId=mycat-cluster-1

myid=mycat_151

clusterSize=2

clusterNodes=mycat_151,mycat_154

#server booster ; booster install on db same server,will reset all minCon to 2

type=server

boosterDataHosts=dataHost1

其中几个重要的参数说明如下所示。

  • loadZk:表示是否加载Zookeeper配置。true:是; false:否;

  • zkURL:Zookeeper的连接地址,多个Zookeeper连接地址以逗号隔开;

  • clusterId:当前Mycat集群的Id标识,此标识需要与Zookeeper中/mycat目录下的目录名称相同,如下所示。

[zk: localhost:2181(CONNECTED) 1] ls /mycat

[mycat-cluster-1]

  • myid:当前Mycat节点的id,这里我的命名方式为mycat_前缀加上IP地址的最后三位;

  • clusterSize:表示Mycat集群中的Mycat节点个数,这里,我们在binghe151和binghe154节点上部署Mycat,所以Mycat节点的个数为2。

  • clusterNodes:Mycat集群中,所有的Mycat节点,此处的节点需要配置myid中配置的Mycat节点id,多个节点之前以逗号分隔。这里我配置的节点为:mycat_151,mycat_154。

2.在binghe154服务器上安装全新的Mycat

在binghe154服务器上下载并安装和binghe151服务器上相同版本的Mycat,并将其解压到binghe

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值