2019独角兽企业重金招聘Python工程师标准>>>
1.升级系统内核
查看内核版本:
uname -r
2.6.32-573.8.1.el6.x86_64
导入elrepo的key:
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
curl 报ssl错误,解决办法:
yum update -y nss curl libcurl openssh
安装elrepo.repo:
rpm -Uvh https://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm
安装内核:
(安装最新版内核)yum --enablerepo=elrepo-kernel -y install kernel-ml
(安装长期稳定版内核)yum --enablerepo=elrepo-kernel -y install kernel-lt
修改grub.conf文件:
vim /etc/grub.conf --> default=0
重启服务器查看内核:
reboot
uname -r
4.4.162-1.el6.elrepo.x86_64
2.安装docker
对于centos6好像是没有yum最新版,只能通过升级方式了。
方法一:centos6下安装epel源,我的服务器好像不行。
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm sudo rpm -Uvh epel-release-6*.rpm
yum install docker-io
方法二:生成docker.repo
tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF
yum update
yum install docker-engine
测试docker:
docker --version
service docker status
3.升级docker
源码编译docker(需要服务器有老版本的docker):
升级git:
1.安装环境
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc -y
yum install gcc perl-ExtUtils-MakeMaker -y
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make && make install
yum install xmlto -y
2.安装配置
yum remove git
wget https://github.com/git/git/archive/v2.2.1.tar.gz
tar zxvf v2.2.1.tar.gz
cd git-2.2.1
make configure
./configure --prefix=/usr/local/git --with-iconv=/usr/local/libiconv
make all doc
make install install-doc install-html
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
source /etc/bashrc
安装golang
#Docker使用Golang开发
wget https://dl.google.com/go/go1.10.linux-amd64.tar.gz
tar xzf go1.10.linux-amd64.tar.gz -C /usr/local
mkdir /usr/local/gopackage
加入环境变量
vi /etc/profile
GOROOT=/usr/local/go
GOPATH=/usr/local/gopackage
PATH=$PATH:$GOROOT/bin:$GOPATH/bin
export GOROOT GOPATH PATH
source /etc/profile
下载源码并编译:
#docker改名为moby,不用纠结
git clone https://github.com/moby/moby
cd moby
#要啥版本你自己看着切换,我们选择比较稳定的最新版本17.03.2
git checkout v17.03.2-ce
make build
#编译源码:
下载1.9.1然后替换
curl -sSL -O https://get.docker.com/builds/Linux/x86_64/docker-1.9.1
chmod +x docker-1.9.1
sudo mv docker-1.9.1 /usr/bin/docker
service docker restart
编译源码
make binary
make instal
卸载并更新:
#卸载旧的docker
yum remove docker-io -y
#清理下遗留的文件
rm -rf /var/lib/docker/*
#docker 配置文件
wget https://raw.githubusercontent.com/moby/moby/master/contrib/init/sysvinit-redhat/docker.sysconfig -O /etc/sysconfig/docker
#docker init启动文件
wget https://raw.githubusercontent.com/moby/moby/master/contrib/init/sysvinit-redhat/docker -O /etc/init.d/docker
#修改启动文件中dockerd的位置
sed -i "27s#usr/bin#usr/local/bin#g" /etc/init.d/docker
#修改环境变量,覆盖functions脚本中的PATH,防止无法找到docker-container等程序
sed -i "23s#functions#functions\nexport PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin#g" /etc/init.d/docker
#启动
service docker restart
#查看版本
docker version