• Membuat Ubuntu Mirror Repository Dengan Rsync

    Suatu hari saya ingin membuat repository local sendiri dikarenakan ada banyak mesin ubuntu yang saya gunakan dan tidak praktis rasanya kalau harus menunggu donwload program yang saya gunakan via internet setiap melakukan instalasi. Internet yang saya gunakan memang tidak cepat sehingga membikin repot saat harus menginstall program. Sementara itu, koneksi di kampus sangat cepat yang bisa saya manfaatkan untuk membuat mirror repository.

    Saya berkeinginan membuat server repository local agar saat saya dirumah tidah harus mendownload kembali via internet, sehingga linux saya yang lain tinggal hanya mendownload dari laptop saya yang sudah saya sulap menjadi sebuah repository. Untuk membuar repository mirror, cara-caranya adalah seperti dibawah ini :

    1. Install aplikasi debmirror

    apt-get install debmirror

    2. Membuat direktori yang menampung file-file repository

    mkdir -p /mirror/ubuntu

    3. Setting permission folder /mirror/ubuntu

    sudo chown -R anjarwebid:anjarwebid /mirror/ubuntu
    sudo chmod -R 771 /mirror/ubuntu

    4. Konfigurasi keyring

    Buatlah folder yang akan menampung keyring

    mkdir /home/anjarwebid/mirrorkeyring

    jalankan command dibawah ini untuk import keyring

    gpg --no-default-keyring --keyring /home/anjarwebid/mirrorkeyring/trustedkeys.gpg --import /usr/share/keyrings/ubuntu-archive-keyring.gpg

    5. Membuat file untuk menjalankan rsync (mirroring) dari server repository yang lain

    nano /home/anjarwebid/mirrorbuild.sh

    6. Isikan file mirrorbuild.sh dengan code dibawah ini

    # --------------------------------------------
    # BEGIN MIRRORBUILD.SH SCRIPT
    # --------------------------------------------
     
    #!/bin/bash
     
    ## Setting variables with explanations.
     
    #
    # Don't touch the user's keyring, have our own instead
    #
    export GNUPGHOME=/home/anjarwebid/mirrorkeyring
     
    # Arch=         -a      # Architecture.
    # For Ubuntu can be i386, amd64, powerpc and/or sparc (sparc support begins with dapper)
    #
    # Comma separated values
    arch=i386,amd64
     
    # Minimum Ubuntu system requires main, restricted
    # Section=      -s      # Section
    # (One of the following - main/restricted/universe/multiverse).
    # You can add extra file with $Section/debian-installer.
    # ex: main/debian-installer,universe/debian-installer,multiverse/debian-installer,restricted/debian-installer
    section=main,restricted,universe,multiverse
     
    # Release=      -d      # Release of the system
    # (Dapper, Edgy, Feisty, Gutsy, Hardy, IntrepidJaunty, Karmic),
    # and the -updates and -security ( -backports can be added if desired)
    dist=oneiric,oneiric-updates,oneiric-security
     
    # Server=       -h      # Server name,
    # minus the protocol and the path at the end
    # CHANGE "*" to equal the mirror you want to create your
    # mirror from. au. in Australia  ca. in Canada. This can be
    # found in your own /etc/apt/sources.list file,
    # assuming you have Ubuntu installed.
    server=us.archive.ubuntu.com
     
    # Dir=          -r      # Path from the main server,
    # so http://my.web.server/$dir, Server dependant
    # Lead with a '/' for everything but rsync,
    # where we lead with a ':'
    inPath=:ubuntu
     
    # Proto=        -e      # Protocol to use for transfer
    # (http, ftp, hftp, rsync)
    # Choose one - http is most usual the service, and the
    # service must be availabee on the server you point at.
    # NOTE: debmirror uses -aIL --partial by default.
    #       However, if you provide the --rsync-options
    #       paramter (which we do) then you HAVE to provide
    #       it -aIL --partial in addition to whatever You
    #       want to add (e.g. --bwlimit) If you don't
    #       debmirror will exit with thousands of files
    #       missing.
    proto=rsync
    rsyncoptions="-aIL --partial --bwlimit=100"
     
    # Outpath=              # Directory to store the mirror in
    # Make this a full path to where you want to mirror the material.
    #
    outPath=/mirror/ubuntu/
     
    # The --nosource option only downloads debs and not deb-src's
    # The --progress option shows files as they are downloaded
    # --source \ in the place of --no-source \ if you want sources also.
    # --nocleanup  Do not clean up the local mirror after mirroring
    # is complete. Use this option to keep older repository
    # Start script
    #
    debmirror       -a $arch \
                    --no-source \
                    -s $section \
                    -h $server \
                    -d $dist \
                    -r $inPath \
                    --progress \
                    -e $proto \
                    --rsync-options="$rsyncoptions" \
                    $outPath
     
    # -----------------------------------------------------
    # END BUILDMIRROR.SH SCRIPT
    # -----------------------------------------------------

    Pada code diatas ada bagian yang saya bold itu pertanda yang harus anda sesuaikan dengan kebutuhan anda.

    > arch, anda bisa mensetting arsitektur repository linux yang akan anda buat apakah 32bit, 64bit atau keduanya.

    > dist, bisa mengatur versi release apa saja yang akan anda buat

    > server, bisa mengatur server mana yang akan di-mirror dengan server anda, untuk server indonesia saya biasa menggunakan server UGM dan UI.

    > rsyncoptions , yang paling penting dari konfigurasi ini adalah bwlimit karena akan membatasi berapa bandwidth maksimal yang anda gunakan untuk rsync respository. Defaultnya ada pada 100KBps

    Setelah itu save file tersebut

    7. Menambahakan permission mirrorbuild.sh agar executable

    chmod +x mirrorbuild.sh

    8. Melakukan sinkronisasi melalui rsync

    ./mirrorbuild.sh

    Proses ini bisa menjadi sangat lama tergantung koneksi yang anda gunakan. Untuk oneiric saja ukurannya sekitar 50GB, jika koneksi kurang mendukung mungkin bisa menjadi berhari-hari bahkan berminggu-minggu.

    9. Setelah proses sinkronisasi selesai, tahap selanjutnya adalah membuat agar file-file yang sudah kita download bisa dibukan via web browser dan dapat digunakan sebagai repository. Caranya adalah dengan menggukanan apache server.

    apt-get install apache2

    10. Membuat symlink antara /var/www/ubuntu dan /mirror/ubuntu

    sudo ln -s /mirror/ubuntu /var/www/ubuntu

    11. Untuk melakukan update secara otomatis tambahkan code dibawah ini untuk dimasukkan ke cron

    crontab -e

    Setelah itu pilih editor nomor 2 (biasanya nano)

    dan tambahkan code dibawah ini

    * 1 * * 0 /home/anjarwebid/mirrorbuild.sh

    pada setting diatas saya melakukan update otomatis setiap minggu, yaitu pada hari minggu jam 1 pagi.

    12. Untuk konfigurasi client bisa seperti biasanya, contohnya adalah seperti yang dibawah ini:

    deb http://172.16.128.130/ubuntu/ oneiric main restricted universe multiverse
    deb http://172.16.128.130/ubuntu/ oneiric-updates main restricted universe multiverse
    deb http://172.16.128.130/ubuntu/ oneiric-security main restricted universe multiverse

    13. Selesai, silahkan mencoba repo buatan anda sendiri

    Terima kasih sudah disempatkan membaca dan mampir ke blog saya, :)

    Tags: 
    Share/Save

    Comments

    Add new comment

    Plain text

    • No HTML tags allowed.
    • Web page addresses and e-mail addresses turn into links automatically.
    • Lines and paragraphs break automatically.
    Type the characters you see in this picture. (verify using audio)
    Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.