有关Yum源的一些小练习

1.插⼊优盘,读取优盘数据

指令:
[root@web1 ~]# lsblk 
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   50G  0 disk 
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   49G  0 part 
  ├─centos-root 253:0    0 45.1G  0 lvm  /
  └─centos-swap 253:1    0  3.9G  0 lvm  [SWAP]
sdb               8:16   1 29.3G  0 disk 
└─sdb1            8:17   1 29.3G  0 part 
sr0              11:0    1  8.8G  0 rom  /mnt
[root@web1 ~]# mkdir /media/myusb
[root@web1 ~]# mount /dev/sdb1 /media/myusb/
[root@web1 ~]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   46G  7.2G   38G   16% /
devtmpfs                 224M     0  224M    0% /dev
tmpfs                    236M     0  236M    0% /dev/shm
tmpfs                    236M  5.7M  230M    3% /run
tmpfs                    236M     0  236M    0% /sys/fs/cgroup
/dev/sda1               1014M  142M  873M   14% /boot
/dev/sr0                 8.8G  8.8G     0  100% /dvd
tmpfs                     48M     0   48M    0% /run/user/0
/dev/sdb1                 30G   25G  4.9G   84% /media/myusb
结果:
[root@web1 ~]# ls /media/myusb/
??                      7        Audiobooks  kugoumusic           Pictures     ??.pptx
??                      8        DCIM        LOST.DIR             Podcasts     Ringtones
???                     9        Documents   Movies               ??????.pptx  System Volume Information
???                     a        Download    Music                ?????.pptx   ?????Web???????????2023.docx
~$???1.xlsm             Alarms   eNSP        Notifications        ?????.pptx   web????-??????????.doc
?????(3)(1)(1)(1).pptx  Android  java.rtf    ???????????????.pdf  ???.pptx     ~$???.xlsm

2.在vmware配置光盘iso⽂件,在linux系统中读取光盘⽂件

首先打开Vmware,找到虚拟机点击鼠标右键,找到设置,找到CD/DVD点击使用IOS镜像文件镜像文件,选择文件路径点击确定。随后鼠标右键点击Vmware右下角处的光盘单击连接。

f213108f2e074b89b89b3c7d98df277e.jpeg

701d464f10cd4a518b247cd9155f9d31.jpeg

a737e78e6fd944499b1e35067ee1a847.bmp

打开虚拟机把光盘挂载到指定文件下:

[root@localhost ~]# mount -o ro /dev/sr0 /mnt

 查看磁盘挂载情况

[root@localhost ~]# lsblk

sr0              11:0    1  8.8G  0 rom /mnt

[root@localhost ~]# ls /mnt/

09fec8c3a4e449b0a6b4f4e9249518f8.png

方法一:[root@localhost ~]# vim /etc/rc.local

mount -o or /dev/sr0 /mnt

方法二:[root@localhost ~]# echo 'mount -o or /dev/sr0 /mnt' >> /etc/rc.local

4440dc79fe1540059a2303775a61d8f4.png

[root@localhost ~]#  chmod +x /etc/rc.local              添加权限方便开机自动挂载

3.配置阿⾥云yum仓库

搜索阿里镜像源

15fe1789fa2347ecb10b2173eca55529.png

跟据官方提示配置Yum源

6ca541543e41415ca1df495e7e28861b.png

3e787fd691fa48b5ade4961825163b84.png

[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

[root@localhost ~]# yum clean all            清除yum上的缓存
[root@localhost ~]# yum makecache       生成yum缓存

[root@localhost yum.repos.d]# yum repolist all

265a9c7f1ffe4426ae9445abb3d5ae8e.png

centos镜像_centos下载地址_centos安装教程-阿里巴巴开源镜像站

4.配置清华镜像仓库

5.配置腾讯镜像仓库
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo

--2024-07-16 17:06:13--  https://mirrors.cloud.tencent.com/repo/centos7_base.repo
正在解析主机 mirrors.cloud.tencent.com (mirrors.cloud.tencent.com)... 150.138.251.99, 150.138.251.98, 240e:946:3009:1:8000:0:b00:98, ...
正在连接 mirrors.cloud.tencent.com (mirrors.cloud.tencent.com)|150.138.251.99|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1694 (1.7K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”

100%[=======================================================================================>] 1,694       --.-K/s 用时 0s      

2024-07-16 17:06:13 (524 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [1694/1694])

[root@localhost ~]# yum clean all

已加载插件:fastestmirror
正在清理软件源: extras os updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors                 

[root@localhost ~]# yum makecache

已加载插件:fastestmirror
Determining fastest mirrors
extras                                                                                                    | 2.9 kB  00:00:00     
os                                                                                                        | 3.6 kB  00:00:00     
updates                                                                                                   | 2.9 kB  00:00:00     
(1/10): extras/7/x86_64/primary_db                                                                        | 253 kB  00:00:00     
(2/10): extras/7/x86_64/filelists_db                                                                      | 305 kB  00:00:00     
(3/10): extras/7/x86_64/other_db                                                                          | 154 kB  00:00:00     
(4/10): os/7/x86_64/group_gz                                                                              | 153 kB  00:00:00     
(5/10): os/7/x86_64/filelists_db                                                                          | 7.2 MB  00:00:01     
(6/10): os/7/x86_64/other_db                                                                              | 2.6 MB  00:00:00     
(7/10): os/7/x86_64/primary_db                                                                            | 6.1 MB  00:00:01     
(8/10): updates/7/x86_64/filelists_db                                                                     |  15 MB  00:00:06     
(9/10): updates/7/x86_64/other_db                                                                         | 1.6 MB  00:00:00     
(10/10): updates/7/x86_64/primary_db                                                                      |  27 MB  00:00:07     
元数据缓存已建立

6.⾃建仓库 包含 tree net-tools bash-completion nginx tree等包

不能用本地yum下载,这里我用的是阿里云

[root@tdr ~]# yum -y remove tree                                                 

删除:
  tree.x86_64 0:1.6.0-10.el7                                                                

完毕!
[root@tdr ~]# yum -y remove net-tools                              

删除:
  net-tools.x86_64 0:2.0-0.22.20131004git.el7                                               

作为依赖被删除:
  mysql-community-server.x86_64 0:9.0.0-1.el7                                               

完毕!
[root@tdr ~]# yum -y remove bash-completion                             

删除:
  bash-completion.noarch 1:2.1-6.el7                                                        

完毕!

[root@tdr ~]# yum install --downloadonly --downloaddir=./soft tree
[root@tdr ~]# yum install --downloadonly --downloaddir=./soft net-tools
[root@tdr ~]# yum install --downloadonly --downloaddir=./soft bash-completion

[root@localhost ~]# createrepo soft/                  这一步在紫色部分后面是必须要在输出一次的

[root@localhost ~]# cd soft/
[root@localhost soft]# ls

[root@localhost soft]# rm -rf /etc/yum.repos.d/*.repo         
[root@localhost soft]# vim /etc/yum.repos.d/soft.repo

[soft]
name=soft_local
gpgcheck=0
baseurl=file:///root/soft
enable=1
[root@localhost soft]# yum clean all
[root@localhost soft]# yum makecache 

已加载插件:fastestmirror
Determining fastest mirrors
soft                                                                | 2.9 kB  00:00:00     
(1/3): soft/filelists_db                                            | 6.6 kB  00:00:00     
(2/3): soft/other_db                                                |  10 kB  00:00:00     
(3/3): soft/primary_db                                              |  33 kB  00:00:00     
元数据缓存已建立

[root@tdr ~]# yum -y install tree
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 tree.x86_64.0.1.6.0-10.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

===========================================================================================
 Package           架构                版本                        源                 大小
===========================================================================================
正在安装:
 tree              x86_64              1.6.0-10.el7                soft               46 k

事务概要
===========================================================================================
安装  1 软件包

总下载量:46 k
安装大小:87 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : tree-1.6.0-10.el7.x86_64                                               1/1 
  验证中      : tree-1.6.0-10.el7.x86_64                                               1/1 

已安装:
  tree.x86_64 0:1.6.0-10.el7                                                               

完毕!

[root@tdr ~]# yum -y install bash-completion.noarch 
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 bash-completion.noarch.1.2.1-8.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

===========================================================================================
 Package                    架构              版本                   源               大小
===========================================================================================
正在安装:
 bash-completion            noarch            1:2.1-8.el7            soft             87 k

事务概要
===========================================================================================
安装  1 软件包

总下载量:87 k
安装大小:263 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : 1:bash-completion-2.1-8.el7.noarch                                     1/1 
  验证中      : 1:bash-completion-2.1-8.el7.noarch                                     1/1 

已安装:
  bash-completion.noarch 1:2.1-8.el7                                                       

完毕!
[root@tdr ~]# yum -y install net-tools.x86_64 
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 net-tools.x86_64.0.2.0-0.25.20131004git.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

===========================================================================================
 Package            架构            版本                               源             大小
===========================================================================================
正在安装:
 net-tools          x86_64          2.0-0.25.20131004git.el7           soft          306 k

事务概要
===========================================================================================
安装  1 软件包

总下载量:306 k
安装大小:917 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : net-tools-2.0-0.25.20131004git.el7.x86_64                              1/1 
  验证中      : net-tools-2.0-0.25.20131004git.el7.x86_64                              1/1 

已安装:
  net-tools.x86_64 0:2.0-0.25.20131004git.el7                                              

完毕!

 

  • 27
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值