In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how to add data disks to the Docker of CCS, which has certain reference value. Interested friends can refer to it. I hope you will learn a lot after reading this article. Let's take a look at it.
The data of Docker is stored on disk through federated file system. When the number of containers or images that need to be run on the machine is increasing, it is possible that the size of the disk can no longer meet the demand. In this case, you need to expand the storage space of the Docker data directory by adding data disks.
Docker data directory
The default container and mirror data storage directory for Docker is under / var/lib/docker. You can check the size of the disk currently occupied by this directory through the du command, for example:
Du-h-max-depth=0 / var/lib/docker7.9G / var/lib/docker replace the data disk of Docker
Because many Docker images are very large, several images may take up a lot of disk space, resulting in insufficient disk space. The need to continue to increase images or containers can be met by adding data disks to the Docker data directory.
Purchase an ECS data disk and mount it to the machine that needs to be expanded
Log in to the ECS console and purchase the cloud disk with the appropriate configuration.
Click the ECS instance details page > this instance disk > Mount disk, select the disk you just purchased, and record the mount point / dev/xvd* or / dev/vd*. The mount point is determined according to the cd command, and the mount point of the IO optimized instance is / dev/vd*.
Log in to the machine and format the disk you just mounted
First execute ls-l / dev/xvd* or ls-l / dev/vd* on the machine to see the same disk ID as you just recorded.
Partition the disk with the fdisk command, and then format the disk using mkfs.ext4. For more information, see Linux formatting and mounting the data disk, for example:
Root@iZbp16h2ijt5er5wempg4sZ:~# ls-l / dev/vd* brw-rw---- 1 root disk 253,0 Jan 5 17:44 / dev/vda brw-rw---- 1 root disk 253,1 Jan 5 17:44 / dev/vda1 brw-rw---- 1 root disk 253,16 Jan 5 17:55 / dev/vdb root@iZbp16h2ijt5er5wempg4sZ:~# fdisk-S 56 / dev/vdb Welcome to fdisk (util-linux 2.27.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table. Created a new DOS disklabel with disk identifier 0x44e128c4. Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-41943039, default 2048): Last sector, + sectors or + size {K Magi M Greco T paper P} (2048-41943039, default 41943039): Created a new partition 1 of type 'Linux' and of size 20 GiB. Command (m for help): wq The partition table has been altered. Calling ioctl () to re-read partition table. Syncing disks. Root@iZbp16h2ijt5er5wempg4sZ:~# ll / dev/vd* brw-rw---- 1 root disk 253, 0 Jan 5 17:44 / dev/vda brw-rw---- 1 root disk 253, 1 Jan 5 17:44 / dev/vda1 brw-rw---- 1 root disk 253, 16 Jan 5 17:58 / dev/vdb brw-rw---- 1 root disk 253 17 Jan 5 17:58 / dev/vdb1 # # New partition root@iZbp16h2ijt5er5wempg4sZ:~# mkfs.ext4 / dev/vdb1 # # formatted mke2fs 1.42.13 (17-May-2015) Creating filesystem with 5242624 4k blocks and 1310720 inodes Filesystem UUID: cef1625c-7533-4308-bc44-511580e3edc8 Superblock backups stored on blocks: 32768, 98304,163840,229376,294912,819200,884736,1605632,2654208,4096000 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
Move Docker data to a new disk
First stop Docker daemon, ensure the integrity of the data when moving, and execute the service docker stop command to stop Docker daemon.
First move the data under the Docker default data directory to a backup directory, such as / var/lib/docker_data, and execute the command mv / var/lib/docker / var/lib/docker_data.
Then mount the new formatted disk to the / var/lib/docker directory and execute the command echo "/ dev/vdb1 / var/lib/docker ext4 defaults 00" > > / etc/fstab & & mkdir / var/lib/docker & & mount-a.
Move the previously backed up Docker data to a new disk and execute the command mv / var/lib/docker_data/* / var/lib/docker/.
Start Docker daemon and check the data location
Start Docker daemon and execute the command service docker start.
Execute the command df and you can see that / var/lib/docker is mounted to the new disk.
Root@iZbp16h2ijt5er5wempg4sZ:/# df-h Filesystem Size Used Avail Use% Mounted on udev 2.0G 02.0G 0% / dev tmpfs 396M 7.1m 389m 2% / run/ dev/vda1 40G 2.7G 35G 8% / tmpfs 2.0G 476K 2.0G 1% / dev/shm tmpfs 5.0M 05.0M 0% / run/lock tmpfs 2.0G 02.0G 0% / sys/fs/cgroup tmpfs 396M 0396M 0% / run/user/0 / dev/vdb1 20G 2.1G 17G 12% / var/lib/docker # # this directory is hung on a new disk.
Execute the command docker ps to see if the container is missing, and restart the relevant containers as needed, such as those with no restart:always tag.
Thank you for reading this article carefully. I hope the article "how to add data disks to Container Service Docker" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.