一、基础环境配置1 IP 修改机器克隆后 IP 修改 , 使Xshell连接上
文章插图
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens160TYPE="Ethernet"PROXY_METHOD="none"BROWSER_ONLY="no"BOOTPROTO="static" # 配置静态IP , 防止修改DEFROUTE="yes"IPV4_FAILURE_FATAL="no"IPV6INIT="yes"IPV6_AUTOCONF="yes"IPV6_DEFROUTE="yes"IPV6_FAILURE_FATAL="no"IPV6_ADDR_GEN_MODE="stable-privacy"NAME="ens160"UUID="d20c4f2e-c799-46e6-9a7a-0579c1791c27"DEVICE="ens160"ONBOOT="yes"IPADDR="192.168.192.10" # 修改ip地址PREFIX="24"GATEWAY="192.168.192.2" # 修改网关地址IPV6_PRIVACY="no"DNS1=114.114.114.114 # DSN配置上 , 不然使用域名会找不到的DNS2=8.8.8.8
重启网卡 , 并测试好不好使[root@localhost software]# nmcli c reload ens160[root@localhost software]# nmcli c up ens160Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/5)[root@localhost software]# 重启完后测试[root@localhost software]# ping 114.114.114.114PING 114.114.114.114 (114.114.114.114) 56(84) bytes of data.64 bytes from 114.114.114.114: icmp_seq=1 ttl=128 time=30.8 ms64 bytes from 114.114.114.114: icmp_seq=2 ttl=128 time=30.6 ms64 bytes from 114.114.114.114: icmp_seq=3 ttl=128 time=28.10 ms64 bytes from 114.114.114.114: icmp_seq=4 ttl=128 time=30.1 ms64 bytes from 114.114.114.114: icmp_seq=5 ttl=128 time=34.4 ms^C--- 114.114.114.114 ping statistics ---5 packets transmitted, 5 received, 0% packet loss, time 14msrtt min/avg/max/mdev = 28.999/30.978/34.430/1.841 ms
2 设置主机名hostnamectl set-hostname kube-master01hostnamectl set-hostname kube-node01hostnamectl set-hostname kube-node02hostnamectl set-hostname kube-vip
3 配置hosts本地解析cat > /etc/hosts <<EOF127.0.0.1localhost localhost.localdomain localhost4 localhost4.localdomain4::1localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.192.10 kube-master01192.168.192.20 kube-node01192.168.192.30 kube-node02192.168.192.40 kube-vipEOF
4 关闭防火墙 / Selinux / Swap为了避免额外的干扰 , 需要关闭防火墙 , 对于公有云 , 内网端口一般全开放 , 外网端口通过安全组控制# 关闭防火墙[root@localhost ~]# systemctl stop firewalld[root@localhost ~]# systemctl disable firewalldRemoved /etc/systemd/system/multi-user.target.wants/firewalld.service.Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.# 关闭Selinux# 永久关闭[root@localhost ~]# sed -i "s#^SELINUX=.*#SELINUX=disabled#g" /etc/selinux/config# 临时关闭[root@localhost ~]# setenforce 0# 检查[root@localhost ~]# /usr/sbin/sestatus -vSELinux status:enabled# 先查看 Swap有没有[root@localhost ~]# free -mtotalusedfreesharedbuff/cacheavailableMem:1800120812215469417Swap:2047152032# 关闭 Swap 分区 , Swap 会影响性能[root@localhost ~]# swapoff -a && sysctl -w vm.swappiness=0vm.swappiness = 0[root@localhost ~]# sed -ri '/^[^#]*swap/s@^@#@' /etc/fstab# 在确认下 [查看swap一行全是0就正确][root@localhost ~]# free -mtotalusedfreesharedbuff/cacheavailableMem:1800121011025479406Swap:000[root@localhost ~]# cat /etc/hosts127.0.0.1localhost localhost.localdomain localhost4 localhost4.localdomain4::1localhost localhost.localdomain localhost6 localhost6.localdomain6# 主机名解析[root@localhost ~]# echo "127.0.0.1 $(hostname)" >> /etc/hosts[root@localhost ~]# cat /etc/hosts127.0.0.1localhost localhost.localdomain localhost4 localhost4.localdomain4::1localhost localhost.localdomain localhost6 localhost6.localdomain6127.0.0.1 localhost.localdomain
5 YUM 源配置本地或者自建服务器都需要配置 YUM 源 , 如果是云服务器由于本身就有对应云的 YUM 源 , 不需要配置# 备份旧的 yum 源cd /etc/yum.repos.d/mkdir backup-$(date +%F)mv *repo backup-$(date +%F)# 上面看不懂 , 这有简单的[root@localhost yum.repos.d]# mkdir /etc/yum.repos.d.bak[root@localhost yum.repos.d]# cp /etc/yum.repos.d/* /etc/yum.repos.d.bak/[root@localhost yum.repos.d]# ls /etc/yum.repos.d.bak/# 添加阿里云 yum 源[root@localhost yum.repos.d]# curl http://mirrors.aliyun.com/repo/Centos-7.repo -o ali.repo% Total% Received % XferdAverage SpeedTimeTimeTimeCurrentDloadUploadTotalSpentLeftSpeed1002523100252300136370 --:--:-- --:--:-- --:--:-- 13637
经验总结扩展阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- redis bitmap数据结构之java对等操作
- Docker | dockerfile构建centos镜像,以及CMD和ENTRYPOINT的区别
- 处女座男对有好感的表现处女座男遇到真爱的表现
- 没有爱情的婚姻也能幸福的星座配对
- 来者不拒是哪些星座对待爱情的态度
- 恋爱中对方做什么会让十二星座特别失望
- 总让人觉得他们已经离婚了的星座配对
- 恋爱期间不会去见对方家长的星座
- 在一起矛盾只会越来越多的星座配对
- 哪些星座配对是大家的爱情榜样