Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

CentOS 6.9 self-built open source mirror station

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. Demo environment:

IP

OS

Nginx version

Rsync version

Open Source Software Mirror Station of Tsinghua University

192.168.1.146

CentOS 6.9 x86_64

1.10.2

3.0.6

Https://mirrors.tuna.tsinghua.edu.cn/

Note: the upstream yum source of synchronization must support the rsync protocol, otherwise you cannot use rsync for synchronization. Many open source mirror stations in China do not support rsync. Here, take the open source software mirror station of Tsinghua University as an example.

2. Prepare before installation:

(1) Server time proofreading

(2) configure epel source

3. Install and configure Nginx:

(1) install Nginx: # yum-y install nginx

(2) create the package storage directory: # mkdir-pv / mirror/ {centosplus,extras,os,updates,epel}

(3) configure Nginx:

# cd / etc/nginx/conf.d

# cp default.conf default.conf.bak

# vim default.conf

Server {

Listen 80

Server_name localhost

Root / mirror/

Location / {

Autoindex on

Autoindex_exact_size off

Autoindex_localtime on

}

}

(4) check the syntax of the Nginx configuration file and start Nginx: # nginx-t # service nginx start

(5) check port 80 that Nginx listens to: # ss-tnlp | grep: 80 # pidof nginx

(6) visit the site in the browser: 192.168.1.146

4. Synchronize the open source software mirror station of Tsinghua University:

(1) install related software packages: # yum-y install rsync createrepo

(2) View the software packages under each source:

# rsync-list-only rsync://mirrors.tuna.tsinghua.edu.cn/centos/6.9/centosplus/x86_64/Packages/

# rsync-list-only rsync://mirrors.tuna.tsinghua.edu.cn/centos/6.9/extras/x86_64/Packages/

# rsync-list-only rsync://mirrors.tuna.tsinghua.edu.cn/centos/6.9/os/x86_64/Packages/

# rsync-list-only rsync://mirrors.tuna.tsinghua.edu.cn/centos/6.9/updates/x86_64/Packages/

# rsync-r-list-only rsync://mirrors.tuna.tsinghua.edu.cn/epel/6Server/x86_64/Packages/

(3) write synchronization scripts:

# mkdir-pv / scripts

# vim / scripts/yum_rsync.sh

#! / bin/bash

/ usr/bin/rsync-avz rsync://mirrors.tuna.tsinghua.edu.cn/centos/6.9/centosplus/x86_64/Packages/ / mirror/centosplus & & / usr/bin/createrepo / mirror/centosplus

/ usr/bin/rsync-avz rsync://mirrors.tuna.tsinghua.edu.cn/centos/6.9/extras/x86_64/Packages/ / mirror/extras & & / usr/bin/createrepo / mirror/extras

/ usr/bin/rsync-avz rsync://mirrors.tuna.tsinghua.edu.cn/centos/6.9/os/x86_64/Packages/ / mirror/os & & / usr/bin/createrepo / mirror/os

/ usr/bin/rsync-avz rsync://mirrors.tuna.tsinghua.edu.cn/centos/6.9/updates/x86_64/Packages/ / mirror/updates & & / usr/bin/createrepo / mirror/updates

/ usr/bin/rsync-avz rsync://mirrors.tuna.tsinghua.edu.cn/epel/6Server/x86_64/Packages/ / mirror/epel & & / usr/bin/createrepo / mirror/epel

# chmod + x / scripts/yum_rsync.sh

(4) write scheduled tasks: start executing synchronization scripts at 12:00 every morning

# crontab-e-> 0 0 * / scripts/yum_rsync.sh

Note: synchronization takes a long time and ensures that the disk has sufficient capacity

When synchronizing, you can view the rsync process with the # top command:

Directory structure and disk capacity before synchronization:

Directory structure and disk capacity after synchronization:

5. Other servers (for example: 192.168.1.145) configure self-built yum sources to download and install software packages:

(1) create a repo configuration file for the yum source:

# cd / etc/yum.repos.d

# mv CentOS-Base.repo CentOS-Base.repo.bak

# vim CentOS-Base.repo

[base]

Name=Marion-CentOS-$releasever-Base

Baseurl= http://192.168.1.146/os

Enabled=1

Gpgcheck=0

[centosplus]

Name=Marion-CentOS-$releasever-Centosplus

Baseurl= http://192.168.1.146/centosplus

Enabled=1

Gpgcheck=0

[extras]

Name=Marion-CentOS-$releasever-Extras

Baseurl= http://192.168.1.146/extras

Enabled=1

Gpgcheck=0

[updates]

Name=Marion-CentOS-$releasever-Updates

Baseurl= http://192.168.1.146/updates

Enabled=1

Gpgcheck=0

# vim epel.repo

[epel]

Name=Marion-CentOS-$releasever-EPEL

Baseurl= http://192.168.1.146/epel

Enabled=1

Gpgcheck=0

(2) clear the current yum cache: # yum clean all

(3) regenerate yum cache: # yum makecache

(4) display the available yum sources: # yum repolist

(5) Test base source: # yum-y install httpd # yum info httpd

(6) Test epel source: # yum-y install nginx # yum info nginx

This article is from the Marion0728 51CTO blog, the original link: http://blog.51cto.com/qiuyue/2052813, if you need to reprint, please contact the original author

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report