1.网络配置
1.1 修改配置文件
修改配置文件 /etc/sysconfig/network-scripts/ifcfg-ens32。
1
2
3
4
5
6
7
8
9
10
11
12
13
| TYPE="Ethernet"
BOOTPROTO="static"
DEFROUTE="yes"
NAME="ens32"
DEVICE="ens32"
ONBOOT="yes"
IPADDR=192.168.78.131
NETMASK=255.255.255.0
GATEWAY=192.168.78.2
DNS1=网关
DNS2=8.8.8.8
|
1.2 重启网卡
1
| systemctl restart network
|
1.3 验证
2.关闭防火墙
1
2
3
4
| iptables -F
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld
|
3.关闭 SElinux
使用 getenforce 命令显示 SElinux 状态,Enforcing 为执行状态,Disabled 为关闭状态。
临时关闭: ```shell setenforce 0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
永久关闭,修改 `/etc/selinux/config` 或 `/etc/sysconfig/selinux` 文件,将 `SELINUX=enforcing` 改为 `SELINUX=disabled`(重启后生效)。
```shell
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
|
4.修改主机名
1
| hostnamectl set-hostname xxx
|
5.配置主机和 IP 映射关系
修改 /etc/hosts 文件,如果是集群的话,需要配置多个主机 ip 映射。
1
2
3
| cat >> /etc/hosts << EFO
192.168.78.150 k8s-master1
EFO
|
6.配置 yum 源
6.1 备份本地源
1
| mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
|
6.2 下载阿里源
1
| wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
|
6.3 清理YUM缓存
1
| yum clean all && yum makecache
|
6.4 安装 epel 扩展源
1
| yum install -y epel-release
|
6.5 测试
7.时间同步
7.1 安装 ntpdate 命令
7.2 进行时间同步
1
| ntpdate cn.pool.ntp.org
|
7.3 配置定时任务
1
2
| crontab -e
* */1 * * * /usr/sbin/ntpdate cn.pool.ntp.org
|
8.安装常用命令
1
2
3
4
5
| yum -y install net-tools tree wget lrzsz vim unzip bash-completion build-essential yum-utils \
telnet telnet-server device-mapper-persistent-data lvm2 nfs-utils gcc gcc-c++ make cmake \
libxml2-devel openssl-devel curl curl-devel sudo ntp libaio-devel ncurses-devel autoconf \
automake zlib-devel python-devel epel-release openssh-server socat ipvsadm conntrack \
ntpdate ipvsadm
|