前言
docker对centos6支持有限,能centos7以上就尽量centos7以上。
内核升级与安装BBR参考地址:CentOS 6/7手动安装BBR和魔改BBR教程
安装docker,参考地址:CentOS6.8上Docker的安装
docker从1.7升级到1.9,参考地址:Centos6.6升级docker到1.9
无论安装docker还是BBR都需要centos6把内核升级到更高的版本。
升级内核
方法一:
1 2 3 4 5 6 7 8 9 10 11 12 |
#CentOS 6系统 #导入ELRepo公钥 wget https://www.elrepo.org/RPM-GPG-KEY-elrepo.org rpm --import RPM-GPG-KEY-elrepo.org #安装ELRepo rpm -Uvh http://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm #升级最新内核 yum --enablerepo=elrepo-kernel install kernel-ml -y #调整内核启动顺序 sed -i '/default=/d' /boot/grub/grub.conf && echo -e "\ndefault=0\c" >> /boot/grub/grub.conf #重启 reboot |
方法二:
1 2 3 4 5 6 7 8 9 |
#CentOS 6系统 #下载并安装内核 wget https://www.moerats.com/usr/down/CentOS_Kernel/kernel-ml-4.12.10-1.el6.elrepo.x86_64.rpm && yum -y install kernel-ml-4.12.10-1.el6.elrepo.x86_64.rpm wget https://www.moerats.com/usr/down/CentOS_Kernel/kernel-ml-devel-4.12.10-1.el6.elrepo.x86_64.rpm && yum -y install kernel-ml-devel-4.12.10-1.el6.elrepo.x86_64.rpm wget https://www.moerats.com/usr/down/CentOS_Kernel/kernel-ml-headers-4.12.10-1.el6.elrepo.x86_64.rpm && yum -y install kernel-ml-headers-4.12.10-1.el6.elrepo.x86_64.rpm #调整内核启动顺序 sed -i '/default=/d' /boot/grub/grub.conf && echo -e "\ndefault=0\c" >> /boot/grub/grub.conf #重启 reboot |
检查当前已安装内核,并删除新内核以外的内核
1 2 |
rpm -qa | grep kernel yum remove -y 内核名 |
安装BBR
开启BBR
1 2 3 4 5 6 7 8 9 10 11 |
#查看最新内核,如果大于4.9,则进行下一步 uname -r #修改配置 cat >>/etc/sysctl.conf << EOF net.core.default_qdisc=fq net.ipv4.tcp_congestion_control=bbr EOF #使配置生效 sysctl -p #检查生效,输出带有tcp_bbr 20480 0即生效 lsmod | grep bbr |
开启魔改BBR
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
#安装依赖 yum -y install make gcc wget -O ./tcp_tsunami.c https://www.moerats.com/usr/down/CentOS_Kernel/tcp_tsunami.c #安装魔改BBR echo "obj-m:=tcp_tsunami.o" > Makefile make -C /lib/modules/`uname -r`/build M=`pwd` modules CC=/usr/bin/gcc chmod +x ./tcp_tsunami.ko cp -rf ./tcp_tsunami.ko /lib/modules/`uname -r`/kernel/net/ipv4 insmod tcp_tsunami.ko depmod -a #修改配置 echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf echo "net.ipv4.tcp_congestion_control=tsunami" >> /etc/sysctl.conf sysctl -p |
检查开启状态
1 |
lsmod | grep tsunami |
如果返回tcp_tsunami 16384 26类似信息,则开启成功。
安装Docker
1、安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
Ubuntu/Debian: curl -sSL https://get.docker.com | sh Linux 64bit binary: https://get.docker.com/builds/Linux/x86_64/docker-1.7.1 Darwin/OSX 64bit client binary: https://get.docker.com/builds/Darwin/x86_64/docker-1.7.1 Darwin/OSX 32bit client binary: https://get.docker.com/builds/Darwin/i386/docker-1.7.1 Linux 64bit tgz: https://get.docker.com/builds/Linux/x86_64/docker-1.7.1.tgz Windows 64bit client binary: https://get.docker.com/builds/Windows/x86_64/docker-1.7.1.exe Windows 32bit client binary: https://get.docker.com/builds/Windows/i386/docker-1.7.1.exe Centos 6/RHEL 6: https://get.docker.com/rpm/1.7.1/centos-6/RPMS/x86_64/docker-engine-1.7.1-1.el6.x86_64.rpm Centos 7/RHEL 7: https://get.docker.com/rpm/1.7.1/centos-7/RPMS/x86_64/docker-engine-1.7.1-1.el7.centos.x86_64.rpm Fedora 20: https://get.docker.com/rpm/1.7.1/fedora-20/RPMS/x86_64/docker-engine-1.7.1-1.fc20.x86_64.rpm Fedora 21: https://get.docker.com/rpm/1.7.1/fedora-21/RPMS/x86_64/docker-engine-1.7.1-1.fc21.x86_64.rpm Fedora 22: https://get.docker.com/rpm/1.7.1/fedora-22/RPMS/x86_64/docker-engine-1.7.1-1.fc22.x86_64.rpm |
根据自己的系统选择。
举个栗子,我要在centos6上安装docker
1 |
yum install https://get.docker.com/rpm/1.7.1/centos-6/RPMS/x86_64/docker-engine-1.7.1-1.el6.x86_64.rpm |
然后执行命令安装:
1 |
yum install docker-io |
此时:成功安装.
该命令是用源安装docker。
2、安装后的配置文件
1 2 |
[root@CentOS6 ~]# ls -l /etc/sysconfig/docker -rw-r--r--. 1 root root 199 Jul 15 2015 /etc/sysconfig/docker |
3、启动Docker后台服务
1 |
service docker start |
4、Docker Version验证
1 |
docker version |
升级docker到1.9.1
执行命令: docker network create -d bridge localbridge
,会报错:docker: ‘network’ is not a docker command.这是因为当前docker版本过低,现在升级为1.9.1
1、安装docker 1.9
1 2 3 4 5 6 7 8 9 10 |
## 下载 curl -sSL -O https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 ## 权限 chmod +x docker-1.9.1 ## 备份docker mv /usr/bin/docker /usr/bin/docker-1.7 cp ./docker-1.9.1 /usr/bin/docker ## 重启 docker /etc/init.d/docker restart |
2、验证安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
root@pts/0 # docker version Client: Version: 1.9.1 API version: 1.21 Go version: go1.4.3 Git commit: a34a1d5 Built: Fri Nov 20 17:56:04 UTC 2015 OS/Arch: linux/amd64 Server: Version: 1.9.1 API version: 1.21 Go version: go1.4.3 Git commit: a34a1d5 Built: Fri Nov 20 17:56:04 UTC 2015 OS/Arch: linux/amd64 |