docker-Cross-host storage

Source: Internet
Author: User
Tags docker run docker swarm

Container classification

From the point of view of business data, containers can be divided into two categories: stateless (stateless) containers and stateful (stateful) containers.

Stateless means that the container does not need to save data while it is running, and the result of each access does not depend on the last access, such as a Web server that provides a static page.

Stateful means that the container needs to save the data, and the data changes, and the results of the access depend on the processing results of the previous request, most typically the database server

Volume driver

Volume driver enables cross-host management of data volume scenarios

Any data volume is managed by driver, and when created volume is not specifically specified, the local type of driver is used to allocate storage space from the local directory of the Docker Host. If you want to support cross-host volume, you need to use a third-party driver

Rex-ray Driver Features
    1. CEP is open source, and the community is active.
    2. Supports multiple backend,virtualbox of Virtual Media, Amazon EBS, Ceph RBD, OpenStack Cinder, and more.
    3. Supports multiple operating systems, Ubuntu, CentOS, RHEL and CoreOS.
    4. supports a variety of container orchestration engines, Docker Swarm, Kubernetes, and Mesos.
    5. Rex-ray installation is easy to use.
Installation configuration

Rex-ray run on the Docker host as a standalone process

Run the following command on hosts Docker1 and docker2 that use Rex-ray driver

Curl-ssl Https://rexray.io/install | Sh

Then create and edit the Rex-ray configuration file/etc/rexray/config.yml

Can use the graphical online Rex-ray configuration generator

VirtualBox Backend

Start the Vboxwebsrv service on the VirtualBox host, which is the notebook:
Vboxwebsrv-h 0.0.0.0

Execute the following command to turn off VirtualBox's login authentication:
VBoxManage setproperty websrvauthlibrary null

Modify the Storage configuration of the virtual machine docker1 and Docker2 in the shutdown state:

1. Remove the IDE controller.

2. Set SATA the controller's port number to the maximum value 30 .

Restart the Rex-ray service:
Systemctl Restart Rexray.service

Run the rexray volume ls test Rex-ray to see if it works correctly.

The volume in the list is the current VirtualBox all virtual disks.

Create Rex-ray Volume Install plugin

Starting with Docker 1.13, Docker now supports a new plug-in architecture where plug-ins can be installed as containers.

$ docker plugin install rexray / ebs EBS_ACCESSKEY = access_key EBS_SECRETKEY = secret_key

Create Volume

Execute the following command on Docker1 or Docker2 to create the volume:

Rexray Volume Create Mysql_data--size=2

Using volume to start Docker

Docker run-dit--name mydb_on_docker1--volume-driver=rexray-v mysql_data:/var/lib/mysql-e MYSQL_ROOT_PASSWORD= passw0rd-d MySQL

Failed to create a successful discard, use Ceph as back-end storage

Verify volumeceph-do backend

Deployment documentation

1. Change the Rex-ray configuration file

Where Test-pool is a pool built in Ceph

2. Restart the Rex-ray service

Rexray restart

3. Create a volume

Docker volume Create--driver rexray--name=mysqldata--opt=size=2

4. Creating a container with a volume

Docker run-dit--name mydb_on_docker1--volume-driver=rexray-v mysql_data:/var/lib/mysql-e MYSQL_ROOT_PASSWORD= Passw0rd-d MYSQ

5. Write Data test

6. Verifying Data consistency

Delete Mydb_on_docker1

Re-create a container

Docker run--name mydb_on_docker2-v mysqldata:/var/lib/mysql-d MySQL

The new container also uses the same volume mysqldata , but this time you don't need to specify an environment variable MYSQL_ROOT_PASSWORD because the password has been saved mysqldata inside.

Now Rex-ray volume mysqldata has been mounted to Docker2:

① into the container mydb_on_docker2 .

② login database, password and mydb_on_docker1 consistent.

③ switch to the database mysql .

④ confirms that the mydb_on_docker1 table created before and the data written are intact.

docker-across host storage

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.