安装虚拟机过程
此处略过主要讲一下配置联网
配置联网
编辑虚拟机网络
网络适配器 – NAT模式
输出命令查看配置文件名
ls /etc/sysconfig/network-scripts
我的是ens33
vi /etc/sysconfig/network-scripts/ifcfg-ens33 对我们的配置文件进行编辑
只用把ONBOOT=no改为yes即可 然后点击esc,键入:wq保存并退出
最后一步输入reboot直接重启虚拟机,可以联网
使用时候还有可能遇到DNS解析失败,我们需要继续配置
切换阿里云源
先备份当前源
sudo cp /etc/yum.repos.d/pgdg-redhat-all.repo /etc/yum.repos.d/pgdg-redhat-all.repo.backup
切换阿里云源
sudo curl -o /etc/yum.repos.d/pgdg-redhat-all.repo https://mirrors.aliyun.com/postgresql/repos/yum/12/redhat/rhel-7-x86_64/pgdg-redhat-all.repo
检查网络链接
ping -c 4 google.com
检查和配置 DNS
sudo vi /etc/resolv.conf
进入后按O编辑
nameserver 8.8.8.8
nameserver 8.8.4.4
按ESC 输出:wq保存退出
q!是不保存退出
如果还是不行 vi /etc/yum.repos.d/CentOS-Base.repo编辑
# CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever – Base – mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever – Updates – mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever – Extras – mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever – Plus – mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #contrib – packages by Centos Users [contrib] name=CentOS-$releasever – Contrib – mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
注意版本。我是在24-8-9使用
重新输入 ping -c 4 google.com 验证联网
可以安装些常用软件
sudo rpm -ivh http://mirror.centos.org/centos/7/updates/x86_64/Packages/yum-3.4.3-167.el7.centos.noarch.rpm 验证安装结果
rpm -q yum
sudo yum install vim
安装软件时,可能会出现一些问题
可以手动添加/etc/yum.repos.d/文件中的repo的内容,来添加你需要的地址
可以使用yum info app名称来查看用的地址
有时候需要删除无用的repo相关文件
同步时间工具
sudo yum install chrony
启动或者关闭
sudo systemctl start chronyd
sudo systemctl enable chronyd
同步时间
sudo chronyc -a makestep
评论前必须登录!
注册