Docker production database middleware Mycat source Mirror __ Database

Source: Internet
Author: User
Tags chmod db2 wrapper tomcat docker ps docker run log4j

The modified Mycat is already in use, and we intend to make it a Docker mirror in order to minimize unnecessary error operations during use. Making Docker requires a stable base environment, built using Dokcerfile for Boot2docker mirroring. preparation of environmental raw materials

Note: Just be prepared to use the following on it.
dokcerfile Configuration

From Boot2docker/boot2docker:latest
maintainer boonya@163.com
ADD jdk-8u121-linux-x64.tar.gz/usr/local/
ADD mycat  /usr/local/mycat
env java_home/usr/local/jdk1.8.0_121
env CLASSPATH $JAVA _home/lib/ Dt.jar: $JAVA _home/lib/tools.jar
ENV PATH $PATH: $JAVA _home/bin
expose 8066 9066
RUN chmod-r 777/usr/ Local/mycat/bin
CMD ["./usr/local/mycat/bin/mycat", "console"]
Note: Jdk,mycat must be installed to run in the Java environment.

Dockerfile Construction

Build command: Docker build-t boonyadocker/boot2docker-mycat:latest.

Build log:

[Root@mysqlserver java-maven-tomcat-jenkins]# Docker build-t boonyadocker/boot2docker-mycat:latest. Sending build context to Docker daemon 308.2 MB Sending builds context to Docker daemon step 0:from Boot2docker/boot2dock
Er:latest---> 898cd2a4a97e step 1:maintainer boonya@163.com---> Running in fc976d113c14---> 4c15c54bace0 Removing intermediate container fc976d113c14 step 2:add jdk-8u121-linux-x64.tar.gz/usr/local/---> C2a68d90a7e8 Rem Oving Intermediate Container 1dabd2085544 step 3:add mycat/usr/local/mycat---> ebf0de05e8ec removing Intermediate Container 66EDA0FB1DCA step 4:env java_home/usr/local/jdk1.8.0_121---> Running in ab924224a988---> Bcbb94be23 E1 removing intermediate container ab924224a988 step 5:env CLASSPATH $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar--- > Running in f84d0bafc488---> fbe32cae8f24 removing Intermediate container f84d0bafc488 step 6:env PATH $PATH: $J Ava_home/bin---> Running in AEC65E85BDCb---> 9684515e4b07 removing Intermediate container AEC65E85BDCB step 7:expose 8066 9066---> Running in 2478366 fb94e---> b78e089eacb5 removing Intermediate container 2478366fb94e step 8:run chmod-r 777/usr/local/mycat/bin- --> Running in fc6c52bf492b---> d9730028fa48 removing Intermediate container fc6c52bf492b step 9:cmd./usr/local /mycat/bin/mycat Console---> Running in bd7431de7e76---> cf46ef25daf5 removing Intermediate container Successfully built CF46EF25DAF5

Mirrored list:

[Root@mysqlserver java-maven-tomcat-jenkins]# Docker images REPOSITORY TAG IMAGE I D CREATED VIRTUAL SIZE boonyadocker/boot2docker-mycat latest CF46EF25DAF5 2         0 seconds ago 2.607 GB boonyadocker/boot2docker-tomcat latest 31ad702ceffa days ago 2.602 GB boonyadocker/boot2docker-jenkins latest A0090abfd7c8 days ago 2.685 GB Boonyado        Cker/centos-jenkins latest 1250a4fe0292 days ago 659 MB Boonyadocker/centos-jenkins Allow-remote 47E38EC3F8BC 2 weeks ago 658.7 MB Boonyadocker/centos-tomcat Allow-remot E a3cf71b7dd49 2 weeks ago 575.9 MB Tomcat latest 70b2ded79  7DF 2 weeks ago 292.4 MB Boot2docker/boot2docker latest 898cd2a4a97e 2 weeks Ago 2.219 GB CENtos latest F3b88ddaed16 3 weeks ago 192.5 MB Jenkins Latest DE57EF56DCA0 4 weeks ago 809.9 MB OpenJDK 8-j Re Cdcc2156bae7 4 weeks ago 275.1 MB Jetbrains/teamcity-server Latest 4        7728ea3474b 5 weeks ago 1.308 GB Boonyadocker/jenkins latest e14944ad9023         6 weeks ago 654.2 MB boonyadocker/tomcat-allow-remote latest 96d1fe00ad03 7 weeks ago  571.4 MB [Root@mysqlserver java-maven-tomcat-jenkins]#

Note: The above has been successfully built.

running mirrors in a container

Run command: Docker run--name mycat-p 8066:8066-p 9066:9066 boonyadocker/boot2docker-mycat:latest

Run log:

Running Mycat-server ... wrapper | --> Wrapper started as Console wrapper | Launching a JVM ... JVM 1 | Java HotSpot (TM) 64-bit Server VM warning:ignoring option maxpermsize=64m; Support is removed in 8.0 JVM 1 |   Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org JVM 1 |  Copyright 1999-2006 Tanuki Software, Inc.
All Rights Reserved.
JVM 1 | JVM 1 | 2017-08-30 01:48:01,258 [INFO][wrappersimpleappmain] Total resouces of datahost localhost1 is:3 (io.mycat.backend.datas Ource. physicaldbpool:physicaldbpool.java:100) JVM 1 | 2017-08-30 01:48:01,265 [INFO][wrappersimpleappmain] Create layer cache pool Tableid2datanodecache of type Encache, Defau LT Cache size 10000, default expire seconds18000 (io.mycat.cache.cacheservice:cacheservice.java:125) JVM 1 | 2017-08-30 01:48:01,266 [INFO][wrappersimpleappmain] Create child cache:testdb_orders for layered Cache Tableid2datanod Ecache, size 50000, expire seconds 18000 (Io.mycat.cache.DefaultLayedCachePool:Defaultlayedcachepool.java:80) JVM 1 |  2017-08-30 01:48:01,391 [INFO][wrappersimpleappmain] Dyna class load from./catlet,and Auto Check for class file modified Every seconds (io.mycat.config.classloader.dynaclassloader:dynaclassloader.java:34) JVM 1 | 2017-08-30 01:48:01,391 [INFO][wrappersimpleappmain] =============================================== ( io.mycat.mycatserver:mycatserver.java:258) JVM 1 |  2017-08-30 01:48:01,391 [INFO][wrappersimpleappmain] Mycat is ready to startup ... (io.mycat.mycatserver:mycatserver.java:259) JVM 1 |    
2017-08-30 01:48:01,392 [INFO][wrappersimpleappmain] Startup processors ..., total Processors:8,aio thread pool size:16  JVM 1 | Each process allocated socket buffer pool bytes, a page size:2097152 a page ' s chunk number (pagesize/chunksize) is:512 b Uffer Page ' s number is:160 (io.mycat.mycatserver:mycatserver.java:271) JVM 1 | 2017-08-30 01:48:01,392 [INFO][wrappersimpleappmain] Sysconfig params:systemconfig [Processorbufferlocalpercent=100, frontsocketsorcvbuf=1048576, frontsocketsosndbuf=4194304, backsocketsorcvbuf=4194304, backsocketsosndbuf=1048576, Frontsocketnodelay=1, Backsocketnodelay=1, maxstringliterallength=65535, frontwritequeuesize=2048, bindip=0.0.0.0, serverport=8066, managerport=9066, Charset=utf8, Processors=8, Processorexecutor=16, timerexecutor=2, managerexecutor=2, idletimeout=1800000, catletclasscheckseconds=60, sqlexecutetimeout=300, processorcheckperiod=1000, datanodeidlecheckperiod=300000, dataNodeHeartbeatPeriod=10000, Clusterheartbeatuser=_heartbeat_user_, Clusterheartbeatpass=_heartbeat_pass_, clusterheartbeatperiod=5000, clusterheartbeattimeout=10000, clusterheartbeatretry=10, txisolation=3, parsercommentversion=50148, SqlRecordCount =10, bufferpoolpagesize=2097152, bufferpoolchunksize=4096, bufferpoolpagenumber=160, maxResultSet=524288, bigresultsizesqlcount=10, bufferusagepercent=80, flowcontrolrejectstrategy=0, clearbigsqlresultsetmapms=600000, DEFAULTMAXLIMIT=100, Sequncehandlertype=2, Sqlinterceptor=io.mycat.server.interceptor.impl.defaultsqlinterceptor, SqlInterceptorType=select, Sqlinterceptorfile=/usr/local/mycat/logs/sql.txt, Mutinodelimittype=0, mutinodepatchsize=100, defaultSqlParser= Druidparser, Usingaio=0, packetheadersize=4, maxpacketsize=16777216, Mycatnodeid=1] (io.mycat.MycatServer: mycatserver.java:272) JVM 1 |
Log4j:warn No Appenders could is found for logger (io.mycat.memory.MyCatMemory). JVM 1 |
Log4j:warn Please initialize the log4j system properly. JVM 1 |
Log4j:warn http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. JVM 1 | 2017-08-30 01:48:01,612 [INFO][wrappersimpleappmain] using NiO network handler (Io.mycat.MycatServer:MycatServer.java : 373) JVM 1 | 2017-08-30 01:48:01,624 [INFO][wrappersimpleappmain] $_mycatmanager is started and listening on 9066 (io.mycat.MycatServ er:mycatserver.java:389) JVM 1 | 2017-08-30 01:48:01,624 [INFO][wrappersimpleappmain] $_mycatserver is started and ListeninG on 8066 (io.mycat.mycatserver:mycatserver.java:393) JVM 1 | 2017-08-30 01:48:01,624 [INFO][wrappersimpleappmain] =============================================== ( io.mycat.mycatserver:mycatserver.java:395) JVM 1 |  2017-08-30 01:48:01,624 [INFO][wrappersimpleappmain] Initialize datahost ... (io.mycat.mycatserver:mycatserver.java:399) JVM 1 | 2017-08-30 01:48:01,624 [INFO][wrappersimpleappmain] init backend MYQSL source, create connections total for hostM1 in  dex:0 (io.mycat.backend.datasource.physicaldbpool:physicaldbpool.java:294) JVM 1 | 2017-08-30 01:48:01,636 [INFO][wrappersimpleappmain] No Ilde connection in pool,create New connection for hostM1 of Schem A db3 (io.mycat.backend.datasource.physicaldatasource:physicaldatasource.java:413) JVM 1 | 2017-08-30 01:48:01,636 [INFO][wrappersimpleappmain] No Ilde connection in pool,create New connection for hostM1 of Schem    A DB2 (io.mycat.backend.datasource.physicaldatasource:physicaldatasource.java:413) JVM 1| 2017-08-30 01:48:01,637 [INFO][wrappersimpleappmain] No Ilde connection in pool,create New connection for hostM1 of Schem A db1 (io.mycat.backend.datasource.physicaldatasource:physicaldatasource.java:413) JVM 1 | 2017-08-30 01:48:01,637 [INFO][wrappersimpleappmain] No Ilde connection in pool,create New connection for hostM1 of Schem A db3 (io.mycat.backend.datasource.physicaldatasource:physicaldatasource.java:413) JVM 1 | 2017-08-30 01:48:01,638 [INFO][wrappersimpleappmain] No Ilde connection in pool,create New connection for hostM1 of Schem
 A DB2 (io.mycat.backend.datasource.physicaldatasource:physicaldatasource.java:413) ........

To view a running container:

[Root@mysqlserver ~]# Docker PS
CONTAINER ID        IMAGE                                     COMMAND                CREATED             STATUS              PORTS                                            NAMES
34e3ef01f9e4        boonyadocker/boot2docker-mycat:latest     "./usr/local/mycat/b   minutes ago      up Minutes       0.0.0.0:8066->8066/tcp, 0.0.0.0:9066->9066/tcp   mycat                          
2b3f9dca2c40        Boonyadocker/boot2docker-jenkins:latest   "/bin/sh-c '/usr/lo"   9 days ago           0.0.0.0:8888- >8080/tcp                           boot2docker-jenkins-20170817   
9483cc274809        boonyadocker/boot2docker-tomcat:latest    "/bin/sh-c '/usr/lo"   9 days ago           0.0.0.0:8080->8080/tcp                           boot2docker-tomcat-20170817    

This shows that Mycat mirror production completed. Note: Docker relies on the underlying mirror image, after all, the boot2docker is too large to be built, and you can try building it directly from CentOS or Linux base mirroring.
Testing Mycat Connections

First, let's look at the IP address assigned to the Mycat run container, command: Service iptables status

Table:nat Chain prerouting (policy ACCEPT) num Target prot opt source destination 1 docker All--0.0.0.0/0 0.0.0.0/0 addrtype match Dst-type local Chain postrouting (policy ACCEPT) n           Um target prot opt source destination 1 SNAT All--172.17.0.8 172.17.0.8  to:10.10.x.x 2 SNAT All--172.17.0.8 0.0.0.0/0 to:10.10.x.x 3 SNAT All           
--172.18.0.8 0.0.0.0/0 to:10.10.x.x 4 Masquerade All--172.17.0.0/16 0.0.0.0/0            5 Masquerade TCP--172.17.0.8 172.17.0.8 TCP dpt:8080 6 Masquerade TCP--172.17.0.9 172.17.0.9 TCP dpt:8080 7 Masquerade TCP--172.17.0.28 172.17.0.28 TCP dpt:90 8 Masquerade TCP--172.17.0.28 172.17.0.28 TCP dpt:8066 Chain OUTPUT (policy ACCEPT) num TA Rget Prot opt Source               Destination 1 Docker All--0.0.0.0/0!127.0.0.0/8 addrtype match dst-t       Ype Local Chain Docker (2 references) num target prot opt source destination 1 Dnat            TCP--0.0.0.0/0 0.0.0.0/0 TCP dpt:8080 to:172.17.0.8:8080 2 dnat TCP--0.0.0.0/0           0.0.0.0/0 TCP dpt:8888 to:172.17.0.9:8080 3 Dnat TCP--0.0.0.0/0 0.0.0.0/0 TCP dpt:9066 to:172.17.0.28:9066 4 dnat TCP--0.0.0.0/0 0.0.0.0/0 TCP dpt:8066 to:1         
72.17.0.28:8066 table:filter Chain INPUT (policy ACCEPT) num Target prot opt source destination     1 ACCEPT TCP--0.0.0.0/0 0.0.0.0/0 TCP dpt:10050 State new,established 2 ACCEPT            TCP--0.0.0.0/0 0.0.0.0/0 TCP dpt:21 State new,established 3 ACCEPT TCP--0.0.0.0/0     0.0.0.0/0      TCP dpt:3306 State new,established 4 ACCEPT TCP--0.0.0.0/0 0.0.0.0/0 TCP dpt:3036 5 ACCEPT All--0.0.0.0/0 0.0.0.0/0 State related,established 6 ACCEPT ICMP--0.0. 0.0/0 0.0.0.0/0 7 ACCEPT All--0.0.0.0/0 0.0.0.0/0 8 ACCEPT t CP--0.0.0.0/0 0.0.0.0/0 State NEW TCP dpt:22 9 REJECT All--0.0.0.0/0 0.0.0               .0/0 reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT) num Target prot opt source Destination 1 Docker All--0.0.0.0/0 0.0.0.0/0 2 ACCEPT All--0.0.0           
.0/0 0.0.0.0/0 ctstate related,established 3 ACCEPT All-0.0.0.0/0 0.0.0.0/0     4 REJECT All--0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited 5 ACCEPT  All--0.0.0.0/0          0.0.0.0/0 Chain OUTPUT (policy ACCEPT) num Target prot opt source destination 1 ACCEPT TCP--0.0.0.0/0 0.0.0.0/0 TCP spt:10050 State established 2 ACCEPT t     CP--0.0.0.0/0 0.0.0.0/0 TCP spt:3306 State established Chain Docker (1 references) Num target Prot opt source Destination 1 ACCEPT TCP--0.0.0.0/0 172.17.0.8 t CP dpt:8080 2 ACCEPT TCP--0.0.0.0/0 172.17.0.9 TCP dpt:8080 3 ACCEPT TCP--0.0. 0.0/0 172.17.0.28 TCP dpt:9066 4 ACCEPT TCP--0.0.0.0/0 172.17.0.28 TCP D 
 pt:8066 [Root@mysqlserver java-maven-tomcat-jenkins]#
Then we try to use the assigned 8066-port IP 172.17.0.28 to connect:

Found outside is not directly accessible to the container, we from the host IP to access:


The access is successful, and the password can be entered into the container for viewing: defined in/usr/local/mycat/conf/server.xml. A glimpse of the Mycat database:


In order to save the steps of the rummage, here is the next user and password: root/digdeep or User/user. provides public warehouse mirroring

Download command: Docker pull Boonyadocker/boot2docker-mycat


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.