Centos7.2 配置yum私源

前言:

      在很多公司的服务器是在内网运行的,装上Centos系统后有很多软件包是没有的,比如:gcc httpd等等,这时候要是想安装这些软件需要费很大的精力去下载软件包及其依赖,一个一个安装,呢,为了使内网服务器也能像外网服务器安装基础一些基础软件包那么简单,这里就需要在我们自己的内网中配置yum私源了。详细步骤立马就来:

1.下载Centos7的iso镜像:http://archive.kernel.org/centos-vault/7.2.1511/isos/x86_64/CentOS-7-x86_64-Everything-1511.iso,这个iso的文件会比较大,因为是完全版,7个G。之所以下载完全版就是因为它包含了Centos所有的功能,为了使后期使用遇到不必要的麻烦我们选择这个版本。

2.将下载后的文件CentOS-7-x86_64-Everything-1511.iso传至服务器中,任意一个目录均可,这里我们选择传输至:/dist目录下。

3.创建一个文件夹,用于挂载iso,我们选择将iso挂载到/mnt/cdrow :

mkdir -p /mnt/cdrow

4.运行命令进行挂载:mount -t iso9660 -o loop /dist/CentOS-7-x86_64-Everything-1511.iso 

/mnt/cdrow

5.将默认的yum配置文件统一备份到文件夹中,备份完了最好检查一下是否备份成功,而后删除源文件:

cd /etc/yum.repo.d    //进入yum初始配置文件目录

mkdir back.repo     //创建备份目录

cp -r Centos-*  ./back.repo    //将yum初始配置文件copy至备份目录中

rm -rf Centos-*     //删除yum初始配置文件

6.创建一个新的yum配置文件:

vi base.repo

文件内容如下:

[centos7]

name=centos7

baseurl=file:///mnt/cdrow

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

gpgcheck=0

enabled=1

7.清除yum缓存并makecache

yum clean all

yum makecache

8.安装httpd测试是否配置成功

yum -y install httpd

9.因为我们需要使用浏览器检查httpd是否启动成功,这里需要关闭防火墙:

systemctl disable firewalld

10.开启httpd服务

systemctl start httpd.service

11.将我们刚才挂载的iso目录做软件接到httpd网页目录下面:

ln -s /mnt/cdrow /var/www/html/centos7

12.这时候我们使用浏览器访问就可以了,假如服务器ip地址为:192.168.1.100,就在浏览器中输入一下地址就可以了。

192.168.1.100/centos7

13.在其他内网服务器使用此yum源

     1)在其他服务器引用第五步骤

     2)在其他服务器引用第六步骤

     3)其第六步骤文件内容有些差别,按照如下配置:

           [centos7]

           name=centos7

           baseurl=http://192.168.1.100/centos7

           gpgcheck=0

           enabled=1

     4)在其他服务器应用第七步骤,操作完成就就可以使用yum进行安装一些基础的软件包了。

          

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
redhat 7.2 可用的yum源, 亲自测试可以使用 ,使用过程: 1.卸载已经存在的yum: rpm -qa | grep yum | xargs rpm -e --nodeps 2.将yum 文件放到server中 3.执行rpm -ivh yum-* 4.创建repo文件: #CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$7 - Base - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$7&arch;=$basearch&repo=os baseurl=http://mirrors.163.com/centos/7/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$7 - Updates - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$7&arch;=$basearch&repo=updates baseurl=http://mirrors.163.com/centos/7/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$7 - Extras - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$7&arch;=$basearch&repo=extras baseurl=http://mirrors.163.com/centos/7/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$7 - Plus - 163.com baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 5.测试是否安装成功 yum -y install tree
要将RedHat 7.2更换为CentOS 7的yum源,可以按照以下步骤操作: 1. 卸载RedHat原有的yum源: 使用命令`rpm -qa | grep yum`查看已安装的yum软件包。 使用命令`rpm -qa | grep yum | xargs rpm -e --nodeps`卸载已安装的yum软件包。 2. 下载CentOSyum源: 前往CentOS镜像站点,例如阿里云镜像站点`https://mirrors.aliyun.com/centos/`,找到对应版本的yum源地址。 在镜像站点中找到合适的版本,例如CentOS 7的yum源码地址为`https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/`。 根据需求选择需要下载的包,例如`python-urlgrabber-3.10-10.el7.noarch.rpm`、`yum-3.4.3-167.el7.centos.noarch.rpm`等。 使用命令`wget`或其他下载工具下载所需的包。 3. 安装下载的CentOSyum源: 执行命令`rpm -ivh --force *.rpm`来安装下载的所有包。 由于这些包之间存在依赖关系,所以需要使用`--force`参数来强制安装。 现在,你已经成功将RedHat 7.2更换为CentOS 7的yum源。你可以通过使用命令`rpm -qa | grep yum`来验证新的yum源已经安装成功。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Red hat7替换centos7Yum源](https://blog.csdn.net/qq_42956179/article/details/109618774)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [Redhat7更换centos7yum源方法步骤](https://blog.csdn.net/weixin_43837883/article/details/89179533)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值