合 Linux配置网络和本地yum源
Tags: OSyum源网络yum源本地yum源挂载ISO文件解压
网络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.dbaup.com/dbbao38centos-6dewangluoyumyuanpeizhizuixindezhi.html