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.? 配置內(nèi)核路由轉(zhuǎn)發(fā)
# 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