linux yum安装共享库,配置本地和共享yum源,定制属于自己的yum仓库

使用yum安装软件命令:

####查看软件包

yum list all              ##列出yum源仓库里面的所有可用的安装包

yum list installed        ##列出所有已经安装的安装包

yum list available        ##列出没有安装的安装包

####安装软件

yum install softwarename  ##安装指定的软件

yum reinstall softarename ##重新安装指定的软件

yum localinstall 第三方software  ##安装第三方文件并且会解决软件的依赖关系

yum remove  softwarename  ##卸装指定的软件

####查找软件的信息

yum info software         ##查看软的信息

yum search keywords       ##根据关键字查找到相关安装包软件的信息

yum whatprovides filename ##查找包含指定文件的相关安装包

####对于软件组

yum groups list          ##列出软件组

yum groups install       ##安装一个软件组

yum group remove         ##卸载一个软件组

yum groups info          ##查看一个软件组的信息

关于yum源:

yum源仓库指向文件指向yum仓库。

yum源的指向文件存在于/etc/yum.repos.d/目录下。

以下是通过修改配置仓库指向文件,制作本地yum源;通过配置http服务和yum仓库指向文件制作共享yum源。

开始之前看一下查看一下当前的配置里面有什么已经安装好的yum源仓库

yum repolist

a7008483d552951bb809ae3f9d757526.png

9aa41aa70a821346a63f29e2671885a8.png

由上面可以知道现在的yum源配置没有成功可以读取利用的信息,下面将修改yum仓库指向文件制作yum的软件可用安装源。

第一种:利用iso镜像文件进行本地yum源的制作

1.挂载mkdir /mount                   ##创建的空的文件夹用于挂载iso镜像文件

mount /iso/ iso的文件的名   /mount    ##为了让iso镜像文件能够被像文件一样被便利地读取利用,将iso文件挂载在一个空的文件里面

987f4cd746647d6ce5899029ddaae93a.png

(在这里被挂载的iso镜像文件是一个存在的yum仓库,但是系统并不能读取识别,我们通过修改yum仓库指向文件让系统可以读取到这个仓库,被我们利用)

2.修改yum源指向文件mkdir /etc/backup      ##创建/etc 下的一个空文件夹用于备份原来的yum源读取文件 mv /etc/yum.repos.d/* /etc/backup/    ##备份yum仓库指定文件touch  /etc/yum.repos.d/myyum.repo

cat > /etc/yum.repos.d/myyum.repo<[test]

>name=myyumsource

>baseurl=file:///mount

>gpgcheck=0        ## 0表示不检查rpm数字证书,1为检查rpm数字证书>end123456789

43395516eaef6a7ff930a977186ecdd8.png

3.刷新测试

yum clean all  ##清空本地/var/cache/yum容器清单列表旧数据。

yum repolist   ##列出所有的可用的yum仓库,执行这个命令,会重读yum源设置志向文件,刷新本地容器清单列表。

现在看一下我们设置好的yum源仓库集合

9e59f1f798ab8a9d9b2e0a4e2b4b77b7.png

由上面我们可以看到我们的挂载已被成功读取。

利用已经做好的iso-yum本地源安装http 服务方便制作共享软件源yum install httpd

f08b52d485ab3c514bceb6d147bf840c.png

c1c6e868b6cc027d070007dde3e76e78.png

安装http服务成功,现在我们启动一下相关服务。systemctl  start httpd    ##开启http服务

systemctl enable httpd    ##设置开机启动http服务

systemctl stop firewalld  ##关闭火墙服务方便下面的htpp服务的使用

第二种:利用iso镜像文件进行http共享yum源的制作

1.解挂载umount /mount   ##将挂载在/mount下的文件解挂载将要挂载在http服务相关目录下

2.重新挂载,mkdir /var/www/html/myshare    ##在http服务的目录下面创建一个挂载点(http服务可以默认的服务目录)

mount /iso/iso文件名  /var/www/html/myshare

24e24b29e51a76f57cbb53dd12b61cfc.png

刷新服务

systemctl restart httpd

3.浏览器测试

打开浏览器,输入设置的主机的ip地址后面加上挂载的文件当看到文件出现则成功了。

d7ec28906bda4eefa0d39ddae647d997.png

添加repo仓库指向文件,让系统在寻找yum源的时候可以找到设置的http分享的yum源。touch  /etc/yum.repo.d/myshare.repo

cat > /etc/yum.repos.d/myshare.repo <

>[share]

>name=mysharesource

>baseurl=http://172.25.6.10/myshare

>gpgcheck=0

>end1234567

64963f18f82e07707c9ba4b1e14ff3ad.png

yum clean all

yum repolist 出现了错误

由于本文里面我们本地yum源制作和http-yum分享源制作使用了同一个iso文件所以我们解挂载了本地源挂载iso,执行yum repolist 命令yum源找不到我们在仓库指向文件里面指定的原本挂载在/mount的内容。现在我们可以修改第一个文件的查找点,让它找/var/www/html/myshare挂载点。

4285e825a6ab07b4aee0f57764207d83.pngyum repolist

8c360dcc5615a38e79d894ea22b93c89.png

这下本地的挂载也成功被读取了,没有出现报错。

由于这仅仅是设置的临时的挂载我们还可以设置开机自动挂载cat  >> /etc/fstab <

/iso/***.iso  /var/www/html/myshare iso9660  ro  0 0 end1234

利用rpm安装包文件进行自己的yum仓库的制作

前面两种是利用厂商发布的iso镜像文件作为yum仓库。当我们需要安装一些第三方提供的软件的时候我们需要到网上下载rpm的安装包,但是每次都下载多麻烦,我们可以将较常使用的rpm安装包归到一个文件里面制作成一个可以被系统识别的yum仓库,通过配置yum仓库指向文件可以将它设置成本地的yum源也可以是通过http发布的共享yum源。

1.首先下几个rpm包放在一个文件夹里面。

e2cf88912a296440f8d53bc1a438ffdf.png

2.生成符合要求的yum仓库

执行createrepo /software##将放置rpm安装包的文件夹创造成一个仓库文件,文件夹里面会多出一个repodata仓库数据文件夹。

8ff1552f9d93f43f3e388cc0da296cae.png

可以看到多了一个repodata的仓库数据文件,此时创建库成功。

8fe6e47d0d48d245b9eecc1d80fd0e79.png

其实在iso的挂载点可以看到它也有一个repodata的文件,这个标志性的文件夹标志着这个文件夹具备成为yum源的可能。

接下来可以修改yum的仓库文件,制作本地yum源以及http发布共享yum源。

一个自动执行脚本#!/bin/bash

###make a local yum source to install httpd service#####

#before start,copy the **.iso to a file i choose '/iso' #

mkdir /mount     #make a file use to mount the **.iso

mount /iso/rhel-server-7.0-x86_64-dvd.iso /mount #mount the **.iso to the mount file

mkdir /etc/backup   ##make a file to bak the *.repo file

mv /etc/yum.repos.d/* /etc/backup/   #move the *.repo file to the backfile

yum clean all  ##to refesh

######add the yum.repo file to add the yum source##

cat > /etc/yum.repos.d/yum.repo <[test]

>name=myyum

>baseurl=file:///mount

>gpgcheck=0>endyum clean all   ## to refresh

yum repolist   ##to see whether the yum-repo-setting is working

### above, the local yum-source is ok! now use the local yum-source we create to down httpd server. setting the httpd server to share the local-iso-source with http###

######install http server###

yum install httpd -y    ##install the httpd server

systemctl start httpd   ##start the httpd server

systemctl enable httpd  ##set start httpd server every time start the sys

systemctl stop firewalld

systemctl disable firewalld

###setting http server let the httpd server can find our iso source

umount /mount   #unmount the **iso file inorder to let it mount under the http sserver

yum clean allyum repolist

mkdir /var/www/html/myshare  ##make a file in http server-file to let it find the iso-source

mount /iso/rhel-server-7.0-x86_64-dvd.iso /var/www/html/myshare   ##mount the iso-source to the http server

systemctl restart httpd

###now because we unmount the /mount that we set local-source to mount the http server so we can not use localyum###

###to modify the local-yum-source to let it share the source with http server###

cat > /etc/yum.repos.d/yum.repo <[test]

>name=myyum

>baseurl=http://172.25.6.11/myshare

>gpgcheck=0>endyum clean allyum repolist

#####set automount when start the system######

cat  >> /etc/fstab </iso/rhel-server-7.0-x86_64-dvd.iso  /var/www/html/myshare  iso9660 ro 0 0 >end12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061

all

转载地址:   https://blog.csdn.net/danneel/article/details/52098527

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值