June 2020
M T W T F S S
« Mar    
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

WordPress Quotes

A person who has a cat by the tail knows a whole lot more about cats than someone who has just read about them.
Mark Twain
June 2020
M T W T F S S
« Mar    
1234567
891011121314
15161718192021
22232425262728
2930  

Short Cuts

2012 SERVER (64)
2016 windows (9)
AIX (13)
Amazon (40)
Ansibile (19)
Apache (135)
Asterisk (2)
cassandra (2)
Centos (211)
Centos RHEL 7 (270)
centos8 (3)
chef (3)
cloud (2)
cluster (3)
Coherence (1)
DB2 (5)
DISK (25)
DNS (9)
Docker (30)
Eassy (11)
ELKS (1)
EXCHANGE (3)
Fedora (6)
ftp (5)
GIT (3)
GOD (2)
Grub (1)
Hacking (10)
Hadoop (6)
health (2)
horoscope (23)
Hyper-V (10)
IIS (15)
IPTABLES (15)
JAVA (7)
JBOSS (32)
jenkins (1)
Kubernetes (7)
Ldap (5)
Linux (188)
Linux Commands (166)
Load balancer (5)
mariadb (14)
Mongodb (4)
MQ Server (24)
MYSQL (84)
Nagios (5)
NaturalOil (13)
Nginx (35)
Ngix (1)
openldap (1)
Openstack (6)
Oracle (35)
Perl (3)
Postfix (19)
Postgresql (1)
PowerShell (2)
Python (3)
qmail (36)
Redis (12)
RHCE (28)
SCALEIO (1)
Security on Centos (29)
SFTP (1)
Shell (64)
Solaris (58)
Sql Server 2012 (4)
squid (3)
SSH (10)
SSL (14)
Storage (1)
swap (3)
TIPS on Linux (28)
tomcat (62)
Ubuntu (1)
Uncategorized (30)
Veritas (2)
vfabric (1)
VMware (28)
Weblogic (38)
Websphere (71)
Windows (19)
Windows Software (2)
wordpress (1)
ZIMBRA (17)

WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.

Who's Online

0 visitors online now
0 guests, 0 bots, 0 members

Hit Counter provided by dental implants orange county

CentOS 7 – Create CentOS 7 Mirror

CentOS 7 – Create CentOS 7 Mirror

The tutorial below will show you how to configure a CentOS 7 server with Nginx to act as a mirror for other CentOS 7 servers.
Steps
First we need to update and install all the necessary packages.
yum update
yum install -y createrepo rsync nginx
Now we need to setup our directories and permissions:

mkdir -p /var/www/html/repos/centos/7.2/os/x86_64/
mkdir -p /var/www/html/repos/centos/7.2/updates/x86_64/
chmod 770 -R /var/www
chown $USER:nginx -R /var/www
Now we are going to configure Nginx to use the location we just created. Replace the contents of /etc/nginx/nginx.conf with:

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

events {
worker_connections 1024;
}

http {
log_format main ‘$remote_addr – $remote_user [$time_local] “$request” ‘
‘$status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” “$http_x_forwarded_for”‘;

access_log /var/log/nginx/access.log main;

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

include /etc/nginx/mime.types;
default_type application/octet-stream;

include /etc/nginx/conf.d/*.conf;
}
Create a file at /etc/nginx/conf.d/repo.conf with the following contents
server {
listen 80;
server_name localhost;
root /var/www/html/repos;

location / {
autoindex on;
}

}
Run the following command
http://mirror.bytemark.co.uk/centos/7.2.1511/

createrepo /var/www/html/repos/centos/7.2/os/x86_64/
createrepo /var/www/html/repos/centos/7.2/updates/x86_64/

Now we need to fetch the data for the mirror. Go to the CentOS mirrors list and pick the mirror closest to you that has an rsync address (6th column in the table). For me, I am going to use Bytemark since I am in the United Kingdom.
rsync://mirror.nus.edu.sg/centos
Take the given url, and add the following to the end of it:
/7/os/x86_64/
/7/updates/x86_64/

Now use those urls in the commands below
rsync -avz -avz –delete –exclude=’repo*’ \
rsync://mirror.bytemark.co.uk/centos/7.2.1511/os/x86_64/ \
/var/www/html/repos/centos/7/os/x86_64/

rsync -avz –delete –exclude=’repo*’ \
rsync://mirror.bytemark.co.uk/centos/7.2.1511/updates/x86_64/ \
/var/www/html/repos/centos/7.2/updates/x86_64/

Next we need to update the repo metadata by running:

createrepo –update /var/www/html/repos/centos/7.2/os/x86_64/
createrepo –update /var/www/html/repos/centos/7.2/updates/x86_64/

Configure Cron For Automatic Updating

Create a script with the following contents:
#!/bin/bash
rsync -avz -avz –delete –exclude=’repo*’ \
rsync://mirror.bytemark.co.uk/centos/7.2.1511/os/x86_64/ \
/var/www/html/repos/centos/7/os/x86_64/

rsync -avz –delete –exclude=’repo*’ \
rsync://mirror.bytemark.co.uk/centos/7.2.1511/updates/x86_64/ \
/var/www/html/repos/centos/7.2/updates/x86_64/
/usr/bin/createrepo –update \
/var/www/html/repos/centos/7/os/x86_64/

/usr/bin/createrepo –update \
/var/www/html/repos/centos/7/updates/x86_64/

Now configure the cron service to call that script from at midnight every day by executing crontab -e and adding the following line:

@daily /bin/bash /path/to/script.sh
Configure Automatic Startup
Run the commands below to ensure nginx starts up on boot.
systemctl enable nginx.service && sudo systemctl enable firewalld.service
systemctl start firewalld.service
firewall-cmd –permanent –add-service=http
firewall-cmd –reload
systemctl reboot

Configure SELinux
If you are running selinux and you don’t want to disable it, then run the following command to have selinux allow nginx to serve content from /var/www

chcon -Rt httpd_sys_content_t /var/www

Configure Client To Use Own Mirror

There’s no point having a mirror unless you configure your other servers to use that mirror for updates. Edit the file at /etc/yum.repos.d/CentOS-Base.repo and comment out any lines starting with mirrorlist or baseurl underneath [base] or [updates]. Then add your own baseurl to these sections, with your own mirrors url. For example, my mirror is located internally at http://centos-mirror.programster.org, so my base urls were:
[base]
baseurl=http://centos-mirror.rmohan.com/centos/$releasever/os/$basearch/

[updates]
baseurl=http://centos-mirror.rmohan.com/centos/$releasever/updates/$basearch/

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  

  

  

Blue Captcha Image
Refresh

*

Protected by WP Anti Spam