[Linux] createrepo 을 활용한 yum repository 서버 구축

  1. yum install -y createrepo 수행

    • 설치 되어 있다면 아래와 같은 메시지 출력

    [root@test ~]# yum install -y createrepo
    Failed to set locale, defaulting to C
    Loaded plugins: fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
    * base: centos.mirror.cdnetworks.com
    * extras: centos.mirror.cdnetworks.com
    * updates: ftp.iij.ad.jp
    Package createrepo-0.9.9-28.el7.noarch already installed and latest version
    Nothing to do
    [root@test ~]#
  2. repository 로 사용할 directory 생성 후 createrepo <directory>

    • 정상 실행되었다면 /yumrepo/repodata/repomd.xml 파일이 생성 됨

    • /yumrepo/내 directory를 Client 에서 repolist 로 추가하여 사용 가능

    root@test ~]# mkdir /yumrepo
    root@test ~]# createrepo /yumrepo
    Saving Primary metadata
    Saving file lists metadata
    Saving other metadata
    Generating sqlite DBs
    Sqlite DBs complete
    [root@test ~]#
  3. 외부에서 repolist 접속을 위한 Apache httpd 설치

    • yum install -y httpd

    • /etc/httpd/conf.d/httpd.conf 파일을 내 "/var/www/html" 구문 삭제

      DocumentRoot "/var/www/html"

      #
      # Relax access to content within /var/www.
      #
      <Directory "/var/www">
        AllowOverride None
        # Allow open access:
        Require all granted
      </Directory>
    • /etc/httpd/conf.d/httpd.conf 파일을 내 아래 문구 추가

      DocumentRoot "/yumrepo"
      <Directory "/yumrepo">
        AllowOverride None
        Require all granted
      </Directory>
    • httpd daemon 재기동

      systemctl restart httpd
    • curl http://localhost/repodata/repomd.xml 로 웹서버 상태 확인

      [root@test conf]# curl http://localhost/repodata/repomd.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <repomd xmlns="http://linux.duke.edu/metadata/repo" xmlns:rpm="http://linux.duke.edu/metadata/rpm">
      <revision>1539673159</revision>
      <data type="filelists">
      <checksum type="sha256">401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93</checksum>
      <open-checksum type="sha256">bf9808b81cb2dbc54b4b8e35adc584ddcaa73bd81f7088d73bf7dbbada961310</open-checksum>
      <location href="repodata/401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93-filelists.xml.gz"/>
      <timestamp>1539673159</timestamp>
      ... 생략 ...

  4. 이후 /yumrepo/ 내 rpm 등을 업로드 후 yum repo client 에서 추가하면 된다.


다른 카테고리의 글 목록

Linux 카테고리의 포스트를 톺아봅니다