这个是很久以前第一次安装rancher时候做的笔记,现在更推荐在coreos下或者rancheros下安装,这样更简单。
1、安装Centos7 64bit:
在https://www.centos.org/download/找到下载地址:
http://isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1611.iso
2、设置主机名:
hostnamectl set-hostname node1
3、添加ssh登陆:
复制或拷贝本机证书到远程计算机:
4、升级系统到最新:
yum update
5、挂载独立的分区:
yum install xfsprogs //安装XFS 文件系统的工具集
fdisk /dev/sdb //选择需要操作的硬盘
然后依次输入 n,p,1, 回车,回车,wq
mkfs.xfs -n ftype=1 /dev/sdb1 //格式化磁盘
mkdir -p /data/docker //创建目录
echo "/dev/sdb1 /data xfs defaults,prjquota 0 0" >> /etc/fstab //挂载磁盘信息
mount -a //挂载所有磁盘
mkdir -p /data/docker //创建docker目录
ln -sv /data/docker /var/lib/docker //创建连接
6、关闭selinux:
setenforce 0
sed -i '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config
7、安装elrepo yum repo:
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
yum repolist elrepo
8、安装新内核和依赖软件:
#装依赖的软件包:
yum -y install bridge-utils net-tools psmisc subversion git fuse ntp deltarpm wget curl zip unzip bind-utils nfs-utils
#启动时间
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
systemctl enable ntpd && systemctl start ntpd
#安装 4.12.5 内核
yum -y --enablerepo=elrepo-kernel install kernel-ml-devel kernel-ml
9、使用新内核启动:
grub2-set-default 0
reboot
uname -r
4.12.0-1.el7.elrepo.x86_64
10、修改系统内核参数:
在文件 /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
11、修改资源限制
ulimit -n 100000
echo "" >> /etc/rc.local
echo ulimit -n 100000 >> /etc/rc.local
chmod +x /etc/rc.d/rc.local
12、即可修改,如果不能修改,需要设置/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