标签:name 筛选 als rtb 连接 multi default hit -name
如果是在单机上,可以使用docker 模拟多个MySQL。
sudo sudo docker run --name mysql -p 12345:3306 -e MYSQL_ROOT_PASSWORD=xxx -d mysql
查看所有的容器,包括运行与停止的
sudo docker ps -a
查看运行的容器
sudo docker ps
筛选容器
sudo docker ps --filter "status=exited"
运行之前运行过,但是停止的容器
sudo docker start e9b454ca373e ee21a1c84c54
创建一个测试表,如果没有表,或者没有配置,mycat启动会失败的
CREATE TABLE `c` (
`id` bigint(20) unsigned zerofill NOT NULL AUTO_INCREMENT,
`a` varchar(255) CHARACTER SET utf8mb4 NOT NULL DEFAULT ‘‘ COMMENT ‘sdfsdfsdf‘,
`b` bigint(255) DEFAULT NULL COMMENT ‘skdjflksadf‘,
`c` int(255) DEFAULT NULL COMMENT ‘isdfasdfsdf‘,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1012791 DEFAULT CHARSET=latin1 STATS_PERSISTENT=0
配置账户
登录的账号密码:
gs@gs-virtual-machine:~/Downloads/mycat$ vim conf/server.xml
<property name="spillsFileBufferSize">1k</property>
<property name="useStreamOutput">0</property>
<!--
单位为m
-->
<property name="systemReserveMemorySize">384m</property>
<!--是否采用zookeeper协调切换 -->
<property name="useZKSwitch">true</property>
</system><!-- 全局SQL防火墙设置 -->
<firewall>
<whitehost>
<host host="127.0.0.1" user="gs"/>
</whitehost>
<blacklist check="false">
</blacklist>
</firewall><user name="gxsdfqs">
<property name="password">xxxx</property>
<property name="schemas">test</property><!-- 表级 DML 权限设置 -->
<!--
<privileges check="false">
<schema name="TESTDB" dml="0110" >
<table name="tb01" dml="0000"></table>
<table name="tb02" dml="1111"></table>
</schema>
</privileges>
-->
</user></mycat:server>
配置节点
gs@gs-virtual-machine:~/Downloads/mycat$ vim conf/schema.xml
<?xml version="1.0"?>
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://io.mycat/"><schema name="test" checkSQLschema="false" sqlMaxLimit="100">
<!-- auto sharding by id (long) -->
<!-- <table name="a" dataNode="dn1, dn2, dn3" rule="mod-long" /> -->
<table name="b" primaryKey=‘id‘ dataNode="dn1, dn2, dn3" rule="mod-long" />
<table name="c" primaryKey=‘id‘ dataNode="dn1, dn2, dn3" rule="mod-long" />
<!-- <table name="oc_call" primaryKey="ID" dataNode="dn1$0-743" rule="latest-month-calldate"
/> -->
</schema>
<!-- <dataNode name="dn1$0-743" dataHost="localhost1" database="db$0-743"
/> -->
<dataNode name="dn1" dataHost="localhost1" database="test" />
<dataNode name="dn2" dataHost="localhost2" database="test" />
<dataNode name="dn3" dataHost="localhost3" database="test" />
<!--<dataNode name="dn4" dataHost="sequoiadb1" database="SAMPLE" />
<dataNode name="jdbc_dn1" dataHost="jdbchost" database="db1" />
<dataNode name="jdbc_dn2" dataHost="jdbchost" database="db2" />
<dataNode name="jdbc_dn3" dataHost="jdbchost" database="db3" /> -->
<dataHost name="localhost1" maxCon="1000" minCon="10" balance="0"
writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
<heartbeat>select user()</heartbeat>
<!-- can have multi write hosts -->
<writeHost host="hostM1" url="localhost:3306" user="gs"
password="gxxxs">
<!-- can have multi read hosts -->
</writeHost>
<!-- <writeHost host="hostM2" url="localhost:3316" user="root" password="123456"/> -->
</dataHost>
<dataHost name="localhost2" maxCon="1000" minCon="10" balance="0"
writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
<heartbeat>select user()</heartbeat>
<!-- can have multi write hosts -->
<writeHost host="hostM2" url="localhost:12306" user="gs"
password="gxxxs">
<!-- can have multi read hosts -->
</writeHost>
<!-- <writeHost host="hostM2" url="localhost:3316" user="root" password="123456"/> -->
</dataHost>
<dataHost name="localhost3" maxCon="1000" minCon="10" balance="0"
writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
<heartbeat>select user()</heartbeat>
<!-- can have multi write hosts -->
<writeHost host="hostM3" url="localhost:12307" user="gxxxs"
password="gxxxs">
<!-- can have multi read hosts -->
</writeHost>
<!-- <writeHost host="hostM2" url="localhost:3316" user="root" password="123456"/> -->
</dataHost>
<!--
<dataHost name="sequoiadb1" maxCon="1000" minCon="1" balance="0" dbType="sequoiadb" dbDriver="jdbc">
<heartbeat> </heartbeat>
<writeHost host="hostM1" url="sequoiadb://1426587161.dbaas.sequoialab.net:11920/SAMPLE" user="jifeng" password="jifeng"></writeHost>
</dataHost><dataHost name="oracle1" maxCon="1000" minCon="1" balance="0" writeType="0" dbType="oracle" dbDriver="jdbc"> <heartbeat>select 1 from dual</heartbeat>
<connectionInitSql>alter session set nls_date_format=‘yyyy-mm-dd hh24:mi:ss‘</connectionInitSql>
<writeHost host="hostM1" url="jdbc:oracle:thin:@127.0.0.1:1521:nange" user="base" password="123456" > </writeHost> </dataHost><dataHost name="jdbchost" maxCon="1000" minCon="1" balance="0" writeType="0" dbType="mongodb" dbDriver="jdbc">
<heartbeat>select user()</heartbeat>
<writeHost host="hostM" url="mongodb://192.168.0.99/test" user="admin" password="123456" ></writeHost> </dataHost><dataHost name="sparksql" maxCon="1000" minCon="1" balance="0" dbType="spark" dbDriver="jdbc">
<heartbeat> </heartbeat>
<writeHost host="hostM1" url="jdbc:hive2://feng01:10000" user="jifeng" password="jifeng"></writeHost> </dataHost> -->
</mycat:schema>
gs@gs-virtual-machine:~/Downloads/mycat/bin$ ls
dataMigrate.sh init_zk_data.sh mycat rehash.sh startup_nowrap.sh wrapper-linux-ppc-64 wrapper-linux-x86-32 wrapper-linux-x86-64
gs@gs-virtual-machine:~/Downloads/mycat/bin$ ./mycat start
Starting Mycat-server...
Removed stale pid file: /home/gs/Downloads/mycat/logs/mycat.pid
查看日志:
~/Downloads/mycat$ tail -f logs/mycat.log
连接
mysql -uroot -P8066 -p
mysql> select count(*) from test.c;
+----------+
| count(*) |
+----------+
| 4263 |
+----------+
1 row in set (0.01 sec)
标签:name 筛选 als rtb 连接 multi default hit -name
原文地址:https://www.cnblogs.com/studyNT/p/9302234.html