1. 程式人生 > 其它 >linux 檢視 active mq_Docker進階---製作MQ映象

linux 檢視 active mq_Docker進階---製作MQ映象

技術標籤:linux 檢視 active mq

為了展示製作映象的各個步驟,可以分為兩大步驟:先製作一個安裝了MQ的映象,然後在此基礎上製作一個建立了各種MQ物件的映象。

1. 製作安裝了MQ 的 Docker 映象

(1)準備安裝資源

安裝包:

[[email protected] mq]# ls -rlttotal 389160-rw-r--r--. 1 root root 398496617 Sep 23 2016 ToprowMQ_8.0.0.3_Linux_X86_64_Full.tar.gz[[email protected] mq]# tar -xvf ToprowMQ_8.0.0.3_Linux_X86_64_Full.tar.gz [
[email protected]
mq]# echo $PWD/tool/mq

映象:

[[email protected] mq]# docker image ls centosREPOSITORY TAG IMAGE ID CREATED SIZEcentos latest 9f38484d220f 7 weeks ago 202MB

(2)啟動容器

對映本地目錄到容器:

[[email protected] mq]# docker run -it -v $PWD:/tmp/software centos /bin/bash[[email protected] /]# uname -aLinux 6dfcd9f0360c 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux[
[email protected]
/]# [[email protected] /]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) [[email protected] /]# [[email protected] /]# ls -ld /tmp/software/drwxr-xr-x. 7 root root 4096 May 8 08:26 /tmp/software/[[email protected] /]# [[email protected] /]# ls -l /tmp/software/ total 679608drwxrwxr-x. 3 500 500 18 Sep 21 2016 PreReqsdrwxrwxr-x. 2 500 500 4096 Sep 21 2016 READMES-rw-rw-r--. 1 500 500 2390555 Sep 21 2016 ToprowMQClient-8.0.0-3.x86_64.rpm-rw-rw-r--. 1 500 500 150269181 Sep 21 2016 ToprowMQExplorer-8.0.0-3.x86_64.rpm-rw-rw-r--. 1 500 500 98662028 Sep 21 2016 ToprowMQJRE-8.0.0-3.x86_64.rpm-rw-rw-r--. 1 500 500 17627124 Sep 21 2016 ToprowMQJava-8.0.0-3.x86_64.rpm-rw-rw-r--. 1 500 500 140705 Sep 21 2016 ToprowMQMsg_Zh_CN-8.0.0-3.x86_64.rpm-rw-rw-r--. 1 500 500 142090 Sep 21 2016 ToprowMQMsg_Zh_TW-8.0.0-3.x86_64.rpm-rw-rw-r--. 1 500 500 10921932 Sep 21 2016 ToprowMQRuntime-8.0.0-3.x86_64.rpm-rw-rw-r--. 1 500 500 232177 Sep 21 2016 ToprowMQSDK-8.0.0-3.x86_64.rpm-rw-rw-r--. 1 500 500 669005 Sep 21 2016 ToprowMQSamples-8.0.0-3.x86_64.rpm-rw-rw-r--. 1 500 500 16310368 Sep 21 2016 ToprowMQServer-8.0.0-3.x86_64.rpm-rw-r--r--. 1 root root 398496617 Sep 23 2016 ToprowMQ_8.0.0.3_Linux_X86_64_Full.tar.gz-rw-rw-r--. 1 500 500 122 Sep 21 2016 copyright-rwxrwxr-x. 1 500 500 5629 Sep 21 2016 crtmqpkgdrwxrwxr-x. 4 500 500 51 Sep 21 2016 lapdrwxrwxr-x. 2 500 500 4096 Sep 21 2016 licenses-rwxr-xr-x. 1 500 500 8371 Sep 21 2016 mqlicense.shdrwxrwxr-x. 2 500 500 278 Sep 21 2016 repackage

(3)在容器中安裝

[[email protected] /]# cd /tmp/software/[[email protected] software]# ./mqlicense.sh -accept WARNING: Unable to determine distribution and release for this system.  Check that it is supported before continuing with installation.Licensed Materials - Property of Vsettan   5724-H72  (C) Copyright Vsettan Corporation 2015,2016 Agreement accepted: Proceed with install.[[email protected] software]# rpm -ivh *rpmPreparing... ################################# [100%]Creating group mqmCreating user mqmUpdating / installing... 1:ToprowMQRuntime-8.0.0-3 ################################# [ 10%] 2:ToprowMQJRE-8.0.0-3 ################################# [ 20%] 3:ToprowMQExplorer-8.0.0-3 ################################# [ 30%] 4:ToprowMQClient-8.0.0-3 ################################# [ 40%] 5:ToprowMQJava-8.0.0-3 ################################# [ 50%] 6:ToprowMQMsg_Zh_CN-8.0.0-3 ################################# [ 60%] 7:ToprowMQMsg_Zh_TW-8.0.0-3 ################################# [ 70%] 8:ToprowMQSDK-8.0.0-3 ################################# [ 80%] 9:ToprowMQSamples-8.0.0-3 ################################# [ 90%] 10:ToprowMQServer-8.0.0-3 ################################# [100%]Updated PAM configuration in /etc/pam.d/ibmmq

然後exit退出容器。

(4)提交為映象

檢視剛才使用的容器:

[[email protected] mq]# docker container ls -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESa4ba25fa8af6 centos "/bin/bash" 5 minutes ago Exited (0) 10 seconds ago elated_mccarthy[[email protected] mq]# docker commit a4ba25fa8af6 shushenlw/toprowmq8003sha256:cb533d56a1f5a9d570c9a983bebe5791e6e03cfc3dfab22bf4b62eacf6e0f407[[email protected] mq]# docker image ls shushenlw/toprowmq8003REPOSITORY TAG IMAGE ID CREATED SIZEshushenlw/toprowmq8003 latest cb533d56a1f5 About a minute ago 907MB

2. 使用安裝MQ的映象製作可以提供服務的MQ映象

建立各種MQ物件,然後對外提供服務。

(1)準備各種檔案

[[email protected] mq]# cat Dockerfile FROM shushenlw/toprowmq8003 RUN yum install -y python-setuptools && easy_install supervisor && mkdir -p /var/log/supervisorCOPY supervisord.conf /usr/etc/supervisord.confCOPY start_queue_manager.sh /tool/RUN chmod +x /tool/start_queue_manager.shEXPOSE 1414CMD ["/usr/bin/supervisord"][[email protected] mq]# cat supervisord.conf [supervisord]nodaemon=true[program:sshd]command=su mqm -c /tool/start_queue_manager.sh[[email protected] mq]# cat start_queue_manager.sh export QMNAME=QMTESTexport QMPORT=1414source /opt/mqm/bin/setmqenv -scrtmqm -u SYSTEM.DEAD.LETTER.QUEUE $QMNAMEstrmqm $QMNAMErunmqsc $QMNAME << EOF define listener(TCP.LISTENER) trptype(tcp) control(qmgr) port($QMPORT) start listener(TCP.LISTENER) define channel(CHL_SVRCONN) chltype(SVRCONN) REPLACE ALTER QMGR CHLAUTH(DISABLED) ALTER QMGR CONNAUTH('') REFRESH SECURITYEOF(2)build映象[[email protected] mq]# docker build --tag shushenlw/toprowmq8003:v1.0 .Sending build context to Docker daemon 5.632kBStep 1/7 : FROM shushenlw/toprowmq8003 ---> cb533d56a1f5Step 2/7 : RUN yum install -y python-setuptools && easy_install supervisor && mkdir -p /var/log/supervisor ---> Running in d0f48ce973c7Loaded plugins: fastestmirror, ovlDetermining fastest mirrors * base: mirrors.163.com * extras: mirrors.huaweicloud.com * updates: mirrors.cqu.edu.cnbase | 3.6 kB 00:00 extras | 3.4 kB 00:00 updates | 3.4 kB 00:00 (1/4): base/7/x86_64/group_gz | 166 kB 04:29 (2/4): extras/7/x86_64/primary_db | 201 kB 04:45 (3/4): base/7/x86_64/primary_db | 6.0 MB 06:13 (4/4): updates/7/x86_64/primary_db | 4.2 MB 06:27 Resolving Dependencies--> Running transaction check---> Package python-setuptools.noarch 0:0.9.8-7.el7 will be installed--> Processing Dependency: python-backports-ssl_match_hostname for package: python-setuptools-0.9.8-7.el7.noarch--> Running transaction check---> Package python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7 will be installed--> Processing Dependency: python-ipaddress for package: python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch--> Processing Dependency: python-backports for package: python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch--> Running transaction check---> Package python-backports.x86_64 0:1.0-8.el7 will be installed---> Package python-ipaddress.noarch 0:1.0.16-2.el7 will be installed--> Finished Dependency ResolutionDependencies Resolved================================================================================ Package Arch Version Repository Size================================================================================Installing: python-setuptools noarch 0.9.8-7.el7 base 397 kInstalling for dependencies: python-backports x86_64 1.0-8.el7 base 5.8 k python-backports-ssl_match_hostname noarch 3.5.0.1-1.el7 base 13 k python-ipaddress noarch 1.0.16-2.el7 base 34 kTransaction Summary================================================================================Install 1 Package (+3 Dependent packages)Total download size: 450 kInstalled size: 2.2 MDownloading packages:warning: /var/cache/yum/x86_64/7/base/packages/python-backports-1.0-8.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPublic key for python-backports-1.0-8.el7.x86_64.rpm is not installed(1/4): python-backports-1.0-8.el7.x86_64.rpm | 5.8 kB 01:18 (2/4): python-backports-ssl_match_hostname-3.5.0.1-1.el7.n | 13 kB 01:50 (3/4): python-ipaddress-1.0.16-2.el7.noarch.rpm | 34 kB 01:50 (4/4): python-setuptools-0.9.8-7.el7.noarch.rpm | 397 kB 01:50 --------------------------------------------------------------------------------Total 3.5 kB/s | 450 kB 02:09 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7Importing GPG key 0xF4A80EB5: Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) " Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5 Package : centos-release-7-6.1810.2.el7.centos.x86_64 (@CentOS) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7Running transaction checkRunning transaction testTransaction test succeededRunning transactionWarning: RPMDB altered outside of yum. Installing : python-backports-1.0-8.el7.x86_64 1/4  Installing : python-ipaddress-1.0.16-2.el7.noarch 2/4  Installing : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch 3/4  Installing : python-setuptools-0.9.8-7.el7.noarch 4/4  Verifying : python-ipaddress-1.0.16-2.el7.noarch 1/4  Verifying : python-setuptools-0.9.8-7.el7.noarch 2/4  Verifying : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch 3/4  Verifying : python-backports-1.0-8.el7.x86_64 4/4 Installed: python-setuptools.noarch 0:0.9.8-7.el7 Dependency Installed: python-backports.x86_64 0:1.0-8.el7  python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7  python-ipaddress.noarch 0:1.0.16-2.el7 Complete!Searching for supervisorReading https://pypi.python.org/simple/supervisor/Best match: supervisor 4.0.2Downloading https://files.pythonhosted.org/packages/cb/02/95953c98a770803e42009f18c2eb361bc035ab6fb3cbb442ffcc94387eac/supervisor-4.0.2.tar.gz#sha256=5604457da4fb89d850e78c128205fe4938c9277f87301885b33c94c60361e575Processing supervisor-4.0.2.tar.gzWriting /tmp/easy_install-PRDNNO/supervisor-4.0.2/setup.cfgRunning supervisor-4.0.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-PRDNNO/supervisor-4.0.2/egg-dist-tmp-JsKCZSwarning: no previously-included files matching '*' found under directory 'docs/.build'Adding supervisor 4.0.2 to easy-install.pth fileInstalling echo_supervisord_conf script to /usr/binInstalling pidproxy script to /usr/binInstalling supervisorctl script to /usr/binInstalling supervisord script to /usr/binInstalled /usr/lib/python2.7/site-packages/supervisor-4.0.2-py2.7.eggProcessing dependencies for supervisorSearching for meld3>=1.0.0Reading https://pypi.python.org/simple/meld3/Best match: meld3 1.0.2Downloading https://files.pythonhosted.org/packages/45/a0/317c6422b26c12fe0161e936fc35f36552069ba8e6f7ecbd99bbffe32a5f/meld3-1.0.2.tar.gz#sha256=f7b754a0fde7a4429b2ebe49409db240b5699385a572501bb0d5627d299f9558Processing meld3-1.0.2.tar.gzWriting /tmp/easy_install-UKscyn/meld3-1.0.2/setup.cfgRunning meld3-1.0.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-UKscyn/meld3-1.0.2/egg-dist-tmp-ikmU68zip_safe flag not set; analyzing archive contents...Adding meld3 1.0.2 to easy-install.pth fileInstalled /usr/lib/python2.7/site-packages/meld3-1.0.2-py2.7.eggFinished processing dependencies for supervisorRemoving intermediate container d0f48ce973c7 ---> 365c08df5698Step 3/7 : COPY supervisord.conf /usr/etc/supervisord.conf ---> f77fc55cd5c9Step 4/7 : COPY start_queue_manager.sh /tool ---> 901ff48aa46dStep 5/7 : RUN chmod +x /start_queue_manager.sh ---> Running in 579b66efbca2Removing intermediate container 579b66efbca2 ---> 7f975388ae10Step 6/7 : EXPOSE 1414 ---> Running in 433c1956e97eRemoving intermediate container 433c1956e97e ---> 20382e828da6Step 7/7 : CMD ["/usr/bin/supervisord"] ---> Running in 4d392c69731aRemoving intermediate container 4d392c69731a ---> fdfed6b58458Successfully built fdfed6b58458Successfully tagged shushenlw/toprowmq8003:v1.0[[email protected] mq]# docker image lsREPOSITORY TAG IMAGE ID CREATED SIZEshushenlw/toprowmq8003 v1.0 fdfed6b58458 30 seconds ago 1GB
9103136c9099a2f3522c280a80736bb6.png

檢視映象

(3)啟動容器

[[email protected] mq]# docker run -d -p 1414:1414 --name toprowmq8003 shushenlw/toprowmq8003:v1.0cf12ddcf485e16060a6f8e67a74964da69893b90618d169c8e02ec13c86dc3d1[[email protected] mq]# docker inspect cf12ddcf485e | grep -i ipaddress "SecondaryIPAddresses": null, "IPAddress": "172.17.0.2