mycat1.6.6.1 separate read and write

--mycat1.6.6.1 separate read and write
- standby library give permission
Grant ON * * All privileges to the root @ '%' IDENTIFIED by 'Oracle';.
the flush privileges;

vi /etc/profile

export JAVA_HOME=/usr/java/latest
#export CLASSPATH=.:$JAVA_HOME/lib
#export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export MYCAT_HOME=/opt/mycat
export PATH=$PATH:$MYCAT_HOME/bin

- Modify logs for Debug:
vim /usr/local/mycat/conf/log4j.xml

<root>
<level value="debug" />
<appender-ref ref="FILE" />
<!--<appender-ref ref="FILE" />-->
</root>

- we can use the mysql client to connect to connect or navicat mycat
- MySQL-uroot--h192.168.92.14 -P8066 -pmysql not landed
- could lead to mycat service to get up after configuration changes conf
mysql -utest - h192.168.92.14 -P8066 -pmysql

- If the configuration file is incorrect, resulting in: DID not the JVM ON Exit Request, terminated
- following configuration table only company allowed to write in the main library and not allowed to read
vi schema.xml

<?xml version="1.0"?>
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://io.mycat/">
<schema name="mydb1" checkSQLschema="true" sqlMaxLimit="100">
<table name="t_order" primaryKey="uuid" autoIncrement="true" dataNode="dn1"/>
<table name="t_user" primaryKey="uuid" autoIncrement="true" dataNode="dn2"/>
<table name="company" primaryKey="ID" type="global" dataNode="dn3" />
</schema>

<dataNode name="dn1" dataHost="dhost1" database="orderdb" />
<dataNode name="dn2" dataHost="dhost1" database="userdb" />
<dataNode name="dn3" dataHost="dhost2" database="userdb" />

<dataHost name="dhost1" maxCon="1000" minCon="10" balance="1" writeType="0" dbType="mysql" dbDriver="native">
<heartbeat>select user()</heartbeat>
<writeHost host="myhostM1" url="192.168.92.14:3306" user="root" password="oracle">
<readHost host="myhostS1" url="192.168.92.16:3306"
user="root" password="oracle" weight="1" />
</writeHost>
</dataHost>
<dataHost name="dhost2" maxCon="1000" minCon="10" balance="1" writeType="0" dbType="mysql" dbDriver="native">
<heartbeat>select user()</heartbeat>
<writeHost host="myhostM2" url="192.168.92.14:3306" user="root" password="oracle"></writeHost>
</dataHost>
</mycat:schema>

vi server.xml configuration as final user, comment out the last of the excess mycat schema: TESTDB

<user name="root" defaultAccount="true">
<property name="password">oracle</property>
<property name="schemas">mydb1</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>

<-! Schema.xml TESTDB has not, so the comment out the following user ->
<-!
<User name = "User">
<Property name = "password"> User </ Property>
<Property name = "schemas"> the TESTDB </ Property>
<Property name = "readOnly"> to true </ Property>
</ User>
->

--mycat startup error
the Startup failed The: Waiting for the Timed OUT A at The Signal from the JVM.
the JVM ON DID not Exit Request, terminated
solution: add wrapper.conf in this case less wrapper.startup.timeout
wrapper.startup.timeout timeout = 300 // 300 seconds
wrapper.ping.timeout = 120

- change log mode Debug
VI /opt/mycat/conf/log4j2.xml info modify Debug
<asyncRoot Level = "Debug" includeLocation = "to true">

<!--<AppenderRef ref="Console" />-->
<AppenderRef ref="RollingFile"/>

</asyncRoot>

--以前的版本参考:
<root>
<level value="debug" />
<appender-ref ref="FILE" />
<!--<appender-ref ref="FILE" />-->
</root>


- Run the start command to start mycat reference startup_nowrap.sh

Start & myCat
--navicat via port 8066 mycat, the following command line connected myCat
MySQL -uroot--h192.168.92.14 -P8066 -poracle

- query debug log, as follows, and may be determined as the corresponding execution node sql execution log according to the corresponding attachment key
tail -f /opt/mycat/logs/mycat.log

to send query cmd:
select user()
in pool
DBHostConfig [hostName=myhostM1, url=192.168.92.14:3306]

--navicat separate read and write tests
SELECT * from orderdb.t_order;
INSERT INTO SELECT orderdb.t_order 16, 'user16';
- write only read error
SELECT * from orderdb.company;
INSERT INTO orderdb.company SELECT. 6, ' company6 ';

Guess you like

Origin www.cnblogs.com/buffercache/p/12446299.html