[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 1 29.3G 0 disk
└─sda1 8:1 1 29.3G 0 part
sr0 11:0 1 8.8G 0 rom /mnt
nvme0n1 259:0 0 20G 0 disk
├─nvme0n1p1 259:1 0 1G 0 part /boot
└─nvme0n1p2 259:2 0 19G 0 part
├─centos-root 253:0 0 17G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
[root@localhost ~]# mount /dev/sda1 /usb
[root@localhost ~]# cd /usb
[root@localhost usb]# ls -l
总用量 6611216
drwxr-xr-x. 2 root root 16384 3月 22 06:26 ??
drwxr-xr-x. 2 root root 16384 7月 3 20:44 ?????
drwxr-xr-x. 3 root root 16384 3月 10 01:43 ??????
drwxr-xr-x. 2 root root 16384 8月 28 2023 ??1.????
-rwxr-xr-x. 1 root root 1328863 12月 24 2023 ???+2021531236 MySQL????.docx
-rwxr-xr-x. 1 root root 939302 10月 23 2023 ????_20231022202213.jpg
-rwxr-xr-x. 1 root root 5296705 12月 11 2021 21?????2????2021531236.zip
drwxr-xr-x. 10 root root 16384 4月 8 2022 c??
drwxr-xr-x. 2 root root 16384 5月 30 2023 Debug
-rwxr-xr-x. 1 root root 1985698 12月 19 2023 ???????.docx
-rwxr-xr-x. 1 root root 1985698 12月 19 2023 ???????.docx
-rwxr-xr-x. 1 root root 63516 12月 20 2023 ????.docx
drwxr-xr-x. 2 root root 16384 6月 11 2023 ????Java
-rwxr-xr-x. 1 root root 1365740 6月 3 2023 jd-gui-windows-1.6.6.zip
drwxr-xr-x. 3 root root 16384 12月 25 2023 KingsoftData
-rwxr-xr-x. 1 root root 1 5月 24 17:54 ~$??.pptx
-rwxr-xr-x. 1 root root 27211305 7月 10 17:43 Python-3.12.4.tgz
-rwxr-xr-x. 1 root root 177152000 5月 22 2018 RHEL7-extras.iso
-rwxr-xr-x. 1 root root 3183450112 5月 22 2018 RHEL7OSP-10.iso
drwxr-xr-x. 2 root root 16384 3月 12 17:59 System Volume Information
-rwxr-xr-x. 1 root root 3368839168 5月 21 09:12 windows_server_2008_r2.iso
练习2.在vmware配置光盘iso⽂件,在linux系统中读取光盘⽂件
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 8.8G 0 rom /mnt
nvme0n1 259:0 0 20G 0 disk
├─nvme0n1p1 259:1 0 1G 0 part /boot
└─nvme0n1p2 259:2 0 19G 0 part
├─centos-root 253:0 0 17G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
[root@localhost ~]# ls /mnt
CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7
EFI images Packages RPM-GPG-KEY-CentOS-Testing-7
EULA isolinux repodata TRANS.TBL
练习3.配置阿⾥云yum仓库
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
--2024-07-16 16:54:34-- https://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 113.137.56.219, 113.137.56.223, 113.137.56.224, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|113.137.56.219|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”
100%[=====================================>] 2,523 --.-K/s 用时 0.03s
2024-07-16 16:54:34 (98.3 KB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523])
[root@localhost ~]# ls /etc/yum.repos.d/
CentOS-Base.repo CentOS-Base.repo.bak hh.repo nginx.repo soft.repo
[root@localhost ~]# yum clean
已加载插件:fastestmirror
错误:清理命令需要参数:headers, packages, metadata, dbcache, plugins, expire-cache, rpmdb, all
[root@localhost ~]# yum clean all
已加载插件:fastestmirror
正在清理软件源: a base extras nginx-stable soft 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
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
a | 3.6 kB 00:00
base | 3.6 kB 00:00
extras | 2.9 kB 00:00
nginx-stable | 2.9 kB 00:00
soft | 2.9 kB 00:00
updates | 2.9 kB 00:00
(1/20): a/group_gz | 166 kB 00:00
(2/20): a/primary_db | 5.9 MB 00:00
(3/20): a/filelists_db | 6.9 MB 00:00
(4/20): a/other_db | 2.5 MB 00:00
(5/20): base/7/x86_64/group_gz | 153 kB 00:00
(6/20): base/7/x86_64/primary_db | 6.1 MB 00:24
(7/20): extras/7/x86_64/primary_db | 253 kB 00:01
(8/20): base/7/x86_64/filelists_db | 7.2 MB 00:26
(9/20): extras/7/x86_64/filelists_db | 305 kB 00:01
(10/20): extras/7/x86_64/other_db | 154 kB 00:00
(11/20): nginx-stable/7/x86_64/filelists_db | 121 kB 00:00
(12/20): soft/filelists_db | 6.3 kB 00:00
(13/20): soft/other_db | 9.8 kB 00:00
(14/20): soft/primary_db | 33 kB 00:00
(15/20): nginx-stable/7/x86_64/other_db | 59 kB 00:00
(16/20): nginx-stable/7/x86_64/primary_db | 97 kB 00:01
(17/20): base/7/x86_64/other_db | 2.6 MB 00:11
(18/20): updates/7/x86_64/filelists_db | 15 MB 00:56
(19/20): updates/7/x86_64/other_db | 1.6 MB 00:06
(20/20): updates/7/x86_64/primary_db | 27 MB 02:01
元数据缓存已建立
练习4.配置清华镜像仓库
[root@aa ~]# wget -O https://mirrors.tuna.tsinghua.edu.cn/centos/7/readme
https://mirrors.aliyun.com/repo/Centos-7.repo
--2024-07-16 16:54:34-- https://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 113.137.56.219, 113.137.56.223, 113.137.56.224, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|113.137.56.219|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”
100%[=====================================>] 2,523 --.-K/s 用时 0.03s
2024-07-16 16:54:34 (98.3 KB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523])[root@localhost ~]# ls /etc/yum.repos.d/
CentOS-Base.repo CentOS-Base.repo.bak hh.repo nginx.repo soft.repo
[root@aa ~]# yum clean all
[root@aa ~]# yum makecache
练习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:10:54-- http://mirrors.cloud.tencent.com/repo/centos7_base.repo
正在解析主机 mirrors.cloud.tencent.com (mirrors.cloud.tencent.com)... 150.138.251.98, 150.138.251.99, 240e:946:3009:1:8000:0:b00:98, ...
正在连接 mirrors.cloud.tencent.com (mirrors.cloud.tencent.com)|150.138.251.98|:80... 已连接。
已发出 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:10:54 (389 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [1694/1694])
[root@localhost ~]# yum clean all
已加载插件:fastestmirror
正在清理软件源: a extras nginx-stable os soft 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
a | 3.6 kB 00:00
extras | 2.9 kB 00:00
nginx-stable | 2.9 kB 00:00
os | 3.6 kB 00:00
soft | 2.9 kB 00:00
updates | 2.9 kB 00:00
(1/20): a/group_gz | 166 kB 00:00
(2/20): a/primary_db | 5.9 MB 00:00
(3/20): a/other_db | 2.5 MB 00:00
(4/20): a/filelists_db | 6.9 MB 00:00
(5/20): extras/7/x86_64/primary_db | 253 kB 00:00
(6/20): extras/7/x86_64/filelists_db | 305 kB 00:00
(7/20): extras/7/x86_64/other_db | 154 kB 00:00
(8/20): nginx-stable/7/x86_64/primary_db | 97 kB 00:01
(9/20): nginx-stable/7/x86_64/filelists_db | 121 kB 00:01
(10/20): nginx-stable/7/x86_64/other_db | 59 kB 00:00
(11/20): os/7/x86_64/group_gz | 153 kB 00:00
(12/20): os/7/x86_64/filelists_db | 7.2 MB 00:01
(13/20): soft/filelists_db | 6.3 kB 00:00
(14/20): soft/other_db | 9.8 kB 00:00
(15/20): soft/primary_db | 33 kB 00:00
(16/20): os/7/x86_64/primary_db | 6.1 MB 00:01
(17/20): os/7/x86_64/other_db | 2.6 MB 00:01
(18/20): updates/7/x86_64/filelists_db | 15 MB 00:07
(19/20): updates/7/x86_64/other_db | 1.6 MB 00:01
(20/20): updates/7/x86_64/primary_db | 27 MB 00:10
元数据缓存已建立
[root@localhost ~]# ls /etc/yum.repos.d/
CentOS-Base.repo CentOS-Base.repo.bak hh.repo nginx.repo soft.repo
练习6.⾃建仓库 包含 tree net-tools bash-completion nginx tree等包
[root@oneday ~]# cp /etc/yum.repos.d/CentOS-Base.repo.tecent /etc/yum.repos.d/CentOS-Base.repo
[root@oneday ~]# yum -y install epel-release
[root@oneday ~]# yum install --downloadonly --downloaddir=./soft/nginx nginx.x86_64
[root@oneday ~]# yum install --downloadonly --downloaddir=./soft/tree tree.x86_64
[root@oneday ~]# yum install --downloadonly --downloaddir=./soft/net-tools net-tools.x86_64
[root@oneday ~]# yum install --downloadonly --downloaddir=./soft/bash-completion bash-completion.noarch
[root@oneday ~]# ls soft/
bash-completion net-tools nginx tree
[root@oneday ~]# ls soft/bash-completion/
bash-completion-2.1-8.el7.noarch.rpm
[root@oneday ~]# ls soft/net-tools/
[root@oneday ~]# ls soft/nginx/
[root@oneday ~]# ls soft/tree/
[root@oneday ~]# yum -y install createrepo
[root@oneday ~]# createrepo soft/
[root@oneday ~]# ls soft/
[root@oneday ~]# vim /etc/yum.repos.d/soft.repo
[root@oneday ~]# rm -rf /etc/yum.repos.d/CentOS-Base.repo
[root@oneday ~]# yum clean all
[root@oneday ~]# yum makecache
[root@oneday ~]# ls /etc/yum.repos.d/
soft.repo
[root@oneday ~]# yum -y install nginx //测试