碰见一个Ubuntu16下需要部署Rancher的需求,整理一份Ubuntu16的Rancher环境的文档:
1、安装系统(跳过)
2、设置主机名:
hostnamectl set-hostname docker-cp
3、添加ssh登陆:
复制或拷贝本机证书到远程计算机:
4、升级系统到最新:
apt update
apt upgrade
5、挂载独立的分区:
apt install xfsprogs //安装XFS 文件系统的工具集
fdisk /dev/vdb //选择需要操作的硬盘
然后依次输入 n,p,1, 回车,回车,wq
mkfs.xfs -n ftype=1 /dev/sdb1 //格式化磁盘
mkdir -p /data/docker //创建目录
sudo blkid //查看硬盘的UUID
echo "UUID=d844cd7c-740a-4efb-9895-316694893b18 /data xfs defaults,prjquota 0 0" >> /etc/fstab //挂载磁盘信息
mount -a //挂载所有磁盘
mkdir -p /data/docker //创建docker目录
ln -sv /data/docker /var/lib/docker //创建连接
6、升级内核版本到最新:
7、修改系统内核参数:
在文件 /etc/sysctl.conf
加入以下配置:
net.unix.max_dgram_qlen = 100
net.ipv4.tcp_mem = 379008 505344 758016
net.ipv4.tcp_wmem = 4096 16384 4194304
net.ipv4.tcp_rmem = 4096 87380 4194304
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_syncookies=1
net.ipv4.tcp_max_syn_backlog=81920
net.ipv4.tcp_synack_retries=3
net.ipv4.tcp_syn_retries=3
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 20000 65000
net.ipv4.tcp_max_tw_buckets = 200000
net.ipv4.route.max_size = 5242880
fs.file-max = 100000 #修改ulimit数量
8、修改资源限制
即可修改,如果不能修改,需要设置/etc/security/limits.conf
加入:
* soft nofile 262140
* hard nofile 262140
root soft nofile 262140
root hard nofile 262140
* soft core unlimited
* hard core unlimited
root soft core unlimited
root hard core unlimited