#1 网络源
#1.1备份默认的yum配置到其他路径
[root@CentOS8 ~]# cd /etc/yum.repos.d
[root@CentOS8 yum.repos.d]# ls
CentOS-AppStream.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-PowerTools.repo
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-HA.repo CentOS-Sources.repo
CentOS-centosplus.repo CentOS-Extras.repo CentOS-Media.repo CentOS-Vault.repo
[root@CentOS8 yum.repos.d]# mkdir bkmv *.repo bk
#1.2 配置yum网络源仓库
[root@CentOS8 yum.repos.d]# vi BaseOS.repo
[BaseOS]
name=BaseOS
baseurl=
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[root@CentOS8 yum.repos.d]# vi AppStream.repo
[AppStream]
name=AppStream
baseurl=
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
#1.3 安装软件,验证yum
[root@CentOS8 yum.repos.d]# yum repolist
repo idrepo name status
AppStream AppStream 5,059
BaseOS BaseOS 1,695
[root@CentOS8 yum.repos.d]# yum provides httpd
[root@CentOS8 yum.repos.d]# yum -y install httpd
[root@CentOS8 yum.repos.d]# rpm -qe httpd
httpd-2.4.37-30.module_el8.3.0+561+97fdbbcc.x86_64
#2 本地源(http方式)
#2.1 服务端配置
[root@repo-server ~]#systemctl stop firewalld.service
[root@repo-server ~]#systemctl status firewalld.service
[root@repo-server ~]#yum -y install httpd --安装httpd服务
[root@repo-server ~]#systemctl enable --now httpdsystemctl status httpd
[root@repo-server ~]#mkdir -pv /var/www/html/centos/8
mkdir: created directory '/var/www/html/centos'
mkdir: created directory '/var/www/html/centos/8'
[root@repo-server ~]#mount /dev/sr0 /var/www/html/centos/8
#2.2 客户端配置
[root@repo-client ~]# cd /etc/yum.repos.d/
[root@repo-client yum.repos.d]# mkdir bkmv *.repo bk
[root@CentOS8 yum.repos.d]# vi BaseOS.repo
[BaseOS]
name=BaseOS
baseurl=file:///var/www/html/centos/8/BaseOS
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[root@CentOS8 yum.repos.d]# vi AppStream.repo
[AppStream]
name=AppStream
baseurl=file:///var/www/html/centos/8/AppStream
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[root@repo-client yum.repos.d]# yum repolist
二、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。
[root@CentOS8 httpd-2.4.46]#rpm -q httpd
package httpd is not installed
[root@CentOS8 ~]#wget -P /usr/local/src
[root@CentOS8 ~]#cd /usr/local/src/
[root@CentOS8 src]#ls
httpd-2.4.46.tar.bz2
[root@CentOS8 src]#tar xvf httpd-2.4.46.tar.bz2
[root@CentOS8 src]#cd httpd-2.4.46/
[root@CentOS8 httpd-2.4.46]#cat README
[root@CentOS8 httpd-2.4.46]#cat INSTALL
$ ./configure--prefix=PREFIX
$ make
$ makeinstall
$ PREFIX/bin/apachectlstart
[root@CentOS8 httpd-2.4.46]#yum -y install gcc make autoconf apr-devel apr-util-devel pcre-devel openssl-devel redhat-rpm-config
[root@CentOS8 httpd-2.4.46]#make -j 4 && make install
[root@CentOS8 httpd-2.4.46]#echo $?
[root@CentOS8 ~]#/apps/httpd24/bin/apachectl start
[root@CentOS8 bin]#systemctl stop firewalld.service
三、利用 sed 取出ifconfig命令中本机的IPv4地址
[root@CentOS8 ~]#ifconfig ens33 | sed -rn '2s/^[^0-9]+([0-9.]+) .*$/\1/p'
10.0.0.205
四、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符
删除前:
[root@CentOS8 ~]#cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sun Feb 28 12:11:21 2021
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=19cfb9c8-bd59-4c52-8403-70527758bf86 / xfs defaults 0 0
UUID=ccb9e34d-a43a-4276-a697-d8ce684cd699 /bootext4 defaults 1 2
UUID=759de453-b2ff-4553-8e01-e830d2f2468f /dataxfs defaults 0 0
UUID=84faeb9d-3694-40bb-b0c9-f55047d09799 swap swap defaults 0 0
删除后:
[root@CentOS8 data]#sed -Ei.bak /^#./s/^#.// fstabmore fstab
#
/etc/fstab
Created by anaconda on Sun Feb 28 12:11:21 2021
#
Accessible filesystems, by reference, are maintained under '/dev/disk/'.
See manpages fstab(5), findfs(8), mount(8) and/orblkid(8) formoreinfo.
#
After editing this file, run 'systemctl daemon-reload'to update systemd
unitsgenerated from this file.
#
UUID=19cfb9c8-bd59-4c52-8403-70527758bf86 / xfs defaults 0 0
UUID=ccb9e34d-a43a-4276-a697-d8ce684cd699 /bootext4 defaults 1 2
UUID=759de453-b2ff-4553-8e01-e830d2f2468f /dataxfs defaults 0 0
UUID=84faeb9d-3694-40bb-b0c9-f55047d09799 swap swap defaults 0 0
五、处理/etc/fstab路径,使用sed命令取出其目录名和基名
[root@CentOS8 ~]#echo "/etc/fstab" |sed -r 's#(^/.*/)([^/]+/?)#\1#'
/etc/
[root@CentOS8 ~]#echo "/etc/fstab" | sed -rn 's#(.*)/([^/]+)/?#\2#p'
fstab
所有Yum仓库的配置文件均需以.repo结尾并存放在/etc/yum.repos.d/目录中的。要创建本机的Yum仓库,需要手工创建这个配置文件。
文件结构如下:
[rhel-media]: yum仓库唯一标识符,避免与其他仓库冲突。
name=MyYumSource : yum仓库的名称描述,易于识别仓库用处。
baseurl=file:///media/cdrom :提供方式包括FTP(ftp://..)、HTTP(http://..)、本地(file:///..)
enabled=1 : 设置此源是否可用,1为可用,0为禁用。
gpgcheck=1 : 设置此源是否校验文件,1为校验,0为不校验。
gpgkey=file:///media/cdrom/RPM-GPG-KEY-redhat-release :若为校验请指定公钥文件地址。
1、本地yum 仓库制作
a.首先连接、挂载光盘:
mount /dev/cdrom /mnt
b. 修改yum配置文件:
[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///mnt ##baseurl 是 repodata 所在的上一级目录
enable=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
c. 清理缓冲并重建缓存
yum clean all
yum makecache
2、制作网络yum源
a. 以httpd作为文件服务器,首先安装httpd 服务,启动服务;
cp -r /mnt/Packages /var/www/html
b. 使用createrepo 创建仓库
>>>cd /var/www/html
>>>createrepo
>>>pwd
/var/www/html
>>>ls
Packages repodata
c. 修改yum 配置文件
>>>cat /etc/yum.repos.d/CentOS-NetYUM.repo
[c7-netyum]
name=CentOS-$releasever - Media
baseurl=http://192.168.0.130
enable=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
测试CentOS-NetYUM.repo 是否可用:
>>>yum clean all yum makecache
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)