Membuat Repository Lokal CentOS

by Novan Fauzi (Engineer), novan@dev.netkromsolution.com

Server Ubuntu 16.04 sebagai repository CentOS

Berikut ini adalah cara membuat repository lokal CentOS pada sistem operasi Ubuntu 16.04.

Pertama-tama kita akan membuat server repository. Siapkan sebuah server dengan sistem operasi Linux Ubuntu 16.04, kemudian lakukan lakukan langkah-langkah berikut ini:

  1. Install paket yang dibutuhkan
apt install createrepo yum-utils

2. Buat struktur folder yang digunakan untuk menyimpan repo

cd /var/www
mkdir yum-mirror
cd /yum-mirror
mkdir -p centos/7/os/x86_64/ centos/7/updates/x86_64/ centos/7/extras/x86_64/

3. Buat config file untuk repository CentOS

nano /etc/yum/repos.d/centos.repo

Masukan script berikut ini pada file tersebut

[os]
name=CentOS-7 - Base
baseurl=http://mirror.buana.web.id/centos/7/os/x86_64
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-7 - Updates
baseurl=http://mirror.buana.web.id/centos/7/updates/x86_64
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-7 - Extras
baseurl=http://mirror.buana.web.id/centos/7/extras/x86_64
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

4. Buat juga config file untuk EPEL

nano /etc/yum/repos.d/epel.repo

Masukan script berikut ini pada file tersebut

[epel]
name=Extra Packages for Enterprise Linux 7
baseurl=https://dl.fedoraproject.org/pub/epel/7/x86_64/
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

5. Bila ingin menggunakan mirror repository lain bisa di cek melalui situs resmi CentOS: https://www.centos.org/download/mirrors/

6. Lalu buat schedule agar repository selalu update, buat file pada crondaily

nano /etc/cron.daily/repo-sync

Masukan script berikut ini pada file tersebut

# Sync CentOS and EPEL repos
reposync -c /etc/yum/yum.conf -n -d -g comps.xml --download-metadata --norepopath -r os --download_path=/var/www/yum-mirror/centos/7/os/x86_64
reposync -c /etc/yum/yum.conf -n -d --download-metadata --norepopath -r updates --download_path=/var/www/yum-mirror/centos/7/updates/x86_64
reposync -c /etc/yum/yum.conf -n -d --download-metadata --norepopath -r extras --download_path=/var/www/yum-mirror/centos/7/extras/x86_64
reposync -c /etc/yum/yum.conf -n -d -g comps.xml --download-metadata --norepopath -r epel --download_path=/var/www/yum-mirror/epel/7/x86_64

# Build CentOS repo metadata
createrepo --update --workers=4 /var/www/yum-mirror/centos/7/os/x86_64/
createrepo --update --workers=4 /var/www/yum-mirror/centos/7/updates/x86_64/
createrepo --update --workers=4 /var/www/yum-mirror/centos/7/extras/x86_64/
createrepo --update --workers=4 /var/www/yum-mirror/epel/7/x86_64/

7. Disana terdapat –workers=4,ubah value ini dan sesuaikan dengan banyak core yang terdapat pada server Ubuntu yang digunakan.

8. Buat script tadi executable

Chmod 755 /etc/cron.daily/repo-sync

9. Lalu jalankan perintah repo-sync ini

/etc/cron.daily/repo-sync

Jika terjadi error, kembali ke langkah 3, ubah gpgcheck=1 menjadi gpgcheck=0, kemudian ulangi lagi perinta repo-sync (langkah 9). Untuk repo-sync ini kita sedang mendownload paket yang berada pada mirror, ini memang agak lama sesuai dengan kecepatan download

10. Jika sinkronisasi sudah selesai, install Apache

apt-get install apache2

11. Lalu coba test apakah Apache running dengan menggunakan web browser (dari komputer lain di jaringan) dan buka http://<ip server Ubuntu>. Jika muncul tampilan Welcome to Apache, kita ubah document root menuju ke repository dengan cara mengedit file config

nano /etc/apache2/apache.conf

Pada file tersebut, carilah

<Directory /var/www/html>
Option Index FollowSymLinks
AllowOverride None
Require all granted
</Directory>

Lalu ubah bagian script tersebut menjadi seperti ini:

<Directory /var/www/yum-mirror>
Option Index FollowSymLinks
AllowOverride None
Require all granted
</Directory>

12. Selanjutnya, edit file 000-default.conf

nano /etc/apache2/sites-available/000-default.conf

Cari DocumentRoot /var/www/html, ubah menjadi DocumentRoot /var/www/yum-mirror

13. Kemudian, reload dan restart Apache2

sudo apache2 reload
/etc/init.d/apache2 restart

Demikianlah langkah-langkah untuk membuat server repository lokal CentOS menggunakan sistem operasi Ubuntu 16.04. Untuk mengetahui cara konfigurasi di client (CentOS) agar menggunakan repository lokal yang telah dibuat, klik tombol berikut ini:

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Open chat
Haii, ada yang bisa kami bantu?