Mycat HA(高可用) 与 LB(负载均衡)9

2021-12-02 09:45:16 浏览数 (1)

server.xml、schema.xml、rule.xml

代码语言:javascript复制
--[server.xml]--------
        <user name="cc">
                <property name="password">cc</property>
                <property name="schemas">cctest</property>
        </user>
--[schema.xml]--------
        <schema name="cctest" checkSQLschema="false" sqlMaxLimit="100">
                <table name="catworld"  dataNode="sd1,sd2,sd3"  rule="mod-long" />
                <table name="abc"  dataNode="sd1,sd2,sd3,sd5"  rule="mod4-long" />
        </schema>

        <dataNode name="sd1" dataHost="h101" database="my1" />
        <dataNode name="sd2" dataHost="h101" database="my2" />
        <dataNode name="sd3" dataHost="h101" database="my3" />
        <dataNode name="sd5" dataHost="h101" database="my5" />

       ...
       ...

        <dataHost name="h101" maxCon="100" minCon="10" balance="0" writeType="0" dbType="mysql" dbDriver="native" switchType="1"  slaveThreshold="100">
                <heartbeat>select user()</heartbeat>
                <writeHost host="h101M1" url="192.168.100.101:3306" user="root" password="mysql">
                <!-- can have multi read hosts -->
                </writeHost>
        </dataHost>
--[rule.xml]--------
	<tableRule name="mod-long">
		<rule>
			<columns>id</columns>
			<algorithm>mod-long</algorithm>
		</rule>
	</tableRule>
	<tableRule name="mod4-long">
		<rule>
			<columns>id</columns>
			<algorithm>mod4-long</algorithm>
		</rule>
	</tableRule>
	...
	...
	<function name="mod-long" class="org.opencloudb.route.function.PartitionByMod">
		<!-- how many data nodes -->
		<property name="count">3</property>
	</function>
	<function name="mod4-long" class="org.opencloudb.route.function.PartitionByMod">
		<!-- how many data nodes -->
		<property name="count">4</property>
	</function>

打开防火墙

确保 8066 开启

代码语言:javascript复制
[root@h101 conf]# iptables -L -nv  | grep 8066
[root@h101 conf]# vim /etc/sysconfig/iptables
[root@h101 conf]# /etc/init.d/iptables reload 
iptables: Trying to reload firewall rules:                 [  OK  ]
[root@h101 conf]# iptables -L -nv  | grep 8066
    0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:8066 
[root@h101 conf]# 

0 人点赞