使用第三方软件来连接虚拟机
个人习惯:Putty 随便是用XSheel还是Putty
替换CentOS的源
和Python替换PIP源一个道理
CentOS中安装软件时一把两个选择
- RPM包安装
- 压缩文件安装
RPM包一般都是通过YUM指令来进行直接安装的.而CentOS本身的YUM源是国外的.所以我们需要替换成国内的.
# 切换到yum源所在的路径
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls -al
总用量 44
drwxr-xr-x. 2 root root 187 11月 5 2018 .
drwxr-xr-x. 74 root root 8192 8月 7 18:42 ..
-rw-r--r--. 1 root root 1664 11月 23 2018 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 11月 23 2018 CentOS-CR.repo
-rw-r--r--. 1 root root 649 11月 23 2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 11月 23 2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 11月 23 2018 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 11月 23 2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 5701 11月 23 2018 CentOS-Vault.repo
[root@localhost yum.repos.d]#
CentOS-Base.repo
就是默认的YUM源我们需要把这个源替换掉.为了保证可以有后悔药吃,先把原本的源备份
# 新下载wget CentOS7 没有自带wget 我们需要先安装.
# yum install 文件
[root@localhost yum.repos.d]# yum install wget
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirror.bit.edu.cn
* updates: mirrors.163.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 wget.x86_64.0.1.14-18.el7_6.1 将被 安装
--> 解决依赖关系完成
依赖关系解决
================================================================================
Package 架构 版本 源 大小
================================================================================
正在安装:
wget x86_64 1.14-18.el7_6.1 updates 547 k
事务概要
================================================================================
安装 1 软件包
总下载量:547 k
安装大小:2.0 M
Is this ok [y/d/N]: y
Downloading packages:
警告:/var/cache/yum/x86_64/7/updates/packages/wget-1.14-18.el7_6.1.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
wget-1.14-18.el7_6.1.x86_64.rpm 的公钥尚未安装
wget-1.14-18.el7_6.1.x86_64.rpm | 547 kB 00:00
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:
用户ID : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
指纹 : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
软件包 : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)
来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : wget-1.14-18.el7_6.1.x86_64 1/1
验证中 : wget-1.14-18.el7_6.1.x86_64 1/1
已安装:
wget.x86_64 0:1.14-18.el7_6.1
完毕!
# mv 原文件 新文件 mv 是move的意思用于移动或重命名文件.
# 把CentOS-Base.repo文件重命名成CentOS-Base.repo.bak
# 如果想拷贝备份 使用cp指令. cp 是copy的意思. 复制.
[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak
# 重新查看文件.可以看到原本的CentOS-Base.repo文件变成了CentOS-Base.repo.bak
[root@localhost yum.repos.d]# ls -al
总用量 44
drwxr-xr-x. 2 root root 191 8月 7 19:41 .
drwxr-xr-x. 74 root root 8192 8月 7 18:42 ..
-rw-r--r--. 1 root root 1664 11月 23 2018 CentOS-Base.repo.bak
-rw-r--r--. 1 root root 1309 11月 23 2018 CentOS-CR.repo
-rw-r--r--. 1 root root 649 11月 23 2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 11月 23 2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 11月 23 2018 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 11月 23 2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 5701 11月 23 2018 CentOS-Vault.repo
[root@localhost yum.repos.d]#
# 使用wget下载网易163的yum源
# wget 下载地址 在本地保存的文件名
# wget 是Linux 的下载指令.用于下载文件 wget 要下载的文件URL 保存路径.如果不写默认当前
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo CentOS7-BASE-163.repo
--2019-08-07 19:45:55-- http://mirrors.163.com/.help/CentOS7-Base-163.repo
正在解析主机 mirrors.163.com (mirrors.163.com)... 59.111.0.251
正在连接 mirrors.163.com (mirrors.163.com)|59.111.0.251|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1572 (1.5K) [application/octet-stream]
正在保存至: “CentOS7-Base-163.repo”
100%[======================================>] 1,572 --.-K/s 用时 0s
2019-08-07 19:45:55 (79.2 MB/s) - 已保存 “CentOS7-Base-163.repo” [1572/1572])
--2019-08-07 19:45:55-- http://centos7-base-163.repo/
正在解析主机 centos7-base-163.repo (centos7-base-163.repo)... 失败:未知的名称或服务。
wget: 无法解析主机地址 “centos7-base-163.repo”
FINISHED --2019-08-07 19:45:55--
Total wall clock time: 0.2s
Downloaded: 1 files, 1.5K in 0s (79.2 MB/s)
# 需要清除原本的yum源缓存
[root@localhost yum.repos.d]# yum clean all
已加载插件:fastestmirror
正在清理软件源: base extras updates
Cleaning up list of fastest mirrors
# 重新生成新的yum源缓存
[root@localhost yum.repos.d]# yum makecache
已加载插件:fastestmirror
Determining fastest mirrors
base | 3.6 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
(1/12): base/7/x86_64/group_gz | 166 kB 00:00
(2/12): base/7/x86_64/primary_db | 6.0 MB 00:03
(3/12): extras/7/x86_64/prestodelta | 73 kB 00:00
(4/12): extras/7/x86_64/filelists_db | 249 kB 00:00
(5/12): extras/7/x86_64/primary_db | 215 kB 00:00
(6/12): extras/7/x86_64/other_db | 131 kB 00:00
(7/12): updates/7/x86_64/prestodelta | 945 kB 00:00
(8/12): base/7/x86_64/other_db | 2.6 MB 00:01
(9/12): base/7/x86_64/filelists_db | 7.1 MB 00:05
(10/12): updates/7/x86_64/filelists_db | 5.2 MB 00:02
(11/12): updates/7/x86_64/other_db | 764 kB 00:00
(12/12): updates/7/x86_64/primary_db | 7.4 MB 00:02
元数据缓存已建立
# 下载ifconfig指令测试
# 搜索那个文件中含有ifconfig指令
[root@localhost yum.repos.d]# yum search ifconfig
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
================================ 匹配:ifconfig ================================
net-tools.x86_64 : Basic networking tools
# net-tools.x86_64含有ifconfif指令.如果我们想用这个指令就需要安装net-tools文件
# 使用yum install 文件来安装. 注意文件名不要错
[root@localhost yum.repos.d]# yum install net-tools.x86_64
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 net-tools.x86_64.0.2.0-0.24.20131004git.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
================================================================================
Package 架构 版本 源 大小
================================================================================
正在安装:
net-tools x86_64 2.0-0.24.20131004git.el7 base 306 k
事务概要
================================================================================
安装 1 软件包
总下载量:306 k
安装大小:918 k
Is this ok [y/d/N]: y
Downloading packages:
net-tools-2.0-0.24.20131004git.el7.x86_64.rpm | 306 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : net-tools-2.0-0.24.20131004git.el7.x86_64 1/1
验证中 : net-tools-2.0-0.24.20131004git.el7.x86_64 1/1
已安装:
net-tools.x86_64 0:2.0-0.24.20131004git.el7
完毕!
# 使用指令ifconfig来查看网路信息
[root@localhost yum.repos.d]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.186.128 netmask 255.255.255.0 broadcast 192.168.186.255
inet6 fe80::ae7:872b:a10a:e743 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:8c:eb:2c txqueuelen 1000 (Ethernet)
RX packets 38201 bytes 49719006 (47.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 13159 bytes 892823 (871.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 8 bytes 632 (632.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8 bytes 632 (632.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
下面使用wget
指令来下载文件.下载网易163的源.(国内目前比较好的源有163.阿里.清华.中科大)