1. 修改IP地址、配置DNS
打开文件vi /etc/sysconfig/network-scripts/ifcfg-ens33
1 2 3 4 5 6 7
| BOOTPROTO="static" # 使用静态IP地址,默认为dhcp IPADDR="19.37.33.66" # 设置的静态IP地址 # 以下没有的话自己添加 NETMASK="255.255.255.0" # 子网掩码 GATEWAY="192.168.10.1" # 网关地址 DNS1="8.8.8.8" # DNS服务器
ONBOOT=yes #设置网卡启动方式为 开机启动 并且可以通过系统服务管理器 systemctl 控制网卡
|
然后配置公共DNS服务vi /etc/resolv.conf
1 2 3 4 5 6 7
| # 可以只配置一个 nameserver 223.5.5.5 nameserver 223.6.6.6 nameserver 114.114.114.114 nameserver 114.114.115.115 nameserver 8.8.8.8 nameserver 8.8.4.4
|
修改完成后重启 service network restart
不修改DNS可能在下载镜像源的时候报错找不到镜像地址
2. 切换镜像源
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| # 备份镜像源 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak # 下载阿里的镜像源或者网易源 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo # 重建缓存 yum clean all && yum makecache
# 可以执行 需要更新的package更新到源中的最新版 yum upgrade -y #或 yum update # yum update和yum upgrade的功能都是一样的,都是将需要更新的package更新到源中的最新版。唯一不同的是,yum upgrade会删除旧版本的package,而yum update则会保留(obsoletes=0)。 # 可执行 若更新 yum 源不更新内核: 直接在 yum 的命令后面加上如下的参数 `yum --exclude=kernel* update` # 生产环境中建议使用yum update,防止因为替换,导致旧的软件包依赖出现问题
|
3. 安装epel
EPEL (Extra Packages for Enterprise Linux)是基于Fedora的一个项目,为“红帽系”的操作系统提供额外的软件包,适用于RHEL、CentOS和Scientific Linux.
Centos下使用yum安装时往往找不到rpm的情况,官方的rpm repository提供的rpm包也不够丰富,很多时候需要自己编译很痛苦,而EPEL恰恰可以解决这两方面的问题。
EPEL是由 Fedora 社区打造,为 RHEL 及衍生发行版如 CentOS、Scientific Linux 等提供高质量软件包的项目。装上了 EPEL之后,就相当于添加了一个第三方源。
1
| yum install -y epel-release
|
防火墙配置
5. 必要软件安装
4. 安装wget
yum install wget
安装完成wget则可以使用wget方式下载镜像源
1 2 3
| wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo # wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
|
5.1. 安装vim或Nano
1 2
| yum install vim -y yum install nano -y
|
5.2. 安装ifconfig
搜索ifconfig命令位置
1 2 3
| yum search ifconfig # 可以发现`ifconfig`位于`net-tools.x86_64` yum install net-tools.x86_64 -y
|