1. hosts配置
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.10.130 rancherserver
2. 主机安全设置
# systemctl stop firewalld;systemctl disable firewalld
# firewall-cmd --state
not running
一、重启后永久性生效:
开启:chkconfig iptables on
关闭:chkconfig iptables off
二、即时生效,重启后失效:
开启:service iptables start
关闭:service iptables stop
# sed -ri 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
3. 时间设置
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# crontab -l
0 */1 * * * ntpdate time1.aliyun.com
4. 关闭swap
# cat /etc/fstab
默认开启,修改后关闭
#/dev/mapper/centos-swap swap swap defaults 0 0
5. 配置内核路由转发
# vim /etc/sysctl.conf
# cat /etc/sysctl.conf
...
net.ipv4.ip_forward=1
6. docker-ce安装
# wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce-23.0.1 docker-ce-cli-23.0.1systemctl enable --now docker
7. 部署及访问rancher
mkdir -p /opt/data/rancher_data
docker run -d --privileged -p 80:80 -p 443:443 -v /opt/data/rancher_data:/var/lib/rancher --restart=always --name rancher-2.7.5 rancher/rancher:v2.7.5