Mycat learning - start mycat alone

Mycat Download: http://mycat.io/
Mycat Installation: unzip.
 
As a Mycat middleware, realization mysql protocol, can not rely on a separate database operation.
It is connected to a front-end application database, there is also the configuration database, database configuration mycat is configured in schema.xml, after configuring the user is mapped to the server.xml inside it.
 
Follows a simple configuration can be started up separately mycat.
 

conf/schema.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">

<mycat:schema  xmlns:mycat="http://io.mycat/">
  <schema name="TESTDB" checkSQLschema="true" sqlMaxLimit="100" dataNode="dn1">
      <table name="t_user" dataNode="dn1,dn2" rule="auto-sharding-long"/>
      <table name="ht_jy_login_log" primaryKey="ID" dataNode="dn1,dn2" rule="auto-sharding-long"/>
  </schema>
  <dataNode name="dn1" dataHost="localhost1" database="mycat_node1"/>
  <dataNode name="dn2" dataHost="localhost1" database="mycat_node2"/>

  <dataHost name="localhost1" writeType="0" switchType="1" slaveThreshold="100" balance="1" dbType="mysql" maxCon="10" minCon="1" dbDriver="native">
    <heartbeat>show status like 'wsrep%'</heartbeat>
    <writeHost host="hostM1" url="127.0.0.1:3306" user="root" password="root" >
    </writeHost>
  </dataHost>
</mycat:schema >

 

conf/server.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE mycat:server SYSTEM "server.dtd">
<mycat:server xmlns:mycat="http://io.mycat/">
<user name="mycat">
    <property name="password">mycat</property>
    <property name="schemas">TESTDB</property>
</user>
 </mycat:server>

 

Start bin / mycat

[root@localhost conf]# mycat start
Starting Mycat-server...
[root@localhost conf]# mycat status
Mycat-server is running (33384).
If the startup fails, check the log logs / wrapper.log.  

 

Login mycat

[root@localhost logs]# mysql -h 127.0.0.1 -umycat -pmycat -P8066
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.29-mycat-1.6.7.3-release-20190927161129 MyCat Server (OpenCloudDB)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]>  select * from help;
ERROR 3000 (HY000): No MyCAT Database selected
MySQL [(none)]> show databases;
+----------+
| DATABASE |
+----------+
| TESTDB   |
+----------+
1 row in set (0.03 sec)

MySQL [(none)]> use TESTDB
Database changed
MySQL [TESTDB]> select * from help;
ERROR 1184 (HY000): Invalid DataSource:0

 

 

Guess you like

Origin www.cnblogs.com/plluoye/p/11716585.html