Unit13 软件安装

 

1.如何安装软件

安装软件是在系统中增加文件的过程

yum search 关键字          ##搜索相关软件

wKiom1f-Uv6jk5LAAAEpOFdYc2I279.png

yum installgcc.x86_64(软件名称)  -y         ##安装软件(加y表示不询问直接安装)

  Is this ok [y/d/N]:  y表示安装d表示下载n表示什么都不做

wKiom1f-Uw7jHMyWAABE-Xz-Smw600.png

yum remove gcc -y            ##卸载gcc

yum list all          ##查询全部安装包

 yumlist all | wc -l        ##统计安装包数量

yum list installed        ##查询已安装的安装包

yum list available        ##查询未安装的

wKioL1f-UxujTKKyAABYuTbt5Ms276.png

yum info gcc                     ##查询软件信息

wKioL1f-UymgIbZgAADhYrG0spM077.png

yum groups installGNOME(名称)         ##安装组

yum group infoGNOME               ##查询组信息

yum groups removeGNOME         ##卸载组

yum group list            ##列出软件组

yum history         ##查看软件修改情况

wKiom1f-Uzaz7CJGAABdc4tYSJg992.png

Hostnamectl        ##查看那本机信息

wKiom1f-U0WB636zAADE4BwCayg703.png

 

2.软件仓库的建立

 

① 安装镜像文件

[kiosk@foundation13Desktop]$ lftp 172.25.254.250:/pub

cd ok,cwd=/pub                       

lftp172.25.254.250:/pub> cd iso/

cd ok,cwd=/pub/iso

lftp172.25.254.250:/pub/iso> getrhel-server-7.0-x86_64-dvd.iso        ##下载镜像文件

② 挂载镜像文件

[root@foundation13 Desktop]# mount rhel-server-7.0-x86_64-dvd.iso /source  ##挂载镜像文件到/source

[root@foundation13 Desktop]# cd /source

[root@foundation13 source]# ls

addons p_w_picpaths      Packages                 RPM-GPG-KEY-redhat-release

EFI    isolinux    release-notes            TRANS.TBL

EULA   LiveOS      repodata

GPL    media.repo RPM-GPG-KEY-redhat-beta

[root@foundation13 source]# cd Packages/  ##所有安装包都在Packages/

wKioL1f-U1-AGiV0AADyd23n2eE387.png

③ /etc/yum.repos.d中的文件移出

mv /etc/yum.repos.d/* /mnt        ##/etc/yum.repos.d中的左右文件移动到/mnt

 

④ 建立仓库

[root@foundation13source]# cd /etc/yum.repos.d/   ##必须在此目录下写.repo文件

[root@foundation13yum.repos.d]# vim yum.repo     ##文件名随意,类型一定要是.repo

[root@foundation13yum.repos.d]# cat yum.repo            ##查看内容

[server]         ##仓库名称

name=server ##仓库描述

baseurl=file:///source  ##仓库的地址

gpgcheck=0  ##是否检测软件的gpgkey(相当于标签,1表示检测,如不同则拒绝安装。0表示不检测)

wKiom1f-U3fTUn3SAAAv0X4jklM934.png

[root@foundation13yum.repos.d]# yum clean all            ##刷新仓库配置

Loaded plugins:langpacks, product-id, subscription-manager

This system is notregistered to Red Hat Subscription Management. You can use subscription-managerto register.

Cleaning repos:server

Cleaning upeverything

wKioL1f-U4XD4sbWAACHFtSXQZI972.png

 

3.虚拟机上安装软件

① 网络yum源的配置(真机上操作)

yum install httpd           ##安装httpd服务

systemctl stop firewalld         ##关闭防火墙

systemctl start httpd              ##启动http服务

systemctl enable httpd

 

[root@foundation13 yum.repos.d]# yum install httpd -y     ##安装http服务

Loaded plugins: langpacks, product-id,subscription-manager

This system is not registered to Red HatSubscription Management. You can use subscription-manager to register.

server                                                   | 4.1 kB     00:00    

(1/2): server/group_gz                                     | 134kB   00:00    

(2/2): server/primary_db                                   | 3.4MB   00:00    

Package matching httpd-2.4.6-17.el7.x86_64already installed. Checking for update.

Nothing to do

[root@foundation13 yum.repos.d]# systemctl stop firewalld      ##关闭防火墙

[root@foundation13 yum.repos.d]# systemctl start httpd           ##开启http服务

[root@foundation13 yum.repos.d]# mkdir -p/var/www//html/yumsource        ##新建目录

[root@foundation13 yum.repos.d]# mount /home/kiosk/Desktop/rhel-server-7.0-x86_64-dvd.iso/var/www/html/yumsource/              ##挂载镜像文件

mount: /dev/loop2 is write-protected,mounting read-only

[root@foundation13 yum.repos.d]#

wKiom1f-U5SAUIJ2AAFI1yVYe5E094.png

 

② 虚拟机操作

[root@localhost ~]# cd /etc/yum.repos.d

[root@localhost yum.repos.d]# ls

yum.repo

[root@localhost yum.repos.d]# vim yum.repo

[root@localhost yum.repos.d]# yum clean all

Loaded plugins: langpacks

Cleaning repos: server

Cleaning up everything

[root@localhost yum.repos.d]#

 

wKiom1f-U6WxQVhSAAEEH1b8UAA440.png