Membuat Lokal Repository HTTP Menggunakan CentOS
Kali ini saya akan sharing gimana caranya bikin lokal repository menggunakan HTTP di CentOS.
Nah apa sih keuntungan pake lokal repository?
- Lebih cepat karna paket2 ada di lokal server/network anda sendiri
- Bisa digunakan apabila server anda tidak terkoneksi ke internet.
Begini cara membuat lokal repository yum dengan memanfaatkan protokol HTTP.
[PREREQUIREMENT/NOTES]
- Dalam tutorial ini status iptables saya adalah mati, untuk matiinnya gunakan command/etc/init.d/iptables stop atau systemctl stop firewalld kalo di CentOS 7
- Status selinux saya juga disabled, untuk mengeceknya gunakan command getenforce. Untuk disabled gunakan command setenforce 0. Untuk disabled persistent edit file /etc/selinux/config
- IP Address yang digunakan 192.168.99.103
1) Download ISO Centos OS
Anda bisa langsung aja cekidot URL http://kambing.ui.ac.id/iso/centos/6.4/isos/x86_64/CentOS-6.4-x86_64-bin-DVD1.iso
[NOTES] :
Apabila server anda terkoneksi dengan internet bisa langsung menggunakan command dibawah ini.
wget http://kambing.ui.ac.id/iso/centos/6.4/isos/x86_64/CentOS-6.4-x86_64-bin-DVD1.iso
2) Upload ISO ke server yang ingin dijadikan Repository Lokal anda.
Pada contoh ini saya upload ke direktory /home/student/iso
[[email protected] iso]# ll /home/student/iso/
total 11737924-rw-rw-r-- 1 student student 6942410752 Oct 14 21:57 CentOS-6.4-x86_64-bin-DVD1.iso
drwxrwxr-x 14 student student 4096 Oct 13 20:28 vcenter
-rw-rw-r-- 1 student student 2997100544 Oct 13 20:24 win2008-r2-x64.iso
-rw-rw-r-- 1 student student 4283871232 Oct 14 21:05 WindowsServer2012R2.ISO
3) Buat direktori untuk mount ISO yang telah di download
[[email protected] ~]# mkdir /mnt/iso
[[email protected] iso]# mount -o loop CentOS-6.4-x86_64-bin-DVD1.iso /mnt/iso/
Cek direktori /mnt/iso apakah sudah termounting terutama direktori Packages
[ro[email protected] ~]# ll -h /mnt/iso/
total 676K-r--r--r-- 2 root root 14 Mar 6 2013 CentOS_BuildTag
dr-xr-xr-x 3 root root 2.0K Mar 5 2013 EFI
-r--r--r-- 2 root root 212 Mar 3 2013 EULA
-r--r--r-- 2 root root 18K Mar 3 2013 GPL
dr-xr-xr-x 3 root root 2.0K Mar 5 2013 images
dr-xr-xr-x 2 root root 2.0K Mar 5 2013 isolinux
dr-xr-xr-x 2 root root 634K Mar 6 2013 Packages
-r--r--r-- 2 root root 1.4K Mar 3 2013 RELEASE-NOTES-en-US.html
dr-xr-xr-x 2 root root 4.0K Mar 6 2013 repodata
-r--r--r-- 2 root root 1.7K Mar 3 2013 RPM-GPG-KEY-CentOS-6
-r--r--r-- 2 root root 1.7K Mar 3 2013 RPM-GPG-KEY-CentOS-Debug-6
-r--r--r-- 2 root root 1.7K Mar 3 2013 RPM-GPG-KEY-CentOS-Security-6
-r--r--r-- 2 root root 1.7K Mar 3 2013 RPM-GPG-KEY-CentOS-Testing-6
-r--r--r-- 1 root root 3.4K Mar 6 2013 TRANS.TBL
Dari output diatas terlihat bahwa ISO sukses dimounting dan sudah ada direktori Packages.
4) Install HTTP buat direktory repo lalu create direktori tersebut sebagai repo
[[email protected] ~]# yum install httpd -y
Matikan IPTABLES
[[email protected] ~]# /etc/init.d/iptables stop
Buat direktori repo didalam /var/www/html
[[email protected] ~]# mkdir /var/www/html/repo
Copy file dari /mnt/iso/Packages ke /var/www/html/repo
[[email protected] ~]# cp /mnt/iso/Packages/* /var/www/html/repo/
Install Packages Createrepo
[[email protected] ~]# cd /var/www/html/repo/
[[email protected] repo]# rpm -ivh createrepo-0.9.9-17.el6.noarch.rpm
[[email protected] repo]# cd
Build direktori /var/www/html/repo sebagai repository baru anda dengan command createrepo
[[email protected] ~]# createrepo -v /var/www/html/repo/
Buat persistent service httpd anda lalu start/restart service httpd.
[[email protected] ~]# chkconfig httpd on
[[email protected] ~]# /etc/init.d/httpd start
5) Pointing Repository Setelah semua proses diatas, selesai anda harus melakukan pointing repository anda ke server yang telah dijadikan repository lokal ini. Hal ini dilakukan agar command yum yang digunakan akan mencari paket2 yang ada dari server yang telah anda build menjadi repository lokal ini.
a) Hapus/Backup semua file yang ada di /etc/yum.repos.d/Untuk hapus gunakan command
[[email protected] ~]# rm /etc/yum.repos.d/*
Untuk backup gunakan command mv sebagai contoh.
[[email protected] ~]# mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.bak
b) Buat pointing file repo
[[email protected] ~]# vim /etc/yum.repos.d/lokal.repo
#Lalu tulis dengan parameter dibawah ini
[lokal]name=lokal
baseurl=http://192.168.99.103/repo/
enabled=1
gpgcheck=0
#Save Lalu Quit
c) Clean repo lalu listing repo
[[email protected] ~]# yum clean all
[[email protected] yum.repos.d]# yum repolist