vnc 或者 shell工具进入到 rancher虚机
#-----------------------------------1. 准备 -----------------------------------------------
## 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
## 关闭 selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/sysconfig/selinux
setenforce 0
## 配置本地yum
mkdir /etc/yum.repos.d/bak && cd /etc/yum.repos.d/
mv *.repo bak
cat <<EOF >> /etc/yum.repos.d/local.repo
[Local]
name=Local
baseurl=file:///mnt
enable=1
gpgcheck=0
EOF
mount /dev/cdrom /mnt
yum clean all
## 安装常用软件
yum install -y vim lrzsz wget net-tools telnet
## 下载阿里云的yum源
cd /etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
## 更新yum缓存
yum clean all
yum makecache
## 安装工具软件
yum -y install yum-utils
## 安装扩展源
yum install -y epel-release
## 安装ntp服务,并同步时区(集群环境时钟要一致否则会有问题)
yum -y install ntp
systemctl enable ntpd
systemctl start ntpd
timedatectl set-ntp yes
ntpdate -u cn.pool.ntp.org
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
#-----------------------------------2. docker ---------------------------------------------
## 配置docker yum源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
## 更新yum
yum clean all
yum makecache
yum update
## 安装docker
yum -y install docker-ce
systemctl start docker
systemctl enable docker
systemctl status docker
## 添加docker镜像源为阿里的加速镜像源
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://ylb0zuy1.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
## 重载daemon.json文件
systemctl daemon-reload
## 开机启动
systemctl enable docker
## 重启Docker服务
systemctl restart docker
mkdir /var/lib/rancher/
#-----------------------------------3. 安装rancher ----------------------------------------
docker run -d --restart=unless-stopped -p 80:80 -p 443:443 --privileged rancher/rancher:latest
进入master虚拟机进行执行,并等待集群为active
注意,要等master 为active之后再执行
进入node1,node2虚拟机进行执行,并等待集群为active