配置网络信息
首先把你的虚拟机网络配置成net或者桥接模式(根据你的环境而定)
通过ip ad 命令查看你使用的网卡名称,比如我的是ens33
查看网卡配置文件信息
vi /etc/sysconfig/network-scripts/ifcfg-xxx(你的网卡的名字)
默认ONBOOT选项是NO,改成YES
重启网络服务systemctl restart network
基本可以成功
配置yum源
查看yum配置
cd /etc/yum.repos.d/
字段解释:
[contrib] #仓库名称
name= #仓库描述
mirrorlist= #仓库镜像路径
baseurl= #仓库URL路径
enabled= #仓库是否启用 1:表示启用 0:标识关闭。一般设置为1
gpgcheck= #仓库检测是否启用 1:表示启用 0:标识关闭。一般配置的镜像源为可信的,所以避免报错就设置为0。
gpgkey= #仓库检测路径
实际应用中不需要自己手工修改配置
开启网络镜像源
一般新安装的都没有启用网络镜像源,这样就导致使用yum命令安装一些本地源中没有的包时会失败
需要在配置文件中启用
vi /etc/yum.repos.d/CentOS-Base.repo
将enable改为1
配置yum可以使用
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
更新缓存yum makecache
更改yum源
(1)备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
(2)下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/
如果时最小安装,系统里没有wget命令,就使用curl命令安装
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
centos8(centos8官方源已下线,建议切换centos-vault源)
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
备注:
如果有报错
sed -i 's/gpgcheck=1/gpgcheck=0/g' /etc/yum.repos.d/CentOS-Base.repo
sed -i 's/enabled=0/enabled=1/g' /etc/yum.repos.d/CentOS-Base.repo
sudo sed -i -e "s|mirrorlist=|#mirrorlist=|g" /etc/yum.repos.d/CentOS-*
sudo sed -i -e "s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g" /etc/yum.repos.d/CentOS-*
--CentOS8环境中,使用yum安装组件提示Cannot prepare internal mirrorlist: No URLs in mirrorlist。CentOS 8操作系统版本于2022年1月31日寿终正寝, 如果业务过渡期仍需要使用CentOS 8中的一些安装包,建议切换至CentOS-Vault源。
(3)运行 yum makecache 生成缓存
把本地缓存的包依赖依赖关系先干掉
yum clean all
把阿里云的包依赖关系缓存到本地
yum makecache
上面这段摘自知乎https://zhuanlan.zhihu.com/p/466695112
开启图形化界面
首先安装epel库
EPEL 是 yum 的一个软件源, 里面包含了许多基本源里没有的软件了。EPEL, 即 Extra Packages for Enterprise Linux 的简称, 是为企业级 Linux 提供的一组高质量的额外软件包, 包 括但不限于 Red Hat Enterprise Linux (RHEL), CentOS and Scientific Linux (SL), Oracle Enterprise Linux (OEL). 但在我们在使 用 epel 时是需要安装它才可以了, 下文来介绍 CentOS7/RHEL7 安装 EPEL 步骤
yum -y install epel-release
报错
yum doesn’t have enough cached data to continue.
安装epel,yum -y install epel-release后,yum安装时出现如下异常:
Cannot retrieve metalink for repository: epel/x86_64. Please verify its path and try again
解决如下
1、将 /etc/yum.repos.d/epel.repo 文件中的注释metalink,去掉baseurl的注释
2、/etc/resolv.conf文件中增加nameserver 144.144.144.144(不太管用)
查看系统默认启动界面方式
systemctl get-default
若显示 graphical.target 表示开机启动图形化界面
显示 multi-user.target 表示开机启动命令行界面,我的就是命令行界面
修改系统默认启动界面
systemctl set-default graphical.target [multi-user.target]
安装可视化系统
首先安装窗口系统X Window System
yum groupinstall "X Window System"
中间的选项都选 y,若出现complete则表示安装完成
startx开启图形化界面,系统一闪而过,并没有开启出现如下所示
这是因为还没有安装桌面系统GNOME
yum -y groupinstall "GNOME Desktop"
startx或者init 5启动
如果有报错,多半因为字体原因
缺少相关字体,通过yum安装即可
yum install libXfont
yum install xorg-x11-xfs
yum install xorg-x11-xfs-utils
yum install xorg-x11-xinit
yum install xorg-x11-xdm
yum install xorg-x11-fonts
报错解决
已加载插件:fastestmirror
没有安装组信息文件
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
- base: mirrors.bupt.edu.cn
- centosplus: mirrors.aliyun.com
- extras: mirrors.aliyun.com
- updates: mirrors.aliyun.com
Warning: group X Windows System does not exist.
Maybe run: yum groups mark install (see man yum)
错误:指定组中没有可安装或升级的软件包
执行本节开头的过程,安装epel即可