Linux配置网络和本地yum源
Tags: OSyum源挂载ISO文件本地yum源网络yum源解压
网络yum源
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | # 阿里云 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bk curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo # sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo # 阿里云 epel源 mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.repo_bk yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm sed -i 's|^#baseurl=https://download.fedoraproject.org/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel* sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel* wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-5.repo # 华为云 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bk curl -o /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-8-reg.repo wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-8-reg.repo wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-6-reg.repo wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-5-reg.repo # 华为云epel yum install -y https://repo.huaweicloud.com/repository/epel/epel-release-latest-8.noarch.rpm wget -O /etc/yum.repos.d/epel.repo https://repo.huaweicloud.com/repository/conf/epel-7-reg.repo wget -O /etc/yum.repos.d/epel.repo https://repo.huaweicloud.com/repository/conf/epel-6-reg.repo wget -O /etc/yum.repos.d/epel.repo https://repo.huaweicloud.com/repository/conf/epel-5-reg.repo yum clean all yum makecache fast rpm --rebuilddb rm -rf /var/run/yum.pid yum --disablerepo=epel -y update ca-certificates |
rhel 或 CentOS配置本地yum源
已在CentOS 、Redhat 5.5、6.5和7.8上测试通过。
挂载ISO文件
直接在外部系统挂载iso镜像文件
一般在iso文件挂载后,在OS内部为/dev/sr0
或 /dev/cdrom
或 /dev/hdc
(5.5版本),若没有这几个文件,则可能需要重启OS来挂载光盘:
1 2 3 4 5 | [root@lhrdocker ~]# ll /dev/sr0 brw-rw----+ 1 root cdrom 11, 0 Dec 3 14:37 /dev/sr0 [root@lhrdocker ~]# ll /dev/cdrom lrwxrwxrwx 1 root root 3 Dec 3 14:37 /dev/cdrom -> sr0 [root@lhrdocker ~] |
在OS内部挂载iso文件
在该情况下,可以将iso文件整体上传到OS内部某个文件夹下,然后在OS内部挂载该iso文件。
1 2 3 4 5 6 | -- 直接使用mont命令进行挂载即可解压 mkdir -p /media/lhr/cdrom mount -t iso9660 -o loop CentOS-7-x86_64-Minimal-2009.iso /media/lhr/cdrom/ -- 或者直接mount mount CentOS-7-x86_64-Minimal-2009.iso /media/lhr/cdrom/ |
配置本地yum源
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | mkdir -p /media/lhr/cdrom -- 挂载物理驱动器文件 mount /dev/sr0 /media/lhr/cdrom/ -- 直接挂载iso文件 mount -t iso9660 -o loop CentOS-7-x86_64-Minimal-2009.iso /media/lhr/cdrom/ mount CentOS-7-x86_64-Minimal-2009.iso /media/lhr/cdrom/ -- 配置本地yum源 cd /etc/yum.repos.d/ mv /etc/yum.repos.d/ /etc/yum.repos.d_bk mkdir -p /etc/yum.repos.d/ cat > /etc/yum.repos.d/yum_local.repo <<"EOF" [yum_local] name=yum_local baseurl=file:///media/lhr/cdrom enabled=1 gpgcheck=0 #gpgkey=file:///media/lhr/cdrom/RPM-GPG-KEY-redhat-release EOF #设置开机自动挂载系统镜像文件 vi /etc/fstab 添加以下内容 /dev/sr0 /media/lhr/cdrom iso9660 defaults,ro,loop 0 0 yum clean all yum list | grep systemd yum install -y lrzsz |
结果示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | [root@lhrdocker ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 3.9G 0 3.9G 0% /dev tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 3.9G 13M 3.9G 1% /run tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/mapper/centos_lhrdocker-root 50G 11G 36G 23% / /dev/sda1 976M 142M 768M 16% /boot /dev/mapper/centos_lhrdocker-home 9.8G 41M 9.2G 1% /home /dev/mapper/vg_docker-lv_docker 788G 255G 493G 35% /var/lib/docker tmpfs 797M 12K 797M 1% /run/user/42 tmpfs 797M 0 797M 0% /run/user/0 /dev/sr0 4.5G 4.5G 0 100% /media/lhr/cdrom [root@lhrdocker ~]# [root@lhrdocker ~]# yum list | grep systemd systemd.x86_64 219-78.el7_9.3 @updates systemd-libs.x86_64 219-78.el7_9.3 @updates systemd-python.x86_64 219-78.el7_9.3 @updates systemd-sysv.x86_64 219-73.el7_8.9 @updates systemd-devel.x86_64 219-73.el7.1 yum_local [root@lhrdocker ~]# cd /media/lhr/cdrom/ [root@lhrdocker cdrom]# ll total 694 -rw-rw-r-- 2 root root 14 Apr 21 2020 CentOS_BuildTag drwxr-xr-x 3 root root 2048 Apr 21 2020 EFI -rw-rw-r-- 3 root root 227 Aug 30 2017 EULA -rw-rw-r-- 3 root root 18009 Dec 10 2015 GPL drwxr-xr-x 3 root root 2048 Apr 21 2020 images drwxr-xr-x 2 root root 2048 Apr 21 2020 isolinux drwxr-xr-x 2 root root 2048 Apr 21 2020 LiveOS drwxr-xr-x 2 root root 671744 Apr 22 2020 Packages drwxrwxr-x 2 root root 4096 Apr 22 2020 repodata -rw-rw-r-- 3 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-7 -rw-rw-r-- 3 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-Testing-7 -r--r--r-- 1 root root 2883 Apr 22 2020 TRANS.TBL [root@lhrdocker cdrom]# cd Packages/ [root@lhrdocker Packages]# ll systemd* -rw-rw-r-- 3 root root 5313164 Apr 4 2020 systemd-219-73.el7.1.x86_64.rpm -rw-rw-r-- 2 root root 216360 Apr 4 2020 systemd-devel-219-73.el7.1.x86_64.rpm -rw-rw-r-- 3 root root 424812 Apr 4 2020 systemd-libs-219-73.el7.1.x86_64.rpm -rw-rw-r-- 2 root root 144564 Apr 4 2020 systemd-python-219-73.el7.1.x86_64.rpm -rw-rw-r-- 3 root root 94544 Apr 4 2020 systemd-sysv-219-73.el7.1.x86_64.rpm [root@lhrdocker Packages]# |
rhel 6.5 网络yum源
参考:https://www.xmmup.com/dbbao38centos-6dewangluoyumyuanpeizhizuixindezhi.html
rhel5.5 网络yum源
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | [base] name=CentOS-5 - Base #mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=os #baseurl=http://mirror.centos.org/centos/5/os/$basearch/ baseurl=http://vault.centos.org/5.11/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #released updates [updates] name=CentOS-5 - Updates #mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=updates #baseurl=http://mirror.centos.org/centos/5/updates/$basearch/ baseurl=http://vault.centos.org/5.11/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #additional packages that may be useful [extras] name=CentOS-5 - Extras #mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=extras #baseurl=http://mirror.centos.org/centos/5/extras/$basearch/ baseurl=http://vault.centos.org/5.11/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-5 - Plus #mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=centosplus #baseurl=http://mirror.centos.org/centos/5/centosplus/$basearch/ baseurl=http://vault.centos.org/5.11/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #contrib - packages by Centos Users [contrib] name=CentOS-5 - Contrib #mirrorlist=http://mirrorlist.centos.org/?release=5&arch=$basearch&repo=contrib #baseurl=http://mirror.centos.org/centos/5/contrib/$basearch/ baseurl=http://vault.centos.org/5.11/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 |
使用7zip解压iso文件
p7zip: 包含 7zr(最小的 7zip 归档工具),仅仅只能处理原生的 7z 格式。
p7zip-full: 包含 7z ,支持 7z、LZMA2、XZ、ZIP、CAB、GZIP、BZIP2、ARJ、TAR、CPIO、RPM、ISO 和 DEB 格式。
p7zip-rar: 包含一个能解压 RAR 文件的插件。
p7zip: 包含 7za 命令,支持 7z、ZIP、GZIP、CAB、ARJ、BZIP2、TAR、CPIO、RPM 和 DEB 格式。
p7zip-plugins: 包含 7z 命令,额外的插件,它扩展了 7za 命令(例如支持 ISO 格式的抽取)。
建议安装 p7zip-full 包(不是 p7zip),因为这是最完全的 7zip 程序包,它支持很多归档格式。此外,如果您想处理 RAR 文件话,还需要安装 p7zip-rar 包,做成一个独立的插件包的原因是因为 RAR 是一种专有格式。
安装使用
1 | sudo yum install p7zip p7zip-plugins |
解压iso文件的命令是:
1 | 7z x Windows.iso |
解压到指定目录:
1 | 7z x Windows.iso -o./tmp |
-o 是指定解压到的目录,-o后是没有空格的,直接接目录。这一点需要注意。
查看压缩文件的内容是:
1 | 7z l Windows.iso |