Using Docker to build an LVS environment

Source: Internet
Author: User
Tags sleep docker ps
Introduction

LVS is an excellent load balancing software, widely used in the major well-known websites, which support a variety of load balancing methods, such as: [Vs/nat,vs/tun,vs/dr and Full NAT, originally in the test environment to build a LVS, often need more than one physical host or virtual machine, In this article, you will find a way to use Docker to build a LVS cluster on a virtual machine, allowing developers to install the virtual machine environment in the development and testing phase using the environment , where the window7, using VirtualBox, installs 64-bit CENTOS7 , in the installation process select minimal can be due to the use of the environment in the construction of Docker and Docker-compose, so first set up a relatively fast domestic yum source, recommended the use of Alibaba cloud Yum Source

Because Docker-compose is used and the Docker-compose is installed via Pip, the PIP is installed via Yum, as follows:

          | Yum-y Install Epel-release |
          | Yum-y Install Python-pip   |
          | Yum Clean All               |

Installing Docker-compose with PIP

       |   Pip Install-u docker-compose  |

Download the attachment from GitHub and place it in a directory on the Linux operating system

After decompression, run docker-compose up in the extracted directory

In this way, the operating environment of the LVS is built successfully by Docker-compose. analysis of related configurations

In this environment, the IP of the LVs two Docker containers, as shown in the following table, has the allocated LVs allocated on the DOCKERMASTER_LVS1 vip:172.17.0.8

[Root@localhost ~]# Docker PS CONTAINER ID IMAGE COMMAND CREATED STATUS  PORTS NAMES 9e52f1b85d79 dockermaster_client1 "Sleep 2h" 2 days ago up 2       Minutes 22/tcp dockermaster_client1_1 ca7970401fa0 dockermaster_web2 "sh local.rc"      2 days ago up 2 minutes 22/tcp, 80/tcp dockermaster_web2_1 0018316201a0 dockermaster_web1 "Sh local.rc" 2 days ago up 2 minutes 22/tcp, 80/tcp dockermaster_web1_1 ed93d015bc56 doc KERMASTER_LVS1 "/app/run.sh" 2 days ago up 3 minutes 22/tcp, 80/tcp dockermaster_lvs1_1 EAC 75212a3b7 DOCKERMASTER_LVS2 "/app/run.sh" 2 days ago up 3 minutes 22/tcp, 80/tcp doc Kermaster_lvs2_1 [root@localhost ~]# docker exec-ti ed93d015bc56/bin/sh sh-4.1# IP addr 1:lo: <loopback,up,lower_up& Gt MTU 65536 Qdisc NoquEue State UNKNOWN link/loopback 00:00:00:00:00:00 BRD 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo Vali D_lft Forever Preferred_lft Forever Inet6:: 1/128 scope host Valid_lft forever Preferred_lft forever 6:eth0@if 7: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> MTU Qdisc noqueue State up Link/ether 02:42:ac:11:00:03 BRD FF: FF:FF:FF:FF:FF inet 172.17.0.3/16 Scope global eth0 Valid_lft forever Preferred_lft Forever inet 172.17.0.8 /32 scope global eth0 Valid_lft forever Preferred_lft forever inet6 fe80::42:acff:fe11:3/64 Scope Link V Alid_lft Forever Preferred_lft Forever sh-4.1# exit[root@localhost ~]# [root@localhost ~]# Docker Exec-ti eac75212a3b7/b in/sh sh-4.1# IP addr 1:lo: <LOOPBACK,UP,LOWER_UP> MTU 65536 qdisc noqueue State UNKNOWN Link/loopback 00:00:00 : 00:00:00 BRD 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever Preferred_lft Forever inet
   6:: 1/128 Scope Host    Valid_lft Forever Preferred_lft Forever 4:eth0@if5: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> MTU Qdisc NOQ Ueue state up Link/ether 02:42:ac:11:00:02 BRD ff:ff:ff:ff:ff:ff inet 172.17.0.2/16 scope Global eth0 Valid _lft Forever Preferred_lft Forever inet6 fe80::42:acff:fe11:2/64 scope link Valid_lft forever preferred_lft for
 Ever

In the Docker Web container, the IP is as follows, and the 172.17.0.8 VIP is bound on the Lo Nic of the two Docker containers

[Root@localhost ~]# Docker PS CONTAINER ID IMAGE COMMAND CREATED STATUS  PORTS NAMES 9e52f1b85d79 dockermaster_client1 "Sleep 2h" 2 days ago up       Minutes 22/tcp dockermaster_client1_1 ca7970401fa0 dockermaster_web2 "sh local.rc"      2 days ago up minutes 22/tcp, 80/tcp dockermaster_web2_1 0018316201a0 dockermaster_web1        "Sh local.rc" 2 days ago up minutes 22/tcp, 80/tcp dockermaster_web1_1 ed93d015bc56 DOCKERMASTER_LVS1 "/app/run.sh" 2 days ago up minutes 22/tcp, 80/tcp dockermaster_lvs1_      1 eac75212a3b7 dockermaster_lvs2 "/app/run.sh" 2 days ago up minutes 22/tcp, 80/tcp Dockermaster_lvs2_1 [root@localhost ~]# docker exec-ti 0018316201a0/bin/sh sh-4.1# IP addr 1:lo: <loopback,up,low Er_up> MTU 65536 QdisC Noqueue State UNKNOWN link/loopback 00:00:00:00:00:00 BRD 00:00:00:00:00:00 inet 127.0.0.1/8 Scope host Lo  Valid_lft Forever Preferred_lft Forever inet 172.17.0.8/32 BRD 172.17.0.8 scope global lo:0 Valid_lft forever Preferred_lft Forever Inet6:: 1/128 scope host Valid_lft forever Preferred_lft forever 8:eth0@if9: &LT;BROADC Ast,multicast,up,lower_up,m-down> MTU Qdisc Noqueue State up Link/ether 02:42:ac:11:00:04 BRD ff:ff:ff:ff:ff:f F inet 172.17.0.4/16 scope global eth0 Valid_lft forever Preferred_lft Forever Inet6 FE80::42:ACFF:FE11:4/6 4 scope link Valid_lft forever Preferred_lft forever sh-4.1# exit Exit [root@localhost ~]# Docker Exec-ti ca797040 1fa0/bin/sh sh-4.1# IP addr 1:lo: <LOOPBACK,UP,LOWER_UP> MTU 65536 qdisc noqueue State UNKNOWN Link/loopback 0
    0:00:00:00:00:00 BRD 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever Preferred_lft Forever inet 172.17.0.8/32 BRD 172.17.0.8 Scope Global lo:0 Valid_lft forever Preferred_lft Forever Inet6:: 1/128 Scope host VALID_LF T forever Preferred_lft Forever 10:ETH0@IF11: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> MTU Qdisc noqueue Stat E up link/ether 02:42:ac:11:00:05 BRD ff:ff:ff:ff:ff:ff inet 172.17.0.5/16 scope global eth0 valid_lft fore Ver preferred_lft forever inet6 fe80::42:acff:fe11:5/64 scope link Valid_lft forever Preferred_lft forever sh-4
 . #

Then on the Docker host, you can access it via Curl 172.17.0.8

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.