美文网首页
Ubuntu系统配置,以及Docker,Rancher的安装

Ubuntu系统配置,以及Docker,Rancher的安装

作者: jfwangncs | 来源:发表于2019-05-30 09:38 被阅读0次

    1、Ubuntu的配置

    1.1 配置主机时间、时区、系统语言

    • 查看时区
    date -R或者timedatectl
    
    • 修改时区
    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    
    • 修改系统语言环境
    sudo echo 'LANG="en_US.UTF-8"' >> /etc/profile;source /etc/profile
    
    • 配置主机NTP时间同步

    1.2 Kernel性能调优

    cat >> /etc/sysctl.conf<<EOF
    net.ipv4.ip_forward=1
    net.bridge.bridge-nf-call-iptables=1
    net.ipv4.neigh.default.gc_thresh1=4096
    net.ipv4.neigh.default.gc_thresh2=6144
    net.ipv4.neigh.default.gc_thresh3=8192
    EOF
    

    1.3 Ubuntu国内更新源

    sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup      
    vi /etc/apt/sources.list
    #注释原文件内的源并添加如下地址
    #Ubuntu 官方源 
    deb http://archive.ubuntu.com/ubuntu/ gutsy main restricted universe multiverse
    deb http://archive.ubuntu.com/ubuntu/ gutsy-security main restricted universe multiverse
    deb http://archive.ubuntu.com/ubuntu/ gutsy-updates main restricted universe multiverse
    deb http://archive.ubuntu.com/ubuntu/ gutsy-proposed main restricted universe multiverse
    deb http://archive.ubuntu.com/ubuntu/ gutsy-backports main restricted universe multiverse
    deb-src http://archive.ubuntu.com/ubuntu/ gutsy main restricted universe multiverse
    deb-src http://archive.ubuntu.com/ubuntu/ gutsy-security main restricted universe multiverse
    deb-src http://archive.ubuntu.com/ubuntu/ gutsy-updates main restricted universe multiverse
    deb-src http://archive.ubuntu.com/ubuntu/ gutsy-proposed main restricted universe multiverse
    deb-src http://archive.ubuntu.com/ubuntu/ gutsy-backports main restricted universe multiverse 
    #添加下面的源
    #阿里云
    deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
    #更新源
    sudo apt-get update
    #更新软件
    sudo apt-get dist-upgrade
    sudo apt-get upgrade
    

    1.4 Docker-ce安装

    #step1
    sudo apt-get remove docker docker-engine docker.io containerd runc
    sudo apt-get update
    #step2
    sudo apt-get install \
        apt-transport-https \
        ca-certificates \
        curl \
        gnupg-agent \
        software-properties-common
    
    #step3 
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    
    #step4
    sudo apt-key fingerprint 0EBFCD88
    
    #step5
    sudo add-apt-repository \
       "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
       $(lsb_release -cs) \
       stable"
    
    #step6
    sudo apt-get update
    
    #step7
    sudo apt-get install docker-ce docker-ce-cli containerd.io
    
    

    1.5 Docker配置

    配置镜像加速地址

    编辑/etc/docker/daemon.json加入以下内容

    {
    "registry-mirrors": ["https://registry.docker-cn.com"]
    }
    

    配置Docker存储驱动

    OverlayFS是一个新一代的联合文件系统,类似于AUFS,但速度更快,实现更简单。Docker为OverlayFS提供了两个存储驱动程序:旧版的overlay,新版的overlay2(更稳定)。

    先决条件:

    • overlay2: Linux内核版本4.0或更高版本,或使用内核版本3.10.0-514+的RHEL或CentOS。
    • overlay: 主机Linux内核版本3.18+
    • 支持的磁盘文件系统

    编辑/etc/docker/daemon.json加入以下内容

    {
    "storage-driver": "overlay2",
    "storage-opts": ["overlay2.override_kernel_check=true"]
    }
    

    配置日志驱动

    容器在运行时会产生大量日志文件,很容易占满磁盘空间。通过配置日志驱动来限制文件大小与文件的数量。 >限制单个日志文件为100M,最多产生3个日志文件

    {
    "log-driver": "json-file",
    "log-opts": {
        "max-size": "100m",
        "max-file": "3"
        }
    }
    

    1.6 Rancher 1.6 单容器部署

    sudo docker run -d --restart=unless-stopped -p 8080:8080 rancher/server
    

    相关文章

      网友评论

          本文标题:Ubuntu系统配置,以及Docker,Rancher的安装

          本文链接:https://www.haomeiwen.com/subject/nsaptctx.html