Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to create a Rex-Ray volume

Shulou Source: shulou.com Published: 2022-06-01 00:52:19 09月13日 Update

Today, I would like to talk to you about how to create Rex-Ray volume, many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something from this article.

We installed and deployed Rex-Ray and successfully configured VirtualBox backend, and today we demonstrate how to create and use Rex-Ray volume.

Create a volume by executing the following command on docker1 or docker2:

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

The volume mysqldata was created successfully with a size of 2GB. Mysqldata can also be seen in the VirtualBox host.

Because VirtualBox uses a small amount of space initially allocated by thin-provisioning,volume.

Next we will:

Start the MySQL container mydb_on_docker1 on dokcer1 and use mysqldata as the data volume.

Update the database and then destroy the mydb_on_docker1.

Start the MySQL container mydb_on_docker2 on dokcer2, also use mysqldata as the data volume, and then verify the validity of the data.

Create containers and use data volumes

Start the MySQL container by executing the following command on dokcer1:

Docker run-- name mydb_on_docker1-v mysqldata:/var/lib/mysql-e MYSQL_ROOT_PASSWORD=passw0rd-d mysql

-v mysqldata:/var/lib/mysql transfers the previously created volume mount to the MySQL data directory.

Let's take a look at how this mount is implemented at a lower level.

First view the storage configuration of the virtual machine docker1 in VirtualBox:

Rex-Ray volume mysqldata has been mounted to docker1.

Perform docker volume inspect mysqldata:

Mysqldata has been mount to the docker1 directory / var/lib/libstorage/volumes/mysqldata/data, and execute docker inspect mydb_on_docker1 to view the volume information of the container:

/ var/lib/libstorage/volumes/mysqldata/data is mount to the container's directory / var/lib/mysql, so that Rex-Ray volume mysqldata has already mount to the container mydb_on_docker1.

Update the database

Follow these steps to update the MySQL data:

① enters the container mydb_on_docker1.

② logs in to the database and enters the password specified by the environment variable MYSQL_ROOT_PASSWORD when the container starts.

③ switches to database mysql.

④ creates the database table my_id.

⑤ inserts a piece of data.

⑥ confirms that the data has been written.

Execute docker rm-f mydb_on_docker1 to delete the container.

After reading the above, do you have any further understanding of how to create Rex-Ray volume? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Tags: Data container database content directory update success next command configuration valid information variable size host host password underlying more validity Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Huawei Shulou Tech Info macOS Docker