资讯专栏INFORMATION COLUMN

服务器配置docker&硬盘格式化

fancyLuo / 2151人阅读

摘要:如下面示例中的有两种情况,你这个数据盘是新购买的,以前没有用过没有存储过数据,那么就要对其进行格式化,使用命令。以下命令写入新分区信息查看,出现以下信息就表示写入成功。

转载请注明出处 http://www.paraller.com
原文排版地址 点击获取更好阅读体验

安装docker

安装docker Engine & docker-compose
Daoclound 安装起步

配置/etc/docker/daemon.json

{
    "registry-mirrors": [
        "http://58f8b602.m.daocloud.io"
    ],
    "insecure-registries": ["docker.umiit.cn:5043"]   
}

docker login -u "umiit" -p "***"   docker.umiit.cn:5043
vim ~/.bash_profile

export PS1="[u@`/sbin/ifconfig eth0 | sed -nr "s/.*inet (addr:)?(([0-9]*.){3}[0-9]*).*/2/p"` W  centerServer! ]$  " 
aliyun ecs 挂载云盘

先购买一个云盘 500G大小

查看硬盘情况fdisk -l

查看是否有一个 /dev/xvdb 或者 数据盘大小与你要挂载一致的硬盘

Disk /dev/xvda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000da36d

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *        2048   209713151   104855552   83  Linux

Disk /dev/xvdb: 214.7 GB, 214748364800 bytes            //重点
255 heads, 63 sectors/track, 26108 cylinders, total 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/xvdb doesn"t contain a valid partition table

执行分区

fdisk /dev/xvdb ;对数据盘进行分区;根据提示,依次输入“n”,“p”“1”,两次回车,“wq”,分区就开始了,很快就会完成。

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x5c273d61.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won"t be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-419430399, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-419430399, default 419430399):
Using default value 419430399

Command (m for help): wq
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

查看硬盘信息

fdisk -l 查看新的分区。新分区 xvdb1 已经创建好。如下面示例中的/dev/xvdb1

Disk /dev/xvda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000da36d

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *        2048   209713151   104855552   83  Linux

Disk /dev/xvdb: 214.7 GB, 214748364800 bytes
86 heads, 25 sectors/track, 195083 cylinders, total 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5c273d61

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdb1            2048   419430399   209714176   83  Linux

有两种情况,

你这个数据盘是新购买的,以前没有用过(没有存储过数据),那么就要对其进行格式化,使用 mkfs.ext3 /dev/xvdb1命令。

第二种,如果你之前就有数据盘,只是你把系统盘重置了,需要将数据盘再次挂载到重置后的系统上,那么就不要对其格式化(跳过此步骤),直接执行后面的步骤挂载就可以了。

mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
13107200 inodes, 52428544 blocks
2621427 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
1600 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
    4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

挂载到 /mnt

前提是你已经创建了这个目录(创建目录的命令是mkdir)。以下命令写入新分区信息

echo "/dev/xvdb1  /mnt ext3    defaults    0  0" >> /etc/fstab

查看,出现以下信息就表示写入成功。

cat /etc/fstab

UUID=af414ad8-9936-46cd-b074-528854656fcd / ext4 errors=remount-ro 0 1
/dev/xvdb  /mnt ext3    defaults    0  0

挂载新分区

使用mount -a挂载,df -h命令查看,出现以下信息就说明挂载成功,可以开始使用新的分区了。

df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1       20G  1.3G   18G   7% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
udev            2.0G  4.0K  2.0G   1% /dev
tmpfs           396M  372K  395M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            2.0G     0  2.0G   0% /run/shm
none            100M     0  100M   0% /run/user
/dev/xvdb        99G   60M   94G   1% /mnt

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/7999.html

相关文章

  • 删除docker-register的镜像& none无效镜像讲解

    摘要:原文排版地址删除的镜像无效镜像讲解背景介绍在服务器上搭建了所有的构建镜像都会集中在一个服务器上,久而久之硬盘就被塞满了。一是标签的镜像,二是删除物理镜像。无效的镜像另一种类型的镜像是,这种类型会造成磁盘空间占用问题。 原文排版地址:删除docker-register的镜像& none无效镜像讲解 背景介绍 在服务器上搭建了docker registry,所有的构建镜像都会集中在一个服务...

    wslongchen 评论0 收藏0
  • CKA-搭建k8s

    1:节点准备系统:centos7.5以上,2核4G以上,30G硬盘以上系统参数配置:1)关闭swap,free -m; swapoff -a2)关闭防火墙 systemctl stop firewalld;systemctl status firewalld3)关闭selinux :vim /etc/selinux/config 修改disable临时关闭setenforce 0查看selinxu...

    社区管理员 评论0 收藏0
  • 务器的硬件配置

      服务器其实就是一台配置更高的计算机,它的内部结构也和普通的计算机大同小异。图 1 所示为拆开盖子后的 服务器内部结构图。    可以看到,服务器是由电源、CPU、内存、硬盘、风扇、光驱等几部分构成。本节将挑选一些重要的硬件,给大家做详细介绍。  电源    电源相当于人体的心脏,需保障电力供应,如果要买服务器,应选择质量好一点的电源。  另外需要注意的是,在实际使用场景中,如果只是配置一个服务...

    白马啸西风 评论0 收藏0
  • 使用Docker-compose打包整个网站项目一键部署

    一、前言我们常常见到很多比较棒的开源项目,但在本地安装运行的话就会很复杂,要配置不同的环境,安装不同的依赖,好一点的会用docker直接拉取,或者打包好。这些无疑都会增加初学者上手的成本,所以这篇文章总结了下目前比较常用的解决方法之一:使用docker-compose同时管理多个服务,只需要一行命令docker compose up -d,就可以启动一个包含后端项目、前端项目、数据库的完整服务。而...

    社区管理员 评论0 收藏0

发表评论

0条评论

fancyLuo

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<