新秀篇 ##Linux软件的安装【yum命令】##

1.yum命令
yum   install   softwaremane   ##安装
           repolist                  ##列出设定yum源信息
           remove   softwaremane     ##卸载
           list     softwareman      ##查看软件源中是否有此软件
           list all                 ##列出所有软件名称
            list installd            ##列出已经安装的软件名称
           list available           ##列出可以用yum安装的软件名称
           clean all                ##清空yum缓存
           search    softwareinfo   ##根据软件信息搜索软件名字
           whatprovides filename    ##在yum源中查找包含filename文件的软件包
           update                   ##更新软件
           history                  ##查看系统软件改变历史记录
           reinstall  softwarename  ##重新安装
           info        softwarename ##查看软件信息
          groups list              ##查看软件组信息
          groups info  softwaregroup ##查看软件组内包含的软件
          groups inatall softwaregroup  ##安装组件

          groups remove  softwaregroup  ##卸载组件

#############################下载软件#####################################
##建立yum源
 搞一个和系统匹配的镜像文件到系统中

  下载rhel-server-7.2-x86_64-dvd.iso文件

新秀篇 ##Linux软件的安装【yum命令】##_第1张图片

  mkdir   /iso           ##在根下建立一个文件存放文件
  mv /home/kiosk/Desktop/*.iso  /iso   ##防止删掉,备份
  mkdir  /source7.0  /source7.2
  mount  /iso/rhel-server-7.0-x86_64-dvd.iso  /source7.0   ##把镜像里的文件移动到相应目录
  mount  /iso/rhel-server-7.2-x86_64-dvd.iso  /source7.2
  cd /etc/yum.repos.d/    ##软件仓库目录
  mkdir  /repobackup
  mv * /repobackup
  vim yum.repo          ##编辑文件

   %%编辑的内容 
    [source7.2]
    name=source7.2
    baseurl=file:///source7.2   ##
    gpgcheck=0
    yum  clean  all      ##清空yum缓存
    ls /source7.0/Packages/ |grep dhcp   ##查看7.0的安装包里dhcp的安装包
    dhcp-4.2.5-27.el7.x86_64.rpm
    dhcp-common-4.2.5-27.el7.x86_64.rpm
    dhcp-libs-4.2.5-27.el7.i686.rpm
    dhcp-libs-4.2.5-27.el7.x86_64.rpm
    yum install dhcp -y    ##安装dhcp

####实验详细操作####
[root@foundation21 ~]# mkdir /iso
mkdir: cannot create directory ‘/iso’: File exists
[root@foundation21 ~]# mv /home/kiosk/Desktop/*.iso /iso
[root@foundation21 ~]# mkdir /source7.0 /source7.2
[root@foundation21 ~]# mount /iso/rhel-server-7.0-x86_64-dvd.iso /source7.0
mount: /dev/loop0 is write-protected, mounting read-only
[root@foundation21 ~]# mount /iso/rhel-server-7.2-x86_64-dvd.iso /source7.2
mount: /dev/loop1 is write-protected, mounting read-only
[root@foundation21 ~]# cd /etc/yum.repos.d/
[root@foundation21 yum.repos.d]# mkdir /repobackup
[root@foundation21 yum.repos.d]# mv * /repobackup
[root@foundation21 yum.repos.d]# vim yum.repo
[root@foundation21 yum.repos.d]# yum clean all
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
              : manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: source7.2
Cleaning up everything
[root@foundation21 yum.repos.d]# cd
[root@foundation21 ~]# yum install dhcp  安装dhcp
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
              : manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
source7.2                                                | 4.1 kB     00:00     
(1/2): source7.2/group_gz                                  | 136 kB   00:00     
(2/2): source7.2/primary_db                                | 3.6 MB   00:00     
Resolving Dependencies
--> Running transaction check
---> Package dhcp.x86_64 12:4.2.5-42.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package      Arch           Version                    Repository         Size
================================================================================
Installing:
 dhcp         x86_64         12:4.2.5-42.el7            source7.2         511 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 511 k
Installed size: 1.4 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 12:dhcp-4.2.5-42.el7.x86_64                                  1/1
source7.2/productid                                      | 1.6 kB     00:00     
  Verifying  : 12:dhcp-4.2.5-42.el7.x86_64                                  1/1

Installed:
  dhcp.x86_64 12:4.2.5-42.el7                                                   

Complete!                                              ##显示这个就是安装成功##

################################共享yum源#############################################
  (1)在本地yum源配置完成之后安装apache
             yum  install  httpd  ##共享
            systemctl  start httpd
            systemctl  enable httpd
            systemctl  stop firewalld
            systemctl  disable  firewalld
            mkdir  /var/www/html/source7.0 /var/www/html/source7.2
  (2)挂载镜像:
            mount /iso/rhel-server-7.0-x86_64-dvd.iso /var/www/html/source7.0
            mount /iso/rhel-server-7.2-x86_64-dvd.iso  /var/www/html/source7.2
            vim /etc/rc.d/rc.local  ##永久挂载,开机启动

编辑:mount /iso/rhel-server-7.0-x86_64-dvd.iso /var/www/html/source7.0
            mount /iso/rhel-server-7.2-x86_64-dvd.iso  /var/www/html/source7.2
          :wq
          chmod +x /etc/rc.d/rc.local
  (3)访问测试
        在浏览器中输入地址:
        ip/source7.0
             172.25.254.20/source7.0
             172.25.254.20/source7.2
  (4)配置虚拟机:
             rm -fr  /etc/yum.repos.d/*
             vim /etc/yum.repos.d/yum.repo

  [source7.0]
  name=source7.0
  baseurl=http://172.25.254.19/source7.0
  gpgcheck=0
 配置文件完成后可以在虚拟机输入yum install dhcp进行下载
挂载是临时的,重启就没了。长期挂载就是如上写入文件。
[root@foundation21 ~]# df    重启之后可以看到已经挂载完成
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/sda3      307974224 17399728 290574496   6% /
devtmpfs         1868044        0   1868044   0% /dev
tmpfs            1881152       88   1881064   1% /dev/shm
tmpfs            1881152     8868   1872284   1% /run
tmpfs            1881152        0   1881152   0% /sys/fs/cgroup
/dev/sda1         505580   149472    356108  30% /boot
/dev/loop0       3654720  3654720         0 100% /var/www/html/source7.0
/dev/loop1       3947824  3947824         0 100% /var/www/html/source7.2
tmpfs             376232       12    376220   1% /run/user/1000
yum命令仅仅是对软件进行管理,rpm命令才是真正安装软件的,yum可以解决软件依赖性。
###########################清理临时文件####################################
监控命令: watch -n -1  ls -R /mnt/ -1
[root@localhost cron.d]# cd /usr/lib/tmpfiles.d    ##切换路径
[root@localhost tmpfiles.d]# vim westos.conf       ##.conf 临时文件的后缀   编辑临时文件删除脚本
[root@localhost tmpfiles.d]# cat westos.conf
d /mnt/westos 1777 root root 8s     ##编写的内容   8s表示临时文件产生8秒后删除
[root@localhost tmpfiles.d]# systemd-tmpfiles --create /usr/lib/tmpfiles.d/*   ##创建临时文件
[root@localhost tmpfiles.d]# touch /mnt/westos/uhfu   ##建立一个
[root@localhost tmpfiles.d]# touch /mnt/westos/ff     ##再建立一个
[root@localhost tmpfiles.d]# systemd-tmpfiles --clean /usr/lib/tmpfiles.d/*   ##删除已经8秒的临时文件

你可能感兴趣的:(新秀篇 ##Linux软件的安装【yum命令】##)