CentOS 6.* 配置本地网络 yum源

CentOS 6.* 配置本地网络yum源

一台服务时只需要配一个本地的yum源即可;
当需要配置多台服务器时,只需要配置1到2台vsftpd的yum源,其它服务器通过ftp连接yum源;

1 基于本地文件的yum源

1.1 下载镜像源

wget -b  https://mirrors.aliyun.com/centos/6.10/isos/x86_64/CentOS-6.10-x86_64-bin-DVD1.iso
tail -100f wget-log

1.2 挂载iso镜像文件

ll /mnt         # 确保/mnt目录下没有文件;
mount -o loop CentOS-6.5-x86_64-bin-DVD1.iso  /mnt

或者挂载光驱

mount /dev/cdrom? /mnt

1.3 修改yum源配置

[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# mv CentOS-Base.repo{,_bak}
[[email protected] yum.repos.d]# cp -a CentOS-Media.repo{,_bak}
[[email protected] yum.repos.d]# vim CentOS-Media.repo

修改内容如下:

[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
        file:///media/cdrom/
        file:///media/cdrecorder/
gpgcheck=0                  # 关闭校验
enabled=1                   # 启用
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

1.4 复制镜像文件内容到指定路径下

复制镜像文件内容到/etc/yum.repos.d/CentOS-Media.repo配置文件里写的路径下:

cp -a /mnt/*  /media/CentOS/

1.5 清除缓存并测试(可选)

  • 清除缓存
yum clean all
  • 生成缓存
yum makecache
  • 测试
yum install lrzsz -y

2 基于vsftp的yum源

2.1 vsftpd服务端

  • 执行1.1和1.2的步骤

2.1.1 安装vsftpd服务

  • 去镜像挂载目录下安装vsftpd服务:
cd /mnt/Packages/
rpm -ivh lrzsz-0.12.20-27.1.el6.x86_64.rpm
  • 修改vsftpd的配置文件

修改ftp的根目录只要修改/etc/vsftpd/vsftpd.conf文件即可:

cp -a /etc/vsftpd/vsftpd.conf{,_$(date +%F)}
vim /etc/vsftpd/vsftpd.conf

加入如下内容:

anon_root=/var/ftp/
local_root=/var/ftp/
chroot_local_user=YES

注:local_root 针对系统用户;
? ? anon_root 针对匿名用户。

  • 启动vsftpd
service vsftpd start
  • 设置开机自启动
chkconfig vsftpd on
chkconfig --list|grep vsftpd

2.1.2 修改yum源配置

[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# mv CentOS-Base.repo{,_bak}
[[email protected] yum.repos.d]# cp -a CentOS-Media.repo{,_bak}
[[email protected] yum.repos.d]# vim CentOS-Media.repo

修改内容如下:

[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///var/ftp/pub/centos6

gpgcheck=0                  # 关闭校验
enabled=1                   # 启用
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

创建相应目录

mkdir -pv /var/ftp/pub/centos6

2.1.3 复制镜像文件内容到指定路径下

复制镜像文件内容到/etc/yum.repos.d/CentOS-Media.repo配置文件里写的路径下:

cp -a /mnt/* /var/ftp/pub/centos6

2.2 ftp客户端

2.2.1 修改yum源配置

[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# mv CentOS-Base.repo{,_bak}
[[email protected] yum.repos.d]# cp -a CentOS-Media.repo{,_bak}
[[email protected] yum.repos.d]# vim CentOS-Media.repo

修改内容如下:

[c6-media]
name=CentOS-$releasever - Media

baseurl=ftp://192.168.1.101/pub/centos6
gpgcheck=0                  # 关闭校验
enabled=1                   # 启用
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

假设vsftpd服务端的IP为:192.168.1.101

2.2.2 清除缓存并测试(可选)

  • 清除缓存
yum clean all
  • 生成缓存
yum makecache
  • 测试
yum install lrzsz -y

3 配置阿里源

3.1 Yum源更换为阿里源

yum install wget telnet -y
mv /etc/yum.repos.d/CentOS-Base.repo{,_$(date +%F)}
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

3.2 添加阿里的epel源

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

3.3 重新生成缓存

yum clean all
yum makecache

END

原文地址:http://blog.51cto.com/moerjinrong/2330693

时间: 2024-08-08 21:50:41

CentOS 6.* 配置本地网络 yum源的相关文章

Linux配置本地网络YUM源

配置环境: 系统版本: [[email protected] ~]# cat /etc/issue Red Hat Enterprise Linux Server release 5.8 (Tikanga) Kernel \r on an \m 系统32位: [[email protected] ~]# getconf LONG_BIT 32 YUM源服务器,IP:192.168.2.1 YUM客户端,IP:192.168.2.2 一.配置本地YUM源服务器: 挂在光盘: [[email pro

centos6配置本地光盘yum源、rhel7修改网卡名称为eth0

VMware安装好centos/rhel后要配置的几点(配置本地光盘yum源.修改网卡名称为eth0等) [[email protected] ~]# setenforce 0 [[email protected] ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config [[email protected] ~]# tar zcvf /root/redhat.repo.tgz /etc/yum.repos.d/

CentOS配置163网络yum源

在安装完CentOS后一般需要修改yum源,才能够在安装更新rpm包时获得比较理想的速度.国内比较快的有163源.sohu源.这里以163源为例子. 1. cd /etc/yum.repos.d 2. mv CentOS-Base.repo CentOS-Base.repo.backup 3. wget http://mirrors.163.com/.help/CentOS6-Base-163.repo 4. mv CentOS6-Base-163.repo CentOS-Base.repo 5

[Linux] 024 IP 地址配置和网络 yum 源

1. IP 地址配置 (1) 使用 setup 工具 $ setup ps setup 是 RedHat 系列的功能:一般地,Debian系列没有这个功能 Xubuntu 没有这个功能 (2) 启动网卡 step1 $ vi /etc/sysconfig/network-scripts/ifcfg-eth0 step2 把 ONBOOT = "no" 改为 ONBOOT = "yes" step3 重启网络服务 $ service network restart p

linux 之软件包管理 (四) IP地址配置和网络yum源简介

yum并不一定需要联网,可以使用光盘做为yum源 在red Hat 里面使用yum需要付费,在cent os不需要! 1先使用setup命令: 网络yum源 yum源文件含义:

在Centos6.5中配置国内网络yum源以及本地yum源

一.本地yum     1.       创建目录.挂载光盘以及安装createrepo [[email protected] ~]# mkdir/mnt/cdrom                  ←用于挂载光盘 [[email protected] ~]# mkdir-vp /yum/localrepo    ←用于存放光盘中的rpm包 mkdir: 已创建目录 "/yum" mkdir: 已创建目录 "/yum/localrepo" [[email prot

CentOS 6.5配置本地DVD yum 源

[[email protected] yum.repos.d]# cat /etc/redhat-releaseCentOS release 6.5 (Final) [[email protected] yum.repos.d]# uname -aLinux centos06 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux [[email protected] yum

RPM包管理-yum在线管理-IP地址配置和网络yum源

[[email protected]~]#setup #使用setup工具 1.选择网络配置 2.设备设置 3.选择第一块网卡.按回车进入设置 4.取消"*"号.设置内容为下 查看网络本地状态 ip需同一ip下

oracle linux配置本地光盘yum源

mkdir -p /mnt/cdrom/ mount /dev/sr0 /mnt/cdrom [[email protected] yum.repos.d]# cat local.repo [Server] name=Server baseurl=file:///mnt/cdrom enabled=1 gpgcheck=0 验证yum [[email protected] yum.repos.d]# yum repolist Loaded plugins: langpacks, ulninfo