Posts

How to create repository in Redhat 7 Linux

Introduction

Repository is database of application installation and up-gradation of packages which are available on different Linux distributions. The packages of distros are available on official websites or you can extract them from official CD/DVD. We can easily install, upgrade or delete packages from repository.

Step 1: Mount ISO from DVD or Folder

In order to create repository, first mount ISO image from Official DVD or download it from given websites.

# cd /root
# mount -o loop RHEL-7.0 Server.x86_64-dvd.iso /mnt/	(For Redhat 7)
# mount -r -t iso9660 -o loop -v rhel-server-6.4-x86_64-dvd.iso /mnt	(For Redhat 6)

Step 2: Create Repository

To create repository follow the following steps.

# cd /etc/yum.repos.d/
# vi rhel7.repo
[rhel7]
name=Redhat
baseurl=file:///mnt/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

Step 3: Install Packages

Install Packages using yum command.

# yum clean all
# yum install ftp httpd gcc

How To Synchronize Files using rsync Command

Rsync is a free software/package that is used for synchronizing and copying directories and files locally as well as remotely.

By Default Port # 873

Install rsync

Install rsync package on server.

For RedHat/CentOS/Fedora

# yum install rsync

For Debian/Ubuntu

# apt-get install rsync

Basic syntax of rsync command

Here is the basic syntax of writing rsync command

# rsync options source destination

Rsync Directory/File on Local Machine

To Rsync Directory/File on Local Machine execute the following command.

# rsync -r dir1/ dir2

Rsync Directory/File on Remote Machine

To Rsync Directory/File on Remote Machine execute the following command.

# rsync -avzhe username@IP-Address:/remote-directory /local-directory

Set Cronjob for Sync Directory/File on Remote Machine

To Set Cronjob Rsync Directory/File on Remote Machine execute the following command.

*/45 * * * * rsync -avzhe ssh username@IP-Address:/remote-directory /local-directory