Redhat8 yum源内网部署

2023年 10月 31日 61.4k 0

Redhat8

内部yum源部署手册

1
、Yum
服务概述

Yum
(全称 Yellow Dog Updater)是一个在 Fedora 和 RedHat 以及 CentOS 中的 Shell 前端软件包管理器。基于 RPM 包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包.

2
、搭建Redhat 8
源服务器

2.1
使用
VDC
对虚拟化环境的
redhat
服务进行注册

       
主要流程:

1、
 
选择一台可以联网的
RHEL
虚拟机,在其上安装
virt-who
软件包,并配置
virt-who
服务。

 

安装 virt-who 软件包可以通过挂载 ISO 镜像,配置本地 yum 源进行安装:

[root@yumserver8 ~]# yum install virt-who

 

2、
 
配置
virt-who
服务,需要您创建并编辑如下文件
:

[root@yumserver8 ~]# cat   /etc/virt-who.d/virt-who.conf

[vmware]

type=esx

server=10.xx.xx.13

username=administrator@vsphere.local

password=77b6513b6baf65d0b4e858a6d5bea92c1f4c7b21d697dafb895e6e34da940597

owner=17xxx593

env=Library

hypervisor_id=hostname

 

注:实际vcenter
密码错误也不会影响

 

# vim /etc/virt-who.d/virt-who.conf

[vmware]

type=esx

server=[vCenter.domain.com] [1]

username=[vCenterusername]  [2]

password=[vCenterpassword]  [3]

owner=[org ID]              [4]

env=Library

hypervisor_id=hostname

 

[1][2][3][4]
处需要您根据实际情况修改:

 

[1]
处请替换问 VCenter 的域名或IP,[2]处替换为 VCenter 具有管理员权限的账户名,[3]处替换为[2]处用户名所对应的密码。

[4]
处请在 RHEL 虚拟机执行如下命令来获取 org ID(会需要您输入登录客户门户网站时用户名和密码):

 

# subscription-manager register

[root@yumserver8 ~]#   subscription-manager register

Registering to:   subscription.rhsm.redhat.com:443/subscription

Username: nixxd

Password:

The system has been registered with ID:   4e3b164c-1151-4f2b-aa03-4fee80b03f71

The registered system name is:   yumserver8

[root@yumserver8 ~]#

 

# subscription-manager identity

[root@yumserver8 ~]#   subscription-manager identity

system identity:   4e3b164c-1151-4f2b-aa03-4fee80b03f71

name: yumserver8

org name: 17xxx593

org ID: 17xxx593

[root@yumserver8 ~]#

 

 

如何使用加密密码配置virt-who
# virt-who-password
#password:(在此处输入字符后系统返回字符串,填入[3])

[root@yumserver8 ~]# virt-who-password

Password:

Use following as value for   encrypted_password key in the configuration file:

77b6513b6baf65d0b4e858a6d5bea92c1f4c7b21d697dafb895e6e34da940597

[root@yumserver8 ~]#

3
、完毕后,请执行如下命令开启 virt-who 服务:

 

[root@yumserver8 ~]# systemctl start   virt-who

[root@yumserver8 ~]#  systemctl enable virt-who

 

4
、在此之后,如果 virt-who 配置正确,此服务会将 VCenter 中的宿主机的信息映射到我们的客户门户网站,然后您需要登录客户门户网站为宿主机附加上 Physical 类型的 VDC 订阅,附加完毕后,会自动解锁 Virtual 类型的 VDC 订阅供虚拟机使用。

 

 

5、
最后,使用如下命令查看注册状态:

 

[root@yumserver8 ~]#   subscription-manager  status

+-------------------------------------------+

     System Status Details

+-------------------------------------------+

Overall Status: Disabled

Content Access Mode is set to Simple   Content Access. This host has access to content, regardless of subscription   status.

 

System Purpose Status: Disabled

 

[root@yumserver8 ~]#

 

6、
最后,查看yum源状态并尝试用红帽yum源安装一个软件测试一下

[root@yumserver8 ~]# yum repolist enabled

Updating Subscription Management   repositories.

repo id                                                           repo name

rhel-8-for-x86_64-appstream-rpms                                Red Hat   Enterprise Linux 8 for x86_64 - AppStream (RPMs)

rhel-8-for-x86_64-baseos-rpms                                   Red Hat   Enterprise Linux 8 for x86_64 - BaseOS (RPMs)

 

[root@yumserver8 ~]# yum install   net-tools

测试安装ok

 

2.2
搭建内部
Yum
源同步
Redhat

2.2.1
、查看系统版本.

[root@yumserver8 ~]# cat   /etc/redhat-release

Red Hat Enterprise Linux release 8.5   (Ootpa)

 

2.2.2
、放开系统防火墙,
关闭selinux

(为部署httpd服务准备)

[root@yumserver8 yum.repos.d]#   firewall-cmd --add-port=80/tcp --permanent

success

[root@yumserver8 yum.repos.d]#  firewall-cmd --reload

success

[root@yumserver8 yum.repos.d]#  firewall-cmd  --list-ports

80/tcp

 

 

[root@yumserver8 ~]# cat   /etc/selinux/config

 

# This file controls the state of SELinux   on the system.

# SELINUX= can take one of these three   values:

#       enforcing - SELinux security   policy is enforced.

#       permissive - SELinux prints warnings instead of enforcing.

#       disabled - No SELinux policy is loaded.

SELINUX=
permissive

# SELINUXTYPE= can take one of these   three values:

#       targeted - Targeted processes are protected,

#       minimum - Modification of targeted policy. Only selected processes are   protected.

#       mls - Multi Level Security protection.

SELINUXTYPE=targeted

  

2.2.3
、安装相关软件

[root@yumserver8 ~]# yum install -y wget   make cmake gcc gcc-c++ pcre-devel zlib-devel openssl openssl-devel httpd   yum-utils


 

2.2.4
、指定目录同步红帽yum
源软件包

指定目录/mirror(自定义目录)

Redhat8
不用createrepo了,直接用reposync,所有都搞定了

reposync -p /mirror   --download-metadata --repoid=rhel-8-for-x86_64-appstream-rpms

reposync -p /mirror   --download-metadata --repoid=rhel-8-for-x86_64-baseos-rpms

实际包大概有30000+个,时间有点久

 

2.3
启动并配置
Apache
服务

配置httpd服务,找到/etc/httpd/conf/httpd.conf中的DocumentRoot,并添加以下的内:

 

 

[root@yumserver8   ~]# cat /etc/httpd/conf/httpd.conf

#DocumentRoot   "/var/www/html"

DocumentRoot   "/mirror/"

        Options Indexes FollowSymLinks

        AllowOverride  None

        Order allow,deny

        Allow from all

        Require all granted

#

#   Relax access to content within /var/www.

 

[root@yumserver8   ~]# systemctl start httpd

[root@yumserver8   ~]# systemctl enable httpd

Created   symlink /etc/systemd/system/multi-user.target.wants/httpd.service
→   /usr/lib/systemd/system/httpd.service.

[root@yumserver8   ~]# systemctl status  httpd

 

###
修改
Apache
默认首页
index.html

cat /usr/share/httpd/noindex/index.html

Redhat   8
镜像

document.createElement("myHero")

myHero {

        display: block;

        background-color: #ddd;

        padding: 10px;

        font-size: 20px;

}

   
简介

   

   

        Redhat 8
配置内部YUM

   

       

1
、备份

        mkdir   /etc/yum.repos.d/backup

        mv   /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/

   

       

2
、下载新的 redhat.repo  
到   /etc/yum.repos.d/

        curl -o /etc/yum.repos.d/redhat.repo   http:/
/x.x.x.x/repo/ redhat.repo

        

   

       

3
、运行 yum makecache
生成缓存

   

       

4
、运行 yum repolist  
查看已经生成缓存

   

   

EOF

在浏览器输入:

即可访问客户端升级方法

2.4
编写
yum
源客户端文件

2.4.1 Redhat8
文件配置

[root@yumserver8 repo]# cat   /mirror/repo/redhat.repo

[AppStream]

name=AppStream

baseurl=
http xxxxxxxxx/rhel-8-for-x86_64-appstream-rpms/

enable=1

gpgcheck=0

 

[BaseOS]

name=BaseOS

baseurl=
http xxxxxxxxx/
rhel-8-for-x86_64-baseos-rpms/

enable=1

gpgcheck=0

 

3

redhat
客户端测试

再需要配置的客户端上操作。

mkdir /etc/yum.repos.d/backup

mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/

curl -o /etc/yum.repos.d/redhat.repo

 

[root@yum8test ~]# yum repolist all

Updating Subscription Management   repositories.

Unable to read consumer identity

 

This system is not registered with an   entitlement server. You can use subscription-manager to register.

 

repo id                                                        repo name                                                       status

AppStream                                                      AppStream                                                       enabled

BaseOS                                                         BaseOS                                                          enabled

 

 

[root@yum8test yum.repos.d]# yum install   net-tools

测试
ok

4
、配置定时任务

###
配置脚本
###

[root@yumserver8 mirror]# mkdir -p   /var/log/yumupdatelog/

 

[root@yumserver8 mirror]# cat   /mirror/redhat_yum_update.sh

#!/bin/bash

echo 'Updating Redhat Source'

DATETIME=`date +%F_%T`

exec >   /var/log/yumupdatelog/Redhat_$DATETIME.log

reposync -p /mirror --download-metadata   --repoid=rhel-8-for-x86_64-appstream-rpms

reposync -p /mirror --download-metadata   --repoid=rhel-8-for-x86_64-baseos-rpms

if [ $? -eq 0 ];then

      echo "SUCESS: $DATETIME Redhat_yum update successful"

      else

       echo "ERROR: $DATETIME Redhat_yum update failed"

      fi

[root@yumserver8 mirror]#

 

###
添加定时任务
###
每周一凌晨
1
点执行

[root@yumserver8 mirror]# crontab -l

0 1 * * 1 /bin/bash /mirror/redhat_yum_update.sh

 

相关文章

服务器端口转发,带你了解服务器端口转发
服务器开放端口,服务器开放端口的步骤
产品推荐:7月受欢迎AI容器镜像来了,有Qwen系列大模型镜像
如何使用 WinGet 下载 Microsoft Store 应用
百度搜索:蓝易云 – 熟悉ubuntu apt-get命令详解
百度搜索:蓝易云 – 域名解析成功但ping不通解决方案

发布评论