linux下yum源的配置及共享

1.yum的基本命令
   install             softwarename    安装
   repolist                            列出设定yum源信息
   remove              softwarename    卸载
   list                softwarename    查看软件源中是否有此软件
   list all                            查看所有软件名称
   list installed                      查看已安装的软件名称
   list available                      查看未安装的但可以装的软件名称
   search              softwarename    根据软件信息搜索软件名字
   whatprovides        filename        根据软件中的包含的文件名搜索软件名称
   history                             查看系统软件改变历史
   reinstall           softwarename    重新安装软件
   info                softwarename    查看软件信息
   clean  all                          清空yum缓存并重启
   update                              更新系统
   groups list                         以组形式查看软件
   groups info       softwaregroupname 查看组信息
   groups install    softwaregroupname 安装组

   groups remove     softwaregroupname 卸载组

2.配置本地yum源
    搞一个和系统匹配的镜像文件到系统中
    mkdir /iso
    mv /home/kiosk/Desktop/*.iso  /iso        防止放在桌面上被删除
    mkdir  /rhel7.0 /rhel7.2
    挂载镜像:
    mount /iso/rhel-server-7.0-x86_64-dvd.iso /rhel7.0

    mount /iso/rhel-server-7.2-x86_64-dvd.iso /rhel7.2

linux下yum源的配置及共享

    配置yum文件
    cd /etc/yum.repos.d/
    mkdir /repobackup
    mv * /repobackup
    vim yum.repo
      [source7.2]
      name=rhel7.2
      baseurl=file:///rhel7.2  挂载路径
      gpgcheck=0               0(可以下载第三方软件)1(不可以安装第三方软件)

    yum clean all              清空yum缓存并重新启动

linux下yum源的配置及共享

3.共享yum源
   1.在本地yum源配置完成之后安装apache

     yum install httpd

linux下yum源的配置及共享

     systemctl start httpd
     systemctl enable httpd
     systemctl stop firewalld
     systemctl disable firewalld

     mkdir /var/www/html/rhel7.0 /var/www/html/rhel7.2
   2.挂载镜像:
     mount /iso/rhel-server-7.0-x86_64-dvd.iso /var/www/html/rhel7.0
     mount /iso/rhel-server-7.2-x86_64-dvd.iso /var/www/html/rhel7.2

  linux下yum源的配置及共享

   3.测试访问:

     在浏览器中输入地址
     http://ip/rhel7.0
     http://172.25.254.7/rhel7.0

  linux下yum源的配置及共享

linux下yum源的配置及共享

   两个镜像挂载并共享成功

4.配置虚拟机yum

     rm -fr /etc/yum.repos.d/*
     vim /etc/yum.repos.d/yum.repo
       [rhel7.0]
       name=rhel7.0
       baseurl=http://172.25.254.10/rhel7.0
       gpgcheck=0

linux下yum源的配置及共享

linux下yum源的配置及共享

linux下yum源的配置及共享

   yum命令可以在虚拟机中运行,则共享成功。

umount  /var/www/html/rhel7.0   卸载挂载后的镜像

以上所有挂载为临时挂载reboot后会消失
  为了方便,不至于每次开机挂在镜像,所以进行开机自动挂载:
  vim /etc/rc.d/rc.local
    mount /iso/rhel-server-7.0-x86_64-dvd.iso /var/www/html/rhel7.0
    mount /iso/rhel-server-7.2-x86_64-dvd.iso /var/www/html/rhel7.2
    mount /iso/rhel-server-7.0-x86_64-dvd.iso /rhel7.0
    mount /iso/rhel-server-7.2-x86_64-dvd.iso /rhel7.2
  chmod +x /etc/rc.d/rc.local     给此文件一个执行权限,以便于开机可以对其进行执行操作。