centos creates a local yum repository

centos creates a local yum repository

  1. Create the relevant directories you need to use
    • /mnt/dvd1 and /mnt/dvd2 are used to mount centos images
    • /mnt/dvd3 Place the merged image file
    • /mnt/iso to place the original centos image file
    • mkdir -p /mnt/dvd1 /mnt/dvd2 /mnt/dvd3 /mnt/iso create directory command
  2. Upload the two dvd image files on the local machine to the centos server, and then mount them to the corresponding directories respectively
    • mount //local machine ip/shared directory name/centos server corresponding directory/centos -o username=local machine username, password=local machine password, nounix, noserverino
    • Copy the two original image files to the /mnt/iso directory
    • mount -o loop /mnt/iso/CentOS-6.5-x86_64-bin-DVD1.iso /mnt/dvd1
    • mount -o loop /mnt/iso/CentOS-6.5-x86_64-bin-DVD2.iso /mnt/dvd2
  3. copy file
    • First, copy all files under /mnt/dvd1 to /mnt/dvd3 directory, then, copy only all rpm files in Packages directory under /mnt/dvd2 to /mnt/dvd3/Packages directory
    • cp -av / mnt / dvd1 / * / mnt / dvd3 /
    • cp -av /mnt/dvd2/Packages/*.rpm / mnt / dvd3 / Packages /
  4. Merge TRANS.TBL
    • Append the information of TRANS.TBL in /mnt/dvd2 to the back of TRANS.TBL in /mnt/dvd1, and save in order
    • cat /mnt/dvd2/Packages/TRANS.TBL >> /mnt/dvd3/Packages/TRANS.TBL
    • mv /mnt/dvd3/Packages/{TRANS.TBL,TRANS.TBL.BAK}
    • sort /mnt/dvd3/Packages/TRANS.TBL.BAK > /mnt/dvd3/Packages/TRANS.TBL
    • rm -rf /mnt/dvd3/Packages/TRANS.TBL.BAK
    • /mnt/dvd3 is already a merged directory and can be used as a local yum source
  5. Backup YUM configuration file
    • cd /etc/yum.repos.d
    • rename .repo .repo.bak *.repo
  6. Generate a new YUM configuration file
    • vi /etc/yum.repos.d/CentOS-Media.repo
  7. Update YUM source
    • yum clean all
    • yum upgrade

YUM configuration file

[c6-media]
name=CentOS-\$releasevyum install glibc-staticer - Media
baseurl=file:///mnt/dvd3
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[c6-media]               #库名称
name=CentOS-$releasever - Media  #名称描述
baseurl=file:///media/centos/     #yum源目录,源地址
gpgcheck=1                #检查GPG-KEY,0为不检查,1为检查
enabled=1               #是否用该yum源,0为禁用,1为使用
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6  #gpgcheck=0时无需配置

Test whether the local yum source is valid

rpm -qa View installed rpm packages

yum install gcc
yum install gcc-c++

yum install glibc-static installs the static library of c
yum install boost boost-devel boost-doc installs boost

yum install kernel
yum install kernel-devel kernel-doc Install the kernel source code

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326045181&siteId=291194637