Docker中安装配置mycat

主数据库master :10.8.49.72
从数据salve:10.8.49.71
mycat:10.8.49.52

1.Mycat配置

拷贝解压的mycat安装文件到Dockerfile安装目录下
配置mycat/conf/server.xml
server.xml




<mycat:server xmlns:mycat="http://io.mycat/">
    <system>
    <property name="useSqlStat">0property> 
    <property name="useGlobleTableCheck">0property>
        <property name="sequnceHandlerType">2property>
        <property name="processorBufferPoolType">0property>   
        <property name="handleDistributedTransactions">0property> 
        <property name="useOffHeapForMerge">1property>
        <property name="memoryPageSize">1mproperty>
        <property name="spillsFileBufferSize">1kproperty>
        <property name="useStreamOutput">0property>
        <property name="systemReserveMemorySize">384mproperty>
        <property name="useZKSwitch">trueproperty>
    system>

    <user name="root">
        <property name="password">rootproperty> 
        <property name="schemas">TESTDBproperty>  #此处可改为自己的数据库名,用于登录后显示数据库名称;不改显示登录的数据库名称为TESTDB。
    user>
mycat:server>

schema.xml配置内容



<mycat:schema xmlns:mycat="http://io.mycat/">

    <schema name="TESTDB" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn1">
    schema>   
    <dataNode name="dn1" dataHost="localhost1" database="wsxdb" />
    <dataHost name="localhost1" maxCon="1000" minCon="10" balance="2"
              writeType="0" dbType="mysql" dbDriver="native" switchType="1"  slaveThreshold="100">
        <heartbeat>select user()heartbeat>
        <writeHost host="hostM1" url="10.8.49.72:3306" user="root"
                   password="root">     
            <readHost host="hostS2" url="10.8.49.71:3306" user="root" password="root" />
        writeHost>        
        dataHost>
mycat:schema>

2.Dockerfile配置如下

FROM docker-centos6:0.0.1
# install jdk1.7
ADD jdk-7u51-linux-x64.tar.gz /usr/local/src  
ADD mycat  /usr/local/src/mycat 
ENV JAVA_HOME=/usr/local/src/jdk1.7.0_51        
ENV PATH=$JAVA_HOME/bin:$PATH
ENV CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

EXPOSE 8066 9066 3306
RUN chmod -R 777 /usr/local/src/mycat/bin  
CMD ["./usr/local/src/mycat/bin/mycat", "console"]  
``

3.创建镜像

docker build -t mycat:0.0.1 .       #创建镜像
docker run --name mycat  -p 8066:8066 -p 9066:9066 -p 3306:3306 mycat:0.0.1                        #创建容器

4.使用客户端连接mycat验证mycat是否正常
ip:10.8.49.52 用户名/密码:root/root

参考文档:

mycat配置:http://blog.csdn.net/boonya/article/details/77700864
mycat详解:http://blog.csdn.net/linuxlsq/article/details/52606225

你可能感兴趣的:(Docker篇)