Test configuring the HTTP image for the Yum repository

Source: Internet
Author: User
Tags gpg rsync

Test configuring the HTTP image for the Yum repository


First, the basic Environment 1, on the basis of tvm-base, copy an image for Tvm-yum to test. 2, Network: eth0:host-only (for virtual intranet, manually fixed IP, so from the host can directly connect to this VM) Eth1:nat (for Sisu network, dynamic IP) [[email protected] ~]#  cd /etc/sysconfig/network-scripts/[[email protected] network-scripts]# cat  ifcfg-eth0device=eth0type=ethernetonboot=yesnm_controlled=yesbootproto=noneipaddr=192.168.56.254prefix= 24gateway=192.168.56.1[[email protected] network-scripts]# cat ifcfg-eth1device=eth1type= ethernetonboot=yesnm_controlled=yesbootproto=dhcp[[email protected] ~]# ip a s  dev eth0 |grep global    inet 192.168.56.254/24 brd  192.168.56.255 scope global eth0[[email protected] ~]# ip a s dev  eth1 |grep global     inet 10.0.3.15/24 brd 10.0.3.255  scope global eth1[[email protected] ~]# route -nkernel ip routing tabledestination     gateway          Genmask         Flags Metric Ref     Use Iface10.0.3.0        0.0.0.0          255.255.255.0   u     0       0        0 eth1192.168.56.0     0.0.0.0         255.255.255.0    U     0      0         0 eth0169.254.0.0     0.0.0.0          255.255.0.0     U     1002    0        0 eth0169.254.0.0     0.0.0.0          255.255.0.0     U     1003    0        0 eth10.0.0.0          10.0.3.2        0.0.0.0          UG    0      0  &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;0&NBSP;ETH12, Preliminary plan is: Yum Warehouse, in the hosts configuration to join:192.168.56.254  Mirrors.office.test then access the Yum repository: Http://mirrors.office.test/centos next needs: 1) Configure a local yum  image, and timing from the public network mirrors synchronization data. Note 1: The i386 directory is not required, only the x86_64 version is used here. Note 2: The ISOs directory is not required and the ISO file is stored in it. 2) Configure an HTTP service. 3) Provide the Local-office.repo file for the client. Ii. Configure directories and scripts to create a local yum image [[Email protected] ~]# mkdir -p /data/yum/repo/centos/ /data /DOWNLOAD/&NBSP;/DATA/OPS/BIN/1, Upload centos6.5-x64 of ISO files to/data/download/[[email protected] ~]# ls /data/download/centos-6.5-x86_64- Bin-dvd1.iso  centos-6.5-x86_64-bin-dvd2.iso[[email protected] ~]# mkdir -p  /data/yum/repo/centos/6/os/x86_642, synchronizing the contents of the ISO file: [[Email protected] ~]# mount -ro  loop /data/download/CentOS-6.5-x86_64-bin-DVD1.iso /mnt[[email protected] ~]#  rsync -avhps /mnt/ /data/yum/repo/centos/6/os/x86_64/[[email protected] ~]#  umount /mnt[[email protected] ~]# mount -ro loop /data/download/ centos-6.5-x86_64-bin-dvd2.iso /mnt[[email protected] ~]# rsync -avhps /mnt/  /data/yum/repo/centos/6/os/x86_64/[[email protected] ~]# umount /mnt3, choose a mirrors, Synchronize from mirrors through scripts. To find a list of mirrors: http://www.centos.org/download/mirrors/Here I chose an image that supports the Rsync protocol: http://mirrors.hust.edu.cn/centos/ Note 3: Currently the latest version is centos6.6, so, in fact, after the synchronization, this warehouse version is 6.6,Make a soft connection,6 -> 6.6[[email protected] ~]# ln -s /data/yum/repo/centos/6  /data/yum/repo/centos/6.6 start syncing [[email protected] ~]# rsync -avzp --delete -- delete-excluded --exclude  "local*"  --exclude  "ISOs"  --exclude  "i386"    rsync://mirrors.hust.edu.cn/centos/6/ /data/yum/repo/centos/6/Three, configure HTTP mode to access Yum image 1, Firewall release 80 port 2, Configure HTTPD service 1) If SELinux is not disabled, this should be configured: [[Email protected] ~]# chcon -rv --type=httpd_sys_ CONTENT_T&NBSP;/DATA/YUM/REPO/2) Configure HTTPD service: [[email protected] ~]# cat /etc/httpd/conf/ httpd.conf |grep servername |grep ^[^#]servername 127.0.0.13) Configuring the virtual host [[email  protected] ~]# mv /etc/httpd/conf.d/welcome.conf /tmp/[[email protected] ~]#  cat /etc/httpd/conf.d/mirrors.office.test.conf <VirtualHost *:80>     serveradmin [email protected]    servername mirrors.office.test    documentroot /data/ yum/repo        errorlog logs/mirrors.office.test-error_log     CustomLog logs/mirrors.office.test-access_log common    < directory /data/yum/repo>        options indexes  followsymlinks        allowoverride none         order allow,deny        allow from  all    </directory></virtualhost>3, starting httpd service [[email protected]  ~]# chown -R apache:apache /data/yum/repo[[email protected] ~]#  SERVICE&NBSP;HTTPD&NBSP;START4, test host configuration Hosts file: 192.168.56.254 mirrors.office.test Access:/http Mirrors.office.test/centos Grasping package information: [[Email protected] ~]# curl -o /dev/null -v -i http://mirrors.office.test/centos/*  about to connect ()  to mirrors.office.test port 80  (#0) *    Trying 192.168.56.254... connected* Connected to mirrors.office.test  ( 192.168.56.254)  port 80  (#0) > head /centos/ http/1.1> user-agent:  curl/7.19.7  (X86_64-REDHAT-LINUX-GNU)  libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3  libidn/1.18 libssh2/1.4.2> host: mirrors.office.test> accept: */*> <  HTTP/1.1 200 OK< Date: Tue, 14 Jul 2015 02:32:14 GMT<  Server: Apache/2.2.15  (CentOS) < Connection: close< Content-Type:  text/html;charset=utf-8<   % total    % received %  Xferd  average&nbsP Speed   time    time     time  current                                   Dload   Upload   total   spent    left  speed  0      0    0     0     0     0      0       0 --:--:-- --:--:-- --:--:--     0* closing connection   #0chrome抓包信息: remote address:192.168.56.254:80request url:http://mirrors.office.test/centos/ Request method:getstatus code:200 okremote address:192.168.56.254:80request url:http ://mirrors.office.test/centos/request method:getstatus code:200 ok Four, provide Local-office.repo file 1, existing directory: [[email protected]  ~]# ls /data/yum/repo/centos/6/centosplus  cloud  contrib  cr   extras  fasttrack  os  scl  updates  xen42, local-office.repo[[email protected] ~]# cat /etc/yum.repos.d/local-office.repo #  local-office.repo# 2015/7/14#  update Centos-base.repo to its own mirror, and the rest of the repo is removed. # -  contains the RPM package in the underlying OS [base]name=centos-$releasever  - basebaseurl=http://mirrors.office.test/ centos/$releasever/os/$basearch/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-6#released  updates -  contains packages that can be updated [updates]name=centos-$releasever  - updatesbaseurl=http:// mirrors.office.test/centos/$releasever/updates/$basearch/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/ Rpm-gpg-key-centos-6#additional packages that may be useful -  contains additional packages [extras]name=centos-$releasever  - extrasbaseurl=http://mirrors.office.test/ centos/$releasever/extras/$basearch/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-6#additional  packages that extend functionality of existing packages -  Packages that include feature extensions [centosplus]name=centos-$releasever  - plusbaseurl=http://mirrors.office.test/centos/$ releasever/centosplus/$basearch/gpgcheck=1enabled=0gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-6#contrib  - packages by Centos Users -  packages that contain user contributions [contrib]name=centos-$releasever  - contribbaseurl=http://mirrors.office.test/centos/$releasever/contrib/$basearch/gpgcheck=1enabled= 0gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-6 Five, etc. mirros after the synchronization is complete, the test starts 1, the native test clears the cache first: [[[Email protected]  ~]# yum clean allLoaded plugins: fastestmirror, securityCleaning  Repos: base extras updatesCleaning up everythingcleaning up list of fastest mirrors try to update the system: [[Email  protected] ~]# yum update (slightly) (369/369): yum-utils-1.1.30-30.el6.noarch.rpm                                   | 110 kB      00:00     --------------------------------------------------- --------------------------------------------------total                                                                     16 mb/s  | 430 mb     00:26     running rpm_check_ Debugrunning transaction testtransaction test succeededrunning transaction (slightly)    yum.noarch 0:3.2.29-60.el6.centos                                                                        yum-plugin-fastestmirror.noarch 0:1.1.30-30.el6                                                         yum-plugin-security.noarch 0:1.1.30-30.el6                                                               yum-utils.noarch 0:1.1.30-30.el6                                                                       Replaced:  libsss_autofs.x86_64 0:1.9.2-129.el6                                                                   complete! [[email protected] ~]# [[email protected] ~]# cat /etc/issuecentos  release 6.6  (Final) kernel \r on an \m2, look, has been upgraded to 6.6 version, recommended reboot first. Before reboot, the HTTPD service should be added to boot. [[email protected] centos]# chkconfig httpd on[[email protected] centos]#  chkconfig --list |grep httpdhttpd            0:off   1:off   2:on    3:on     4:on    5:on    6:off[[email protected] ~]# cp  /etc/Yum.repos.d/local-office.repo /data/yum/repo/centos/[[email protected] ~]# chown -r  apache:apache /data/yum/repo/centos/updated the CentOS-related repo file in/etc/yum.repos.d/after upgrading the system with update, So after rebooting you can consider removing [[EMAIL&NBSP;PROTECTED]&NBSP;~]#&NBSP;MV&NBSP;CENTOS-*&NBSP;/ETC/YUM.REPOS.D/&NBSP;/TMP/3, configuring the script synchronization, and put it in crontab to execute [[email protected] ~]# cat /data/ops/bin/repo_update.sh   .  #!/bin/bash## 2015/7/14if [ -f /var/lock/subsys/repo_update ]; then     echo  "[' Date '] yum repo update via rsync is already  running. "     exit 0fiif [ -d /data/yum/repo/centos/6 ]; then     touch /var/lock/subsys/repo_update    rsync -avzp -- delete --delete-excluded --exclude  "local*"  --exclude  "ISOs"  --exclude  " I386 "  rsync://mirrors.hust.edu.cn/centos/6/ /data/yum/repo/centos/6/    rm /var/lock/subsys/ repo_updateelse    echo  "[' Date '] [error] dir not proesent:  /DATA/YUM/REPO/CENTOS/6 "Fichown -r apache:apache /data/yum/repo into crontab [[email protected ] ~]# cat <<_ntp >>/var/spool/cron/$ (WhoAmI) # repo update0 4  * * * /bin/bash /data/ops/bin/repo_update.sh >/tmp/repo.log 2>&1 &NBSP;&AMP;_NTP Six, TODO1, join the Epel source [[email protected] ~]# rpm -uvh http:// dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm[[email protected] ~]# yum  Makecache2, client uses Local-office.repo file [[email protected] ~]# mv /etc/yum.repos.d/centos*  /tmp/ && echo  ' 192.168.56.254 mirrors.office.test '  >> /etc/ Hosts && wget http://mirrors.office.test/centos/local-office.repo -o /etc/yum.repos.d/local-office.repo & & yum makecach[[email protected] ~]# yum update meets expectations. Zyxw, reference 1, creating a local repo  (Mirror)  with centos 6.2+http:// DARKTRAINING.COM/93/2, creating local mirrors for updates or installshttps:// Wiki.centos.org/howtos/createlocalmirror3, list of centos mirrorshttp://www.centos.org/download/ MIRRORS/4, How to set up and use yum repositories on a centos  6 vpshttps://www.digitalocean.com/community/tutorials/ How-to-set-up-and-use-yum-repositories-on-a-centos-6-vps


Test configuring the HTTP image for the Yum repository

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.