一、yum 共享源
yum repolist #列出设定yum源信息
yum remove softwarename #卸载
yum list softwarename #列出软件源是否有此软件
yum list all #列出软件名称
yum list installd #列出已经安装的软件名称
yum list availavle #列出可以用yum安装的软件名称
yum clean all #清空yum缓存
yum search softwareinfo #根据软件信息搜寻软件名字
yun whatprovides filename #在yum源中查找包含filename文件的软件包
yum update #更新软件
yum history #查看系统软件改变历史
yum reinstall softwarename #重新安装
yum info softwarename #查看软件信息
yum groups list #查看软件组信息
yum groups info softwaregroup #查看软件组内包含的软件
yum groups install softwaregroup #安装组件
yum groups remove softwaregroup #卸载组件
二、在本地yum源配置完成之后去安装apache
yum install httpd 安装httpd
systemctl start httpd 开启httpd
systemctl enable httpd 开机时启动httpd
systemctl stop firewalld 暂时关闭防火墙
systemctl disable firewalld 关闭防火墙
mkdir /var/www/html/source7.0 /var/www/html/source7.2 创建目录
2、挂载镜像
挂载:每个文件系统都有独立的inode、block、super、block等信息,这个文件系统要能够链接到目录树才能被我们使用。将文件系统与目录树结合的操作称为挂载。
挂载点一定是目录,该目录为进入该文件系统的入口,因此并不是你有任何文件系统都能使用,必须要挂载到目录树的某个目录后,才能使用该文件系统
vim /etc/rc.d/rc/local #开机时自动挂载
写入
mount /iso/rhe*7.0* /var/www/html/source7.0
mount /iso/rhe*7.2* /var/www/html/source7.2 挂载
:wq
chmod +x /etc/rc.d/rc.local #将/etc/rc.d/rc.local文件可执行文件
3、访问测试
在浏览器中输入地址
http://真机ip/source7.0
http://172.25.254.18/source7.0
4、配置虚拟机
rm -rf /etc/yum.repos.d/*
vim /etc/yum.repos.d/yum.repo
[source7.0]
name=source7.0
baseurl=file:///source7.0(前两个//代表超文本,第三个/为根)
gpgcheck=0(gpg加密方式,若为0,代表不对第三方软件进行检测,若为1,对官方软件进行检测)
练习
ot@foundation60 ~]# hostnamectl #查看当前主机是哪个版本的镜像文件
Static hostname: foundation60.ilt.example.com
Icon name: computer-laptop
Chassis: laptop
Machine ID: 504c4d8a5d664226b1877a3b1647df87
Boot ID: ace68e7ac2d14151b3a3aea07656ac26
Operating System: Red Hat Enterprise Linux Server 7.2 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.2:GA:server
Kernel: Linux 3.10.0-327.el7.x86_64
Architecture: x86-64
[root@foundation60 ~]# mkdir /iso/ #创建镜像目录
[root@foundation60 ~]# mv /home/kiosk/Desktop/rhel-server-7.2-x86_64-dvd.iso /iso #将镜像文件7.2移动到/iso目录下
[root@foundation60 ~]# mkdir /source7.2 #建立source7.2目录
[root@foundation60 ~]# mount /iso/rhel-server-7.2-x86_64-dvd.iso /source7.2 #挂载
mount: /dev/loop0 is write-protected, mounting read-only
[root@foundation60 ~]# ls /iso #查看/iso下的镜像文件
rhel-server-7.2-x86_64-dvd.iso
[root@foundation60 ~]# cd /etc/yum.repos.d
[root@foundation60 yum.repos.d]# mkdir /repobackup
[root@foundation60 yum.repos.d]# mv * /repobackup
[root@foundation60 yum.repos.d]# vim yum.repo
[root@foundation60 yum.repos.d]# ls
yum.repo
[root@foundation60 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@foundation60 yum.repos.d]# yum repolist #列出设定yum源信息
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
repo id repo name status
source7.2 source7.2 4,620
repolist: 4,620
[root@foundation60 yum.repos.d]# yum install dhcpd #安装dhcpd
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.
No package dhcpd available.
Error: Nothing to do
[root@foundation60 yum.repos.d]# yum install 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.
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!
[root@foundation60 yum.repos.d]#
[root@foundation18 ~]# yum install htppd #安装htppd
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.
No package htppd available.
Error: Nothing to do
[root@foundation18 ~]# systemctl start httpd #开启httpd
[root@foundation18 ~]# systemctl enable httpd #开机时开启httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@foundation18 ~]# systemctl stop firewalld #暂时关闭防火墙
[root@foundation18 ~]# systemctl disable firewalld #关闭防火墙
[root@foundation18 ~]# mkdir /var/www/html/source7.0 /var/www/html/source7.2
root@foundation18 ~]# mount /iso/rhel-server-7.0-x86_64-dvd.iso /var/www/html/source7.0 #挂载
root@foundation18 ~]# mount /iso/rhel-server-7.2-x86_64-dvd.iso /var/www/html/source7.2
ot@localhost ~]# rm -rf /etc/yum.repos.d/*
[root@localhost ~]# vim /etc/yum.repos.d/yum.repo
[root@localhost ~]# cat /etc/yum.repos.d/yum.repo
[source7.0]
name=source7.0
baseurl=http://172.25.254.18/source7.0
gpgcheck=0
[root@localhost ~]# yum install httpd
Loaded plugins: langpacks
source7.0 | 4.1 kB 00:00:00
(1/2): source7.0/group_gz | 134 kB 00:00:00
(2/2): source7.0/primary_db | 3.4 MB 00:00:00
Resolving Dependencies
--> Running transaction check
永久挂载
ot@foundation18 ~]# vim /etc/rc.d/rc.local # 打开rc.local文件
[root@foundation18 ~]# ls -ld /etc/rc.d/rc.local #显示rc.local文件的属性
-rw-r--r-- 1 root root 610 Apr 22 16:25 /etc/rc.d/rc.local
[root@foundation18 ~]# chmod +x /etc/rc.d/rc.local #将此文件变为可执行文件
[root@foundation18 ~]# ls -ld /etc/rc.d/rc.local #查看修改后的文件属性
-rwxr-xr-x 1 root root 610 Apr 22 16:25 /etc/rc.d/rc.local
[root@foundation18 ~]# df #列出文件系统的整体磁盘使用量
#Filesystem:代表该文件系统在哪个分区,所以列出设备名称
#1k-blocks:数字单位为1kb
#used:使用掉的硬盘空间
#Available:剩下的磁盘空间大小
#Use%:磁盘的使用率,如果使用率高达90%以上时,可能会因为容量不足造成系统问题
#Mountedon:挂载点
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 307974224 28970344 279003880 10% /
devtmpfs 1870112 0 1870112 0% /dev
tmpfs 1883192 524 1882668 1% /dev/shm
tmpfs 1883192 9056 1874136 1% /run
tmpfs 1883192 0 1883192 0% /sys/fs/cgroup
/dev/sda1 508588 149320 359268 30% /boot
tmpfs 376640 20 376620 1% /run/user/1000
tmpfs 376640 0 376640 0% /run/user/0
/dev/loop0 3654720 3654720 0 100% /source7.0
/dev/loop1 3947824 3947824 0 100% /source7.2
/dev/loop2 3654720 3654720 0 100% /var/www/html/source7.0
/dev/loop3 3947824 3947824 0 100% /var/www/html/source7.2
/dev/sdb1 31457360 3834496 27622864 13% /run/media/kiosk/̨
ifcfg-enp0s25 网络配置接口 (和外界沟通)
ifcfg-lo 回关接口(内部沟通)
yum repolist #列出设定yum源信息
yum remove softwarename #卸载
yum list softwarename #列出软件源是否有此软件
yum list all #列出软件名称
yum list installd #列出已经安装的软件名称
yum list availavle #列出可以用yum安装的软件名称
yum clean all #清空yum缓存
yum search softwareinfo #根据软件信息搜寻软件名字
yun whatprovides filename #在yum源中查找包含filename文件的软件包
yum update #更新软件
yum history #查看系统软件改变历史
yum reinstall softwarename #重新安装
yum info softwarename #查看软件信息
yum groups list #查看软件组信息
yum groups info softwaregroup #查看软件组内包含的软件
yum groups install softwaregroup #安装组件
yum groups remove softwaregroup #卸载组件
二、在本地yum源配置完成之后去安装apache
yum install httpd 安装httpd
systemctl start httpd 开启httpd
systemctl enable httpd 开机时启动httpd
systemctl stop firewalld 暂时关闭防火墙
systemctl disable firewalld 关闭防火墙
mkdir /var/www/html/source7.0 /var/www/html/source7.2 创建目录
2、挂载镜像
挂载:每个文件系统都有独立的inode、block、super、block等信息,这个文件系统要能够链接到目录树才能被我们使用。将文件系统与目录树结合的操作称为挂载。
挂载点一定是目录,该目录为进入该文件系统的入口,因此并不是你有任何文件系统都能使用,必须要挂载到目录树的某个目录后,才能使用该文件系统
vim /etc/rc.d/rc/local #开机时自动挂载
写入
mount /iso/rhe*7.0* /var/www/html/source7.0
mount /iso/rhe*7.2* /var/www/html/source7.2 挂载
:wq
chmod +x /etc/rc.d/rc.local #将/etc/rc.d/rc.local文件可执行文件
3、访问测试
在浏览器中输入地址
http://真机ip/source7.0
http://172.25.254.18/source7.0
4、配置虚拟机
rm -rf /etc/yum.repos.d/*
vim /etc/yum.repos.d/yum.repo
[source7.0]
name=source7.0
baseurl=file:///source7.0(前两个//代表超文本,第三个/为根)
gpgcheck=0(gpg加密方式,若为0,代表不对第三方软件进行检测,若为1,对官方软件进行检测)
练习
ot@foundation60 ~]# hostnamectl #查看当前主机是哪个版本的镜像文件
Static hostname: foundation60.ilt.example.com
Icon name: computer-laptop
Chassis: laptop
Machine ID: 504c4d8a5d664226b1877a3b1647df87
Boot ID: ace68e7ac2d14151b3a3aea07656ac26
Operating System: Red Hat Enterprise Linux Server 7.2 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.2:GA:server
Kernel: Linux 3.10.0-327.el7.x86_64
Architecture: x86-64
[root@foundation60 ~]# mkdir /iso/ #创建镜像目录
[root@foundation60 ~]# mv /home/kiosk/Desktop/rhel-server-7.2-x86_64-dvd.iso /iso #将镜像文件7.2移动到/iso目录下
[root@foundation60 ~]# mkdir /source7.2 #建立source7.2目录
[root@foundation60 ~]# mount /iso/rhel-server-7.2-x86_64-dvd.iso /source7.2 #挂载
mount: /dev/loop0 is write-protected, mounting read-only
[root@foundation60 ~]# ls /iso #查看/iso下的镜像文件
rhel-server-7.2-x86_64-dvd.iso
[root@foundation60 ~]# cd /etc/yum.repos.d
[root@foundation60 yum.repos.d]# mkdir /repobackup
[root@foundation60 yum.repos.d]# mv * /repobackup
[root@foundation60 yum.repos.d]# vim yum.repo
[root@foundation60 yum.repos.d]# ls
yum.repo
[root@foundation60 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@foundation60 yum.repos.d]# yum repolist #列出设定yum源信息
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
repo id repo name status
source7.2 source7.2 4,620
repolist: 4,620
[root@foundation60 yum.repos.d]# yum install dhcpd #安装dhcpd
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.
No package dhcpd available.
Error: Nothing to do
[root@foundation60 yum.repos.d]# yum install 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.
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!
[root@foundation60 yum.repos.d]#
[root@foundation18 ~]# yum install htppd #安装htppd
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.
No package htppd available.
Error: Nothing to do
[root@foundation18 ~]# systemctl start httpd #开启httpd
[root@foundation18 ~]# systemctl enable httpd #开机时开启httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@foundation18 ~]# systemctl stop firewalld #暂时关闭防火墙
[root@foundation18 ~]# systemctl disable firewalld #关闭防火墙
[root@foundation18 ~]# mkdir /var/www/html/source7.0 /var/www/html/source7.2
root@foundation18 ~]# mount /iso/rhel-server-7.0-x86_64-dvd.iso /var/www/html/source7.0 #挂载
root@foundation18 ~]# mount /iso/rhel-server-7.2-x86_64-dvd.iso /var/www/html/source7.2
ot@localhost ~]# rm -rf /etc/yum.repos.d/*
[root@localhost ~]# vim /etc/yum.repos.d/yum.repo
[root@localhost ~]# cat /etc/yum.repos.d/yum.repo
[source7.0]
name=source7.0
baseurl=http://172.25.254.18/source7.0
gpgcheck=0
[root@localhost ~]# yum install httpd
Loaded plugins: langpacks
source7.0 | 4.1 kB 00:00:00
(1/2): source7.0/group_gz | 134 kB 00:00:00
(2/2): source7.0/primary_db | 3.4 MB 00:00:00
Resolving Dependencies
--> Running transaction check
永久挂载
ot@foundation18 ~]# vim /etc/rc.d/rc.local # 打开rc.local文件
[root@foundation18 ~]# ls -ld /etc/rc.d/rc.local #显示rc.local文件的属性
-rw-r--r-- 1 root root 610 Apr 22 16:25 /etc/rc.d/rc.local
[root@foundation18 ~]# chmod +x /etc/rc.d/rc.local #将此文件变为可执行文件
[root@foundation18 ~]# ls -ld /etc/rc.d/rc.local #查看修改后的文件属性
-rwxr-xr-x 1 root root 610 Apr 22 16:25 /etc/rc.d/rc.local
[root@foundation18 ~]# df #列出文件系统的整体磁盘使用量
#Filesystem:代表该文件系统在哪个分区,所以列出设备名称
#1k-blocks:数字单位为1kb
#used:使用掉的硬盘空间
#Available:剩下的磁盘空间大小
#Use%:磁盘的使用率,如果使用率高达90%以上时,可能会因为容量不足造成系统问题
#Mountedon:挂载点
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 307974224 28970344 279003880 10% /
devtmpfs 1870112 0 1870112 0% /dev
tmpfs 1883192 524 1882668 1% /dev/shm
tmpfs 1883192 9056 1874136 1% /run
tmpfs 1883192 0 1883192 0% /sys/fs/cgroup
/dev/sda1 508588 149320 359268 30% /boot
tmpfs 376640 20 376620 1% /run/user/1000
tmpfs 376640 0 376640 0% /run/user/0
/dev/loop0 3654720 3654720 0 100% /source7.0
/dev/loop1 3947824 3947824 0 100% /source7.2
/dev/loop2 3654720 3654720 0 100% /var/www/html/source7.0
/dev/loop3 3947824 3947824 0 100% /var/www/html/source7.2
/dev/sdb1 31457360 3834496 27622864 13% /run/media/kiosk/̨
ifcfg-enp0s25 网络配置接口 (和外界沟通)
ifcfg-lo 回关接口(内部沟通)