1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > Linux 挂载光盘镜像配置本地 yum 源安装软件

Linux 挂载光盘镜像配置本地 yum 源安装软件

时间:2019-12-21 11:14:00

相关推荐

Linux 挂载光盘镜像配置本地 yum 源安装软件

Yum(全称为 Yellowdog Updater, Modified)是一个在 Fedora 和 RedHat 以及 CentOS 中的 Shell 前端软件包管理器。CentOS 和 Redhat 版本的 Linux 一般安装软件包选择 rpm 和 yum 安装方式,这也是比较常见的方式。不过 rpm 安装时如果有其他依赖的包则需要先安装依赖包,比较麻烦, yum 则可以解决依赖关系,也可同时安装多个 rpm 包。当然 deb 软件包安装以及源码方式安装也有使用。deb 软件包一般以 .deb 后缀结尾,dpkg -i 包名即可安装。源码方式的包一般都以.tar.gz 或者 .tar.bz2 结尾,下载后校检md5值,解压后经过配置(./configure)、编译(make)、安装(make install)便可以完成。

一般传统行业的公司的生产环境均是内网环境,是没有办法上网的,故网络 yum 源就不用考虑了,大公司基本上会使用局域网内的 FTP 服务器,配置 ftp 方式的 yum 源,通过局域网安装软件,也可挂载光盘镜像。个人学习使用或小公司基本上会配置本地 yum 源,以后有时间可以说说网络 yum 源,下面就先说说配置本地 yum 源以及安装软件的方式。

本次演示使用Oracle VM VirtualBox下的Redhat6.4以及VMware Workstation Pro下的CentOS 7.6以及简略说明 linuxone下的 suse12sp4环境

Redhat6.4 下配置 yum 源

一、插入光盘镜像

图形化界面上能够看到新增光盘图标,默认自动弹出窗口显示光盘中文件

二、 查看光盘对应路径

切换到光盘目录,使用 Tab 补齐的方法进入,便可以看到很多软件包,但由于默认路径有空格,不方便配置 yum 源,故需要重新挂载光盘。

[root@JiekeXu ~]# cd /media/RHEL_6.4\ x86_64\ Disc\ 1/[root@JiekeXu RHEL_6.4 x86_64 Disc 1]# ls

三、创建目录

光盘加载到光驱后默认挂载点(访问入口)为 /media/RHEL_6.4 x86_64 Disc 1 路径中包含空格,不方便使用。

创建目录 作为新挂载点 (访问光盘的入口)

[root@JiekeXu ~]# mkdir /mnt/dvd[root@JiekeXu ~]# ls -ld /mnt/dvd

四、重新挂载

df -Th 查看光盘对应设备名称 /dev/sr0

挂载光盘到新建的挂载点

[root@JiekeXu ~]# mount /dev/sr0 /mnt/dvd[root@JiekeXu ~]# df -Th

使用新挂载点即可访问光盘中文件

[root@JiekeXu ~]#ls /mnt/dvd

/mnt/dvd/Server 是配置 yum 仓库要用到的路径

五、修改配置文件配置 yum源

[root@JiekeXu ~]# cd /etc/yum.repos.d/[root@JiekeXu yum.repos.d]# lltotal 16K-r--r--r-- 1 root root 114 Jul 2 packagekit-media.repo-rw-r--r--. 1 root root 358 Oct 19 redhat.repo-rw-r--r-- 1 root root 656 Oct 20 rhel64.repo-rw-r--r--. 1 root root 529 Jun 12 rhel-source.repo[root@JiekeXu yum.repos.d]#

配置文件目录 /etc/yum.repos.d/

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release表示公钥文件地址

编辑配置文件,在最后追加写入内容 baseurl 中 file:// 表示本地文件,第三个 / 表示 根目录

[root@JiekeXu yum.repos.d]# cp rhel-source.repo rhel-source.repo.bak[root@JiekeXu yum.repos.d]# vi rhel-source.repo[rhel64]name=rhel64 repobaseurl=file:///mnt/dvd/Servergpgcheck=0[root@JiekeXu yum.repos.d]# tail -5 rhel-source.repo

六、yum基本操作

清除缓存

[root@JiekeXu yum.repos.d]# yum clean all Loaded plugins: product-id, refresh-packagekit, security, subscription-managerThis system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.Repository rhel-source is listed more than once in the configurationRepository rhel-source-beta is listed more than once in the configurationCleaning repos: InstallMedia rhel67 rhel67rpmCleaning up Everything

列出软件包

[root@JiekeXu yum.repos.d]# yum listLoaded plugins: product-id, refresh-packagekit, security, subscription-managerThis system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.[root@JiekeXu yum.repos.d]# yum list | grep zshRepository rhel-source is listed more than once in the configurationRepository rhel-source-beta is listed more than once in the configurationzsh.x86_64 4.3.11-4.el6@rhel64

yum安装、查看、删除软件包

[root@JiekeXu yum.repos.d]# yum install zsh[root@JiekeXu yum.repos.d]# yum info zsh[root@JiekeXu yum.repos.d]# yum remove zsh

七、 yum install XXX 安装其他的包

本地镜像源内的 rpm 包便可以自由安装了,使用 -y 则不用提示直接安装。

[root@JiekeXu yum.repos.d]# yum install vim* -y[root@JiekeXu yum.repos.d]# yum install x11*Loaded plugins: product-id, refresh-packagekit, security, subscription-managerThis system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.Repository rhel-source is listed more than once in the configurationRepository rhel-source-beta is listed more than once in the configurationSetting up Install ProcessResolving Dependencies--> Running transaction check---> Package xorg-x11-apps.x86_64 0:7.7-6.el6 will be installed--> Finished Dependency Resolution

CentOS 7.6下配置 yum源

CentOS 系列的 Linux 操作系统目前市场上使用的还是比较多的,而且很多公司也都陆陆续续使用 7 系列版本,那么本次将使用 CentOS 7.6 作为演示版本。

一、关闭防火墙

临时关闭防火墙

systemctl stop firewalld

永久防火墙开机自关闭

systemctl disable firewalld

临时打开防火墙

systemctl start firewalld

防火墙开机启动

systemctl enable firewalld

查看防火墙状态

systemctl status firewalld

[root@JiekeXu ~]# systemctl status firewalld● firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)Active: active (running) since 六 -09-07 08:33:48 CST; 18h agoDocs: man:firewalld(1)Main PID: 8220 (firewalld)Tasks: 2CGroup: /system.slice/firewalld.service└─8220 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid9月 07 08:33:40 JiekeXu systemd[1]: Starting firewalld - dynamic firewall daemon...9月 07 08:33:48 JiekeXu systemd[1]: Started firewalld - dynamic firewall daemon.9月 07 08:33:55 JiekeXu firewalld[8220]: WARNING: /etc/sysconfig/network-scripts/ifcfg-ens32: Duplicate option definition: 'BOO...tatic"'Hint: Some lines were ellipsized, use -l to show in full.[root@JiekeXu ~]#[root@JiekeXu ~]# systemctl stop firewalld[root@JiekeXu ~]# systemctl status firewalld● firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)Active: inactive (dead) since 日 -09-08 03:19:50 CST; 3s agoDocs: man:firewalld(1)Process: 8220 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)Main PID: 8220 (code=exited, status=0/SUCCESS)9月 07 08:33:40 JiekeXu systemd[1]: Starting firewalld - dynamic firewall daemon...9月 07 08:33:48 JiekeXu systemd[1]: Started firewalld - dynamic firewall daemon.9月 07 08:33:55 JiekeXu firewalld[8220]: WARNING: /etc/sysconfig/network-scripts/ifcfg-ens32: Duplicate option definition: 'BOO...tatic"'9月 08 03:19:46 JiekeXu systemd[1]: Stopping firewalld - dynamic firewall daemon...9月 08 03:19:50 JiekeXu systemd[1]: Stopped firewalld - dynamic firewall daemon.Hint: Some lines were ellipsized, use -l to show in full.[root@JiekeXu ~]#[root@JiekeXu ~]# systemctl disable firewalldRemoved symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.[root@JiekeXu ~]#[root@JiekeXu ~]# systemctl status firewalld● firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)Active: inactive (dead)Docs: man:firewalld(1)9月 07 08:33:40 JiekeXu systemd[1]: Starting firewalld - dynamic firewall daemon...9月 07 08:33:48 JiekeXu systemd[1]: Started firewalld - dynamic firewall daemon.9月 07 08:33:55 JiekeXu firewalld[8220]: WARNING: /etc/sysconfig/network-scripts/ifcfg-ens32: Duplicate option definition: 'BOO...tatic"'9月 08 03:19:46 JiekeXu systemd[1]: Stopping firewalld - dynamic firewall daemon...9月 08 03:19:50 JiekeXu systemd[1]: Stopped firewalld - dynamic firewall daemon.Hint: Some lines were ellipsized, use -l to show in full.

二、关闭SELINUX

编辑/etc/selinux/config 文件,将其设置为 disabled,注意编辑/etc/sysconfig/selinux 文件也可。

[root@JiekeXu sysconfig]# pwd/etc/sysconfig[root@JiekeXu sysconfig]# ls -l selinuxlrwxrwxrwx. 1 root root 17 7月 4 02:03 selinux -> ../selinux/config[root@JiekeXu ~]# cat /etc/sysconfig/selinux[root@JiekeXu ~]# more /etc/selinux/config# This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:#enforcing - SELinux security policy is enforced.#permissive - SELinux prints warnings instead of enforcing.#disabled - No SELinux policy is loaded.SELINUX=disabled# SELINUXTYPE= can take one of three values:#targeted - Targeted processes are protected,#minimum - Modification of targeted policy. Only selected processes are protected.#mls - Multi Level Security protection.SELINUXTYPE=targeted

四、设置域名解析

[root@JiekeXu ~]# vi /etc/resolv.conf# Generated by NetworkManagernameserver 192.168.32.1nameserver 192.168.32.0nameserver 8.8.8.8nameserver 114.114.114.114

五、挂载镜像

首先插入光盘镜像

六、建立目录,挂载镜像,将其写入开机自启动文件

mkdir /mnt/centosmount -t iso9660 -o loop /dev/sr0 /mnt/centosvim /etc/fstab

添加如下一行

/dev/cdrom /mnt/contos iso9660 defaults 0 0 0 0[root@JiekeXusysconfig]#cat/etc/fstab# /etc/fstab# Created by anaconda on Thu Jul 4 01:57:56 ## Accessible filesystems, by reference, are maintained under '/dev/disk'# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info#/dev/mapper/centos-root / xfsdefaults 0 0UUID=d40ff30e-48ce-4286-8e3f-bc9e30f3a6bb /boot xfsdefaults 0 0/dev/mapper/centos-swap swapswap defaults,size=1024M 0 0/dev/cdrom /mnt/centosiso9660 defaults 0 00 0

七、配置 yum源

进入/etc/yum.repos.d 目录修改CentOS-Media.repo文件

mv CentOS-Base.repo CentOS-Base.repo_bakvi CentOS-Media.repo[local] //id:local 表示本地name=CentOS-$releasever - localbaseurl=file:///mnt/centos //挂载镜像的文件夹路径gpgcheck=0 //设置此源是否检验文件,1为校验,0为不校验enabled=1 //启用该yum源gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7//公钥文件地址

注意:如果没有注释掉 CentOS-Base.repo 则会出现如下未知错误。

[root@JiekeXu yum.repos.d]# yum clean all;已加载插件:fastestmirror, langpacks正在清理软件源:base extras local updatesCleaning up list of fastest mirrors[root@JiekeXu yum.repos.d]# yum repolist已加载插件:fastestmirror, langpacksDetermining fastest mirrorsCould not retrieve mirrorlist /?release=7&arch=x86_64&repo=os&infra=stock error was14: curl#6 - "Could not resolve host: ; 未知的错误"Loading mirror speeds from cached hostfileLoading mirror speeds from cached hostfileLoading mirror speeds from cached hostfileLoading mirror speeds from cached hostfile源标识源名称 状态base/7/x86_64 CentOS-7 - Base 0extras/7/x86_64 CentOS-7 - Extras 0local CentOS-7 - local 0updates/7/x86_64CentOS-7 - Updates0repolist: 0

八、简单应用

清空缓存 yum clean all查看可用 yum 源 yum repolist[root@JiekeXu yum.repos.d]# yum clean all;已加载插件:fastestmirror, langpacks正在清理软件源:localCleaning up list of fastest mirrors[root@JiekeXu yum.repos.d]# yum repolist已加载插件:fastestmirror, langpacksDetermining fastest mirrorslocal| 3.6 kB 00:00:00(1/2): local/group_gz | 166 kB 00:00:00(2/2): local/primary_db | 3.1 MB 00:00:00源标识源名称状态localCentOS-7 - local4,021repolist: 4,021

SUSE 12sp4 环境下 zypper源配置

1. zypper 的几个重要选项:

2. zypper 软件管理:

3. zypper 的查询选项:

下面实操说明配置 zypper 源

JiekeXu2:~ # zypper cleanAll repositories have been cleaned up.JiekeXu2:~ # zypper clean allRepository 'all' not found by its alias, number, or URI.Use 'zypper repos' to get the list of defined repositories.Could not clean the repositories because of errors.JiekeXu2:~ # cat /etc/issueWelcome to SUSE Linux Enterprise Server 12 SP4 (s390x) - Kernel \r (\l).JiekeXu2:~ # zypper rr 1Removing repository 'SLES12-SP4 12.4-0' ......................................................................[done]Repository 'SLES12-SP4 12.4-0' has been removed.JiekeXu2:~ # zypper rr 1Repository '1' not found by alias, number or URI.JiekeXu2:~ # zypper rr 1Repository '1' not found by alias, number or URI.JiekeXu2:~ # zypper ar ftp://ftp@10.18.127.222/suse/suse12sp4s390x suseAdding repository 'suse' .....................................................................................[done]Repository 'suse' successfully addedURI : ftp://ftp@10.18.127.222/suse/suse12sp4s390xEnabled: Yes GPG Check : Yes Autorefresh : No Priority : 99 (default priority) Repository priorities are without effect. All enabled repositories share the same priority.JiekeXu2:~ # zypper lrRepository priorities are without effect. All enabled repositories share the same priority.# | Alias | Name | Enabled | GPG Check | Refresh--+-------+------+---------+-----------+--------1 | suse | suse | Yes| ( p) Yes | NoJiekeXu2:~ # zypper refRetrieving repository 'suse' metadata ---------------------------------------------------------------------------[\]Authentication required for 'ftp://ftp@10.18.127.222/suse/suse12sp4s390x'User Name: ftpuserPassword:Retrieving repository 'suse' metadata ........................................................................[done]Building repository 'suse' cache .............................................................................[done]All repositories have been refreshed.JiekeXu2:~ # zypper -n in libaio-develLoading repository data...Reading installed packages...Resolving package dependencies...The following NEW package is going to be installed:libaio-devel1 new package to install.Overall download size: 6.5 KiB. Already cached: 0 B. After the operation, additional 9.1 KiB will be used.m | 9.43-8.1 | s390x | s390 | SLES12-SP4 12.4-0 | hfsutils| 3.2.6-1240.71 | s390x | SLES12-SP4 12.4-0 | gnome-session-lang| 3.20.2-19.2 | noari | SLES12-SP4 12.4-0 | hicolor-icon-theme| 0.15-4.1 | noarch | SLES12-SP4 12.4-0 | gnome-settings-daemon | 3.20.1-50.5.8 | s390 | SLES12-SP4 12.4-0 | hmaccalc| 0.9.13-2.3| s390x | SLES12-SP4 12.4-0 | gnome-settings-daemon-lang | 3.20.1-50.5.8 | noar | SLES12-SP4 12.4-0 | hostinfo| 1.0-17.12 | noarch | SLES12-SP4 12.4-0 | gnome-shell | 3.20.4-77.17.1| s390 | SLES12-SP4 12.4-0 | hplip | 3.16.11-1.33 | s390x | SLES12-SP4 12.4-0 | gnome-shell-browser-plugin | 3.20.4-77.17.1| s390 | SLES12-SP4 12.4-0 | hplip-hpijs | 3.16.11-1.33 | s390x | SLES12-SP4 12.4-0 | gnome-shell-classic | 3.20.1-24.27.44| noar | SLES12-SP4 12.4-0 | hplip-sane | 3.16.11-1.33 | s390x | SLES12-SP4 12.4-0 | gnome-shell-extensions-common | 3.20.1-24.27.44| noari | SLES12-SP4 12.4-0 | hunspell| 1.3.2-18.1| s390x | SLES12-SP4 12.4-0 | gnome-shell-extensions-common-lang | 3.20.1-24.27.44| noar | SLES12-SP4 12.4-0 | hunspell-32bit | 1.3.2-18.1| s390x | SLES12-SP4 12.4-0 | gnome-shell-lang | 3.20.4-77.17.1| noari | SLES12-SP4 12.4-0 | hunspell-tools | 1.3.2-18.1| s390x | SLES12-SP4 12.4-0 | gnome-shell-search-provider-gnome-terminal | 3.20.2-8.62 | s390Continue? [y/n/...? shows all options] (y): yRetrieving package libaio-devel-0.3.109-17.15.s390x (1/1), 6.5 KiB ( 9.1 KiB unpacked)Retrieving: libaio-devel-0.3.109-17.15.s390x.rpm .............................................................[done]Checking for file conflicts: .................................................................................[done](1/1)Installing:libaio-devel-0.3.109-17.15.s390x...........................................................[done]

当然,局域网也有不通的时候,那么我们只要挂载光盘镜像或者上传镜像到系统某个目录下,如下 5 步也很方便配置 zypper 源,还等什么,赶快来试试吧。

1、首先建立挂载目录

mkdir /mnt/iso

2、上传光盘镜像到 /app目录,并挂载镜像

mount -t iso9660 /app/SLES-11-SP4-DVD-x86_64-GM-DVD1.iso /mnt/iso

3、添加库,配置本地 repo

zypper ar file:///mnt/iso ss

4、查看列出本地库

zypper lr

JiekeXu2:/app/oracle # zypper lrRepository priorities are without effect. All enabled repositories share the same priority.# | Alias| Name| Enabled | GPG Check | Refresh--+-----------+-----------+---------+-----------+--------1 | suse12sp4 | suse12sp4 | Yes| (r ) Yes | No

5、 zypper install或者 zypper in xxx安装包

zypper in binutils-2.19

80%

推荐阅读:

Linux Oracle 11.2.0.4 单机数据库升级至最新补丁安装指北

万字详解Oracle架构、原理、进程,学会世间再无复杂架构

Linux | CentOS6.X/7.X 忘记超级用户 root 密码该怎么办?

模拟真实环境下超简单超详细的 MySQL 5.7 安装

CentOS6.7安装PostgreSQL10.9详细教程

Linux CentOS 7 安装教程

Linux RHEL7 安装教程

长按添加微信公众号,更多精彩内容不错过!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。