Centos 发行版内核版本2.6.32-042stab127.2 安装docker

版权声明:版权为ZZQ所有 https://blog.csdn.net/qq_39148187/article/details/81735477

Docker官网上针对Centos的的安装需求如下:

Docker requires a 64-bit installation regardless of your CentOS version. Also, your kernel must be 3.10 at minimum, which CentOS 7 runs.

看来如果我们想在低于3.x内核的操作系统(比如Centos6.6)上装Docker最新版,势必要升级内核了。且不说升级内核步骤繁琐、容易出错,单就这种比较怪异的搭配:Centos6.x + Kerneol3.X + Docker1.11,就没有人能够保证其稳定性。故我的建议是设法在Centos6.6上安装较低版本的docker。事实上,对于内核版本要大于3.10这个要求,是从Docker1.8.2版本开始的,Docker之前的版本是可以运行在较低内核版本之上的,比如1.7.1。

  

首先,看下我的操作环境以及直接安装Docker的现象:

[root@bogon docker]# uname -a

Linux bogon 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/linux

[root@bogon docker]# cat /etc/redhat-release

CentOS release 6.6 (Final)

[root@bogon docker]# docker

bash: docker: command not found

[root@bogon docker]# yum install docker

Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * epel: dl.fedoraproject.org
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
http://repos.fedorapeople.org/repos/peter/erlang/epel-6/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
To address this issue please refer to the below knowledge base article

https://access.redhat.com/articles/1320623

If above article doesn't help to resolve this issue please open a ticket with Red Hat Support.

No package docker available.
Error: Nothing to do

[root@bogon docker]# yum install docker-io

Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * epel: pubmirror1.math.uh.edu
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
http://repos.fedorapeople.org/repos/peter/erlang/epel-6/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
To address this issue please refer to the below knowledge base article

https://access.redhat.com/articles/1320623

If above article doesn't help to resolve this issue please open a ticket with Red Hat Support.

No package docker-io available.
Error: Nothing to do

可以看到,在Centos6.7的标准yum源中已经没有Docker的安装包了,这时,我们需要安装EPEL。

EPEL(Extra Packages for Enterprise Linux),企业版Linux额外包,RHEL分布非标准包的社区类库。安装如下:

[root@bogon docker]# rpm -iUvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Retrieving http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
warning: /var/tmp/rpm-tmp.em6i9i: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]

接下来安装Docker1.7.1,在1.7.1中,安装包名称为docker-io,故我们的安装命令如下:

[root@bogon docker]# yum install docker-io

Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
epel/metalink                                                                                                                                                                                            | 7.1 kB     00:00     
 * base: mirrors.tuna.tsinghua.edu.cn
 * epel: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
epel                                                                                                                                                                                                     | 4.3 kB     00:00     
epel/primary_db                                                                                                                                                                                          | 5.9 MB     00:13     
http://repos.fedorapeople.org/repos/peter/erlang/epel-6/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
To address this issue please refer to the below knowledge base article

https://access.redhat.com/articles/1320623

If above article doesn't help to resolve this issue please open a ticket with Red Hat Support.

Resolving Dependencies
--> Running transaction check
---> Package docker-io.x86_64 0:1.7.1-2.el6 will be installed
--> Processing Dependency: lxc for package: docker-io-1.7.1-2.el6.x86_64
--> Processing Dependency: libcgroup for package: docker-io-1.7.1-2.el6.x86_64
--> Running transaction check
---> Package libcgroup.x86_64 0:0.40.rc1-23.el6 will be installed
---> Package lxc.x86_64 0:1.0.9-1.el6 will be installed
--> Processing Dependency: lua-lxc(x86-64) = 1.0.9-1.el6 for package: lxc-1.0.9-1.el6.x86_64
--> Processing Dependency: lua-alt-getopt for package: lxc-1.0.9-1.el6.x86_64
--> Processing Dependency: liblxc.so.1()(64bit) for package: lxc-1.0.9-1.el6.x86_64
--> Running transaction check
---> Package lua-alt-getopt.noarch 0:0.7.0-1.el6 will be installed
---> Package lua-lxc.x86_64 0:1.0.9-1.el6 will be installed
--> Processing Dependency: lua-filesystem for package: lua-lxc-1.0.9-1.el6.x86_64
---> Package lxc-libs.x86_64 0:1.0.9-1.el6 will be installed
--> Running transaction check
---> Package lua-filesystem.x86_64 0:1.4.2-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================================================================================================
 Package                                                   Arch                                              Version                                                      Repository                                       Size
================================================================================================================================================================================================================================
Installing:
 docker-io                                                 x86_64                                            1.7.1-2.el6                                                  epel                                            4.6 M
Installing for dependencies:
 libcgroup                                                 x86_64                                            0.40.rc1-23.el6                                              base                                            131 k
 lua-alt-getopt                                            noarch                                            0.7.0-1.el6                                                  epel                                            6.9 k
 lua-filesystem                                            x86_64                                            1.4.2-1.el6                                                  epel                                             24 k
 lua-lxc                                                   x86_64                                            1.0.9-1.el6                                                  epel                                             16 k
 lxc                                                       x86_64                                            1.0.9-1.el6                                                  epel                                            122 k
 lxc-libs                                                  x86_64                                            1.0.9-1.el6                                                  epel                                            257 k

Transaction Summary
================================================================================================================================================================================================================================
Install       7 Package(s)

Total download size: 5.1 M
Installed size: 20 M

Is this ok [y/N]: y

Downloading Packages:
(1/7): docker-io-1.7.1-2.el6.x86_64.rpm                                                                                                                                                                  | 4.6 MB     00:10     
(2/7): libcgroup-0.40.rc1-23.el6.x86_64.rpm                                                                                                                                                              | 131 kB     00:00     
(3/7): lua-alt-getopt-0.7.0-1.el6.noarch.rpm                                                                                                                                                             | 6.9 kB     00:00     
(4/7): lua-filesystem-1.4.2-1.el6.x86_64.rpm                                                                                                                                                             |  24 kB     00:00     
(5/7): lua-lxc-1.0.9-1.el6.x86_64.rpm                                                                                                                                                                    |  16 kB     00:00     
(6/7): lxc-1.0.9-1.el6.x86_64.rpm                                                                                                                                                                        | 122 kB     00:00     
(7/7): lxc-libs-1.0.9-1.el6.x86_64.rpm                                                                                                                                                                   | 257 kB     00:00     
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                           457 kB/s | 5.1 MB     00:11     
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Importing GPG key 0x0608B895:
 Userid : EPEL (6) <[email protected]>
 Package: epel-release-6-8.noarch (installed)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

Is this ok [y/N]: y

Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : lxc-libs-1.0.9-1.el6.x86_64                                                                                                                                                                                  1/7
  Installing : lua-filesystem-1.4.2-1.el6.x86_64                                                                                                                                                                            2/7
  Installing : lua-lxc-1.0.9-1.el6.x86_64                                                                                                                                                                                   3/7
  Installing : libcgroup-0.40.rc1-23.el6.x86_64                                                                                                                                                                             4/7
  Installing : lua-alt-getopt-0.7.0-1.el6.noarch                                                                                                                                                                            5/7
  Installing : lxc-1.0.9-1.el6.x86_64                                                                                                                                                                                       6/7
  Installing : docker-io-1.7.1-2.el6.x86_64                                                                                                                                                                                 7/7
  Verifying  : lua-lxc-1.0.9-1.el6.x86_64                                                                                                                                                                                   1/7
  Verifying  : lxc-libs-1.0.9-1.el6.x86_64                                                                                                                                                                                  2/7
  Verifying  : lxc-1.0.9-1.el6.x86_64                                                                                                                                                                                       3/7
  Verifying  : docker-io-1.7.1-2.el6.x86_64                                                                                                                                                                                 4/7
  Verifying  : lua-alt-getopt-0.7.0-1.el6.noarch                                                                                                                                                                            5/7
  Verifying  : libcgroup-0.40.rc1-23.el6.x86_64                                                                                                                                                                             6/7
  Verifying  : lua-filesystem-1.4.2-1.el6.x86_64                                                                                                                                                                            7/7

Installed:
  docker-io.x86_64 0:1.7.1-2.el6                                                                                                                                                                                                

Dependency Installed:
  libcgroup.x86_64 0:0.40.rc1-23.el6      lua-alt-getopt.noarch 0:0.7.0-1.el6      lua-filesystem.x86_64 0:1.4.2-1.el6      lua-lxc.x86_64 0:1.0.9-1.el6      lxc.x86_64 0:1.0.9-1.el6      lxc-libs.x86_64 0:1.0.9-1.el6     

Complete!

[root@bogon docker]# docker -v

Docker version 1.7.1, build 786b29d/1.7.1


安装完成!

至此,本想升级Linux内核,但按照下面的教程没有成功,所以 http://www.docker.org.cn/book/docker/what-is-docker-16.html ,docker入门手册继续!docker pull learn/tutorial时报错,继续下一步(自动下载),就OK!

======================================================================================================================

检查当前版本

[Long80A@VM-196~]$ uname -r

2.6.32-279.el6.x86_64

查看当前的/boot/grub/grub.conf内容:

下面使用root用户操作:

[root@VM-196~]# cat /boot/grub/grub.conf

#grub.conf generated by anaconda

#

#Note that you do not have to rerun grub after making changes to this file

#NOTICE:  You do not have a /bootpartition.  This means that

#          all kernel and initrd paths arerelative to /, eg.

#          root (hd0,0)

#          kernel /boot/vmlinuz-version roroot=/dev/sda1

#          initrd/boot/initrd-[generic-]version.img

#boot=/dev/sda

default=0

timeout=5

splashimage=(hd0,0)/boot/grub/splash.xpm.gz

hiddenmenu

titleCentOS (2.6.32-279.el6.x86_64)

        root (hd0,0)

        kernel /boot/vmlinuz-2.6.32-279.el6.x86_64ro root=UUID=41262435-0821-4978-a349-5edf0b1caf32 rd_NO_LUKS rd_NO_LVMLANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgbquiet

        initrd/boot/initramfs-2.6.32-279.el6.x86_64.img

[root@VM-196~]#

安装所需要的工具:

[root@VM-196~]# yum install wget gcc gc bc gd make perl ncursec-devel xz –y

 

如果此处,执行时遇到问题,比如:

Loaded plugins: fastestmirror, security
Determining fastest mirrors
Setting up Install Process
No package gc available.
No package ncursec-devel available.
Nothing to do

【这是由于没有配置正确yum的源导致,可通过ll /etc/yum.repos.d/来检查,看看是否是存在CentOS-Base.repo,

以及内容:

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6


#released updates 
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6


#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6


#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6


#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6】

下载内核文件:

cd /usr/src  

wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.11.4.tar.xz# 内核文件

xz  -d Linux-3.11.4.tar.xz # 解压.xz   补充:目前可以直接使用 tar xvJf  ***.tar.xz来解压

tar  -xvf linux-3.11.4.tar # 解压.tar

cd linux-3.11.4

清理系统内的环境变量及依赖

make mrproper #清除环境变量

cp  /boot/config-* /usr/src/kernels/ #为了方便编译配置,将/boot下的配置文件复制到当前目录下的/usr/src/kernels/文件中

 make   menuconfig出现General setup菜单,根据自己的需要对Kernel进行增、减。

 
 
 
报错时:(yum install ncurses ncurses-devel)
 
 
 
 
 
 

 make  clean

make bzImage    #生成内核文件

make  modules    #编译模块(注:此处需要很长时间,请耐心等待,给我的环境轻松一个半小时+)

make  modules_install  #安装模块

make  install    #安装,此处报了一个vmware的错【ERROR: modinfo: could not find module vmware_balloon】,是因为在VM中运行导致的,但不影响升级

下面修改/boot/grub/grub.conf文件,把default=1改为0

[[email protected]]# vi  /boot/grub/grub.conf

#grub.conf generated by anaconda

#

#Note that you do not have to rerun grub after making changes to this file

#NOTICE:  You do not have a /bootpartition.  This means that

#          all kernel and initrd paths arerelative to /, eg.

#          root (hd0,0)

#          kernel /boot/vmlinuz-version roroot=/dev/sda1

#          initrd/boot/initrd-[generic-]version.img

#boot=/dev/sda

default=0

timeout=5

splashimage=(hd0,0)/boot/grub/splash.xpm.gz

hiddenmenu

titleCentOS (3.11.4)

        root (hd0,0)

        kernel /boot/vmlinuz-3.11.4 roroot=UUID=41262435-0821-4978-a349-5edf0b1caf32 rd_NO_LUKS rd_NO_LVMLANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgbquiet

        initrd /boot/initramfs-3.11.4.img

titleCentOS (2.6.32-279.el6.x86_64)

        root (hd0,0)

        kernel/boot/vmlinuz-2.6.32-279.el6.x86_64 roroot=UUID=41262435-0821-4978-a349-5edf0b1caf32 rd_NO_LUKS rd_NO_LVMLANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgbquiet

        initrd/boot/initramfs-2.6.32-279.el6.x86_64.img

重启之后看看版本号:

reboot

uname -r

[Long80A@VM-196 ~]$ uname -r

3.11.4

此时升级完成。

猜你喜欢

转载自blog.csdn.net/qq_39148187/article/details/81735477
今日推荐