重新装了个虚拟机,回顾一下最近三天的工作:

Centos 查看版本 cat /etc/redhat-release

yum -y upgrade 升级所有包,不改变软件设置和系统设置,系统版本升级,内核不改变

目前的版本为CentOS Linux release 7.2.1511 (Core)

添加内核参数

默认配置下,在 CentOS 使用 Docker 可能会碰到下面的这些警告信息:

WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled

添加内核配置参数以启用这些功能。

$ sudo tee -a /etc/sysctl.conf <<-EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF

然后重新加载 sysctl.conf 即可

$ sudo sysctl -p

添加 yum 源

虽然 CentOS 软件源 Extras 中有 Docker,名为 docker,但是不建议使用系统源中的这个版本,它的版本相对比较陈旧,而且并非 Docker 官方维护的版本。因此,我们需要使用 Docker 官方提供的 CentOS 软件源。

执行下面的命令添加 yum 软件源。

$ sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF

安装 Docker

更新 yum 软件源缓存,并安装 docker-engine

$ sudo yum update
$ sudo yum install docker-engine

启动 Docker 引擎

$ sudo systemctl enable docker
$ sudo systemctl start docker

建立 docker 用户组

默认情况下,docker 命令会使用 Unix socket 与 Docker 引擎通讯。而只有 root用户和 docker 组的用户才可以访问 Docker 引擎的 Unix socket。出于安全考虑,一般 Linux 系统上不会直接使用 root 用户。因此,更好地做法是将需要使用 docker的用户加入 docker 用户组。

建立 docker 组:

$ sudo groupadd docker

将当前用户加入 docker 组:

$ sudo usermod -aG docker $USER

将Loop-LVM改为Direct-LVM

 

新添加一块硬盘SDB,新建分区,格式化

新添加一块硬盘 sdb

  $dd if=/dev/zero of=/dev/sdb bs=4k count=1k

新建分区

  $fdisk /dev/sdb

  $mkfs.ext3 /dev/sdb

备份本地镜像,停止docker daemon并清除存储目录

  $systemctl stop docker.service

  $rm -rf /var/lib/docker

在/dev/sdb上创建LVM物理卷(PV)

  $pvcreate /dev/sdb

创建卷组vg-docker

  $vgcreate vg-docker /dev/sdb


Create a thin pool named thinpool.

In this example, the data logical is 95% of the ‘docker’ volume group size. Leaving this free space allows for auto expanding of either the data or metadata if space runs low as a temporary stopgap.

  $ lvcreate --wipesignatures y -n thinpool vg-docker -l 95%VG

  $ lvcreate --wipesignatures y -n thinpoolmeta vg-docker -l 1%VG

Convert the pool to a thin pool.

  $ lvconvert -y --zero n -c 512K --thinpool vg-docker/thinpool --poolmetadata vg-docker/thinpoolmeta

Configure autoextension of thin pools via an lvm profile.

  $ vi /etc/lvm/profile/docker-thinpool.profile

  thin_pool_autoextend_threshold = 80

   thin_pool_autoextend_percent = 20

Apply your new lvm profile

  $ lvchange --metadataprofile metadata_profile_template vg-docker/thinpool

Verify the lv is monitored.

  $ lvs -o+seg_monitor

If the Docker daemon was previously started, move your existing graph driver directory out of the way.

  $ mkdir /var/lib/docker.bk

  $ mv /var/lib/docker/* /var/lib/docker.bk

Configure the Docker daemon with specific devicemapper options.

 
 

reload systemd to scan for changes,Start the Docker daemon  

  $ systemctl daemon-reload

  $ systemctl start docker

  $journalctl -fu dm-event.service

  $ rm -rf /var/lib/docker.bk

参考文档

  https://docs.docker.com/engine/userguide/storagedriver/device-mapper-driver/

  http://blog.sina.com.cn/s/blog_6f2d2e310102wrvi.html

  http://www.bubuko.com/infodetail-1039489.html

Centos中的Docker 配置:将loop-lvm改为derict-lvm的更多相关文章

  1. Docker学习笔记之-在CentOS中安装Docker

    上一节演示了如何 通过Xshell连接CentOS服务,链接:Docker学习笔记之-通过Xshell连接 CentOS服务 本节将演示 如何在CentOS中安装 Docker 第一步:更新系统包到最 ...

  2. CentOS中利用Docker安装RabbitMQ

    CentOS中利用Docker安装RabbitMQ 1.拉取镜像(带管理平台) #docker pull rabbitmq:3.7.7-management 2.启动容器: #docker run - ...

  3. CentOS中利用Docker安装Redis

    CentOS中利用Docker安装Redis 1.拉取镜像 #docker pull redis:4.0.10 2.加载镜像 #docker run -p 6379:6379 --name test- ...

  4. CentOS 中利用docker安装MySQL

    1.前提条件 centos7 且内核版本高于3.10, 可通过命令: uname -r 查看内核版本 2.利用yum 安装docker 安装一些必要的系统工具: sudo yum install -y ...

  5. centos中apache-tomcat的配置

    在centos中配置Apache-toncat需要先安装jdk,前面文章已经写了怎么配置jdk,这里略过. 首先到官网下载好Apache-tomcat安装包,我这里下载的是apache-tomcat- ...

  6. 1,Linux(CentOS)中的基本配置

    1,hostname(主机名) 查看主机名:hostname 临时修改主机名:hostname hadoop1 永久修改主机名:vi etc/sysconfig/network :  [NETWORK ...

  7. CentOs中玩docker

    1.启动: systemctl start docker.service 2.停止: systemctl stop docker 3.从usts上拉取仓库 编辑文件 vi /etc/docker/da ...

  8. centos中网卡的配置

    配置临时IP: ip a a 192.168.59.100/24 dev ens32 ifconfig ens32 192.168.59.100 up 在Linux最小安装之后,一般需要手动配置网络地 ...

  9. Centos中使用Docker部署Apollo

    采用微服务开发框架开发项目时会涉及多个系统,如果要更改配置参数需要在多个系统间逐一更改,比较费时,而且容易遗漏,效率低下,次问题可以采用Apollo配置中心的方式解决,下面将介绍如何配置: 准备环境: ...

随机推荐

  1. AngularJs的UI组件ui-Bootstrap分享(五)——Pager和Pagination

    ui-bootstrap中有两个分页控件,一个是轻量级的Pager,只有上一页和下一页的功能,另一个是功能完整的Pagination,除了上一页和下一页,还可以选择首页和最后页,并且支持多种页数的显示 ...

  2. Android ContentResolve使用

    在Android中使用ContentResolve访问其他程序的数据: http://developer.android.com/reference/android/content/ContentPr ...

  3. oracle 小知识

    oracle: 数值随机的函数是 dbms_random.value(最大值,最小值)   用法是select dbms_random(3,0) from dual; oracle: 获取前100条 ...

  4. poj3181 Dollar Dayz ——完全背包

    link:http://poj.org/problem?id=3181 本来很常规的一道完全背包,比较有意思的一点是,结果会超int,更有意思的解决方法是,不用高精度,用两个整型的拼接起来就行了.OR ...

  5. c++字符串变量---8

    原创博客:转载请标明出处:http://www.cnblogs.com/zxouxuewei/ 一.字符串变量的定义 1>.对于C与C++来说是没有字符串型的数据类型的,在C++中是通过包含st ...

  6. UVa 10562看图写树(二叉树遍历)

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  7. Timer和TimerTask的用法

    最近在做java课程设计的时候,我用到了timer,于是学习了一下timer的用法. java实现多线程比较常用的两种方法,一种是直接继承Thread类,另一种则是实现Runnable接口.Timer ...

  8. 理解伪元素 :before和:after

    在CSS中有一特性允许我们添加额外元素而不扰乱文档本身,就是伪元素. 下面举例说明: html: <blockquote>  blockquote只是一个块引用 </blockquo ...

  9. C#对象复制 ICloneable

    在.net framework中,提供了ICloneable接口来对对象进行克隆.当然,你也可以不去实现ICloneable接口而直接自己定义一个Clone()方法,当然,还是推荐实现ICloneab ...

  10. LeetCode 【235. Lowest Common Ancestor of a Binary Search Tree】

    Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BS ...