Configurar un sitio Mirror en un entorno aislado

Hay muchas herramientas para crear sitios Mirror, pero en la raíz, todas usan rsync como una herramienta y un medio de sincronización remota, por lo que este tipo de herramienta de duplicación se puede llamar herramienta de duplicación de rsync. Entre muchas herramientas de duplicación de rsync, la facilidad de uso y configuración es la herramienta tunasync abierta por la Universidad de Tsinghua. Por supuesto, también es una herramienta de duplicación de rsync desarrollada por Golang.

La razón para mostrar este documento de operación es porque hoy un estudiante que llevé conmigo el año pasado necesitaba construir un sitio que reflejara el sitio de Alibaba Cloud CentOS en un entorno aislado. Debido a una operación incorrecta, la duplicación falló y no se pudo acceder al servicio web.

El siguiente es el proceso que utilizo tunasync para construir un sitio Mirror en un entorno aislado:

El entorno del sistema operativo es CentOS 7 1804 de 64 bits

Primero inicialice CentOS 7, el script de inicialización es el siguiente:

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.original
wget -O /etc/yum.repos.d/CentOS-Base.repo https: //mirrors.aliyun.com/repo/Centos-7.repo
yum clean all && yum makecache
yum -y update
systemctl stop firewalld && systemctl disable firewalld
sed -i 's / ^ SELINUX =. / SELINUX = desactivado / '/ etc / selinux / config && setenforce 0
wget https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
yum install -y https: //mirrors.aliyun .com / epel / epel-release-latest-7.noarch.rpm
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
sed - soy | ^ # baseurl =https://download.fedoraproject.org/pub|baseurl=https://mirrors.aliyun.com | ' /etc/yum.repos.d/epel

sed -i 's | ^ metalink | #metalink |' /etc/yum.repos.d/epel*
yum clean all && yum makecache
yum -y update
yum install -y ntpdate
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
yum localinstall -y google-chrome-stable_current_x86_64.rpm
ntpdate cn.ntp.org.cn
yum install -y árbol
quién | grep googlebigtable | sed -n '1p' | cortar -d '' -f 1 | ordenar | uniq
DescriptionUser = $ (who | grep googlebigtable | sed -n '1p' | cut -d '' -f 1 | sort | uniq)
echo $ DescriptionUser
echo "$ DescriptionUser ALL = (ALL) NOPASSWD: ALL" >>

Cree espejos de usuarios y grupos de espejos de grupos de usuarios
[googlebigtable @ localhost tunasyncMirrorWeb] $ sudo su

[root @ localhost tunasyncMirrorWeb] # groupadd mirrorgroup

[root @ localhost tunasyncMirrorWeb] # useradd -g mirrorgroup espejos

[root @ localhost tunasyncMirrorWeb] # espejos de id

uid = 1001 (espejos) gid = 1001 (grupo espejo) grupos = 1001 (grupo espejo)

[root @ localhost tunasyncMirrorWeb] # espejos passwd

Cambio de contraseña para espejos de usuario.

Nueva contraseña:

CONTRASEÑA MALA: la contraseña no pasa la verificación del diccionario; se basa en una palabra del diccionario

Reescriba nueva contraseña:

passwd: todos los tokens de autenticación se actualizaron correctamente.

[root @ localhost tunasyncMirrorWeb] # espejos de id

uid = 1001 (espejos) gid = 1001 (grupo espejo) grupos = 1001 (grupo espejo)

[root @ localhost tunasyncMirrorWeb] #

Cree una aplicación y un directorio de datos
[root @ localhost tunasyncMirrorWeb] # mkdir -p / opt / mirrors / tunasync / {conf, db, log}

[root @ localhost tunasyncMirrorWeb] # ls -F / opt / mirrors / tunasync /

conf / db / log /

[root @ localhost tunasyncMirrorWeb] #

[root @ localhost tunasyncMirrorWeb] # mkdir -p / opt / mirrors / mirrorsData

[root @ localhost tunasyncMirrorWeb] # ls -F / opt / mirrors /

espejosData / tunasync /

[root @ localhost tunasyncMirrorWeb] # chown -R mirrors: mirrorgroup / opt / mirrors / mirrorsData

[root @ localhost tunasyncMirrorWeb] # ll / opt / mirrors /

total 0

drwxr-xr-x 2 espejos grupo de espejos 6 de septiembre de 20 06:03 espejos

drwxr-xr-x 4 raíz raíz 28 de septiembre de 20 06:00 tunasync

[root @ localhost tunasyncMirrorWeb] #

部署 tunasync
[root @ localhost tunasyncMirrorWeb] # ls -F

tunasync-linux-amd64-bin.tar.gz

[root @ localhost tunasyncMirrorWeb] # chmod 777 tunasync-linux-amd64-bin.tar.gz

[root @ localhost tunasyncMirrorWeb] # tar -xzvf tunasync-linux-amd64-bin.tar.gz -C / opt / mirrors / tunasync /

tunasync

tunasynctl

[root @ localhost tunasyncMirrorWeb] # ls -F / opt / mirrors / tunasync /

conf / db / tunasync tunasynctl

[root @ localhost tunasyncMirrorWeb] #

Configure las variables de entorno
[root @ localhost tunasyncMirrorWeb] # chown -R mirrors: mirrorgroup / opt / mirrors

[root @ localhost tunasyncMirrorWeb] # ll / opt / mirrors

total 0

drwxr-xr-x 2 espejos grupo de espejos 6 de septiembre de 20 06:03 espejos

drwxr-xr-x 4 espejos grupo de espejos 62 20 de septiembre 06:07 tunasync

[root @ localhost tunasyncMirrorWeb] # ll / opt / mirrors / tunasync /

total 28032

drwxr-xr-x 2 espejos grupo de espejos 6 20 de septiembre 06:00 conf

drwxr-xr-x 2 espejos grupo de espejos 6 20 de septiembre 06:00 db

-rwxr-xr-x 1 espejos grupo de espejos 17930410 11 de septiembre 06:24 tunasync

-rwxr-xr-x 1 espejos grupo de espejos 10770787 11 de septiembre 06:24 tunasynctl

[root @ localhost tunasyncMirrorWeb] # su - espejos

[espejos @ localhost ~] $ cat -n ~ / .bash_profile

 1 # .bash_profile

 2

 3 # Get the aliases and functions

 4 if [ -f ~/.bashrc ]; then

 5 . ~/.bashrc

 6 fi

 7

 8 # User specific environment and startup programs

 9

10 PATH=$PATH:$HOME/.local/bin:$HOME/bin

11

12 export PATH

[espejos @ localhost ~] $ cp ~ / .bash_profile {,. original}

[mirrors @ localhost ~] $ echo "TUNAPATH = / home / mirrors / tunasync" >> ~ / .bash_profile

[espejos @ localhost ~] $ echo "RUTA = $ RUTA: $ TUNAPATH" >> ~ / .bash_profile

[espejos @ localhost ~] $ cat -n ~ / .bash_profile

 1 # .bash_profile

 2

 3 # Get the aliases and functions

 4 if [ -f ~/.bashrc ]; then

 5 . ~/.bashrc

 6 fi

 7

 8 # User specific environment and startup programs

 9

10 PATH=$PATH:$HOME/.local/bin:$HOME/bin

11

12 export PATH

13 TUNAPATH=/home/mirrors/tunasync

14 PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/mirrors/.local/bin:/home/mirrors/bin:

[espejos @ localhost ~] $ fuente ~ / .bash_profile

[espejos @ localhost ~] $

Configure el servicio de sincronización de tunasync
[mirrors @ localhost ~] $ ls -F / opt / mirrors / tunasync /

conf / db / tunasync tunasynctl

[espejos @ localhost ~] $

[espejos @ localhost ~] $ tee> /opt/mirrors/tunasync/conf/manager.conf << EOF

manager.conf

debug = falso

[servidor]

addr = "127.0.0.1"

puerto = 14242

ssl_cert = ""

ssl_key = ""

[archivos]

db_type = "perno"

db_file = "/opt/mirrors/tunasync/db/manager.db"

ca_cert = ""

EOF

Cree archivos de configuración de duplicación sincronizados según sea necesario. A continuación, se muestra un ejemplo de duplicación de CentOS:

[espejos @ localhost ~] $ tee> /opt/mirrors/tunasync/conf/worker-centos.conf << EOF

[global]

nombre = "centos_worker"

log_dir = "/opt/mirrors/tunasync/log/{{.Name}}"

mirror_dir = "/ opt / mirrors / mirrorsData"

concurrente = 10

intervalo = 1440

[gerente]

api_base = " http: // localhost: 14242 "

token = "algún_token"

ca_cert = ""

[cgroup]

habilitar = falso

ruta_base = "/ sys / fs / cgroup"

group = "tunasync"

[servidor]

hostname = "localhost"

listen_addr = "127.0.0.1"

listen_port = 16010

ssl_cert = ""

ssl_key = ""

[[espejos]]

nombre = "centos"

proveedor = "rsync"

upstream = "rsync: //mirrors.aliyun.com/centos/"

use_ipv6 = false

EOF

[espejos @ localhost ~] $

espejos @ localhost ~] $ ls -F / opt / espejos / tunasync /

conf / db / log / tunasync tunasynctl

[espejos @ localhost ~] $ ls -F / opt / espejos / tunasync / conf /

manager.conf worker-centos.conf

[espejos @ localhost ~] $

Inicie el programa de sincronización tunasync. Para
iniciar tunasync, primero debe iniciar el administrador y luego iniciar el trabajador. Para facilitar el monitoreo de los procesos del sistema, se crea un directorio / opt / mirrors / tunasync / log / plog /, y los registros de trabajo de todos los procesos se encuentran en este directorio.

Ejecutar con el usuario de los espejos:

[mirrors @ localhost ~] $ / opt / mirrors / tunasync / tunasync manager --config /opt/mirrors/tunasync/conf/manager.conf >> /opt/mirrors/tunasync/log/plog/manager.log &

[1] 60268

[mirrors @ localhost ~] $ / opt / mirrors / tunasync / tunasync worker --config /opt/mirrors/tunasync/conf/worker-centos.conf >> / opt / mirrors / tunasync / log / plog / worker-centos. Iniciar sesión &

[2] 60284

[espejos @ localhost ~] $


Instale el servidor apache para abrir el servicio de acceso web para los usuarios de la intranet :

[espejos @ localhost ~] $ su root

Contraseña:

[root @ localhost espejos] # yum -y instalar httpd

Complementos cargados: rapidmirror, langpacks

Cargando velocidades de espejo desde un archivo host en caché

Instalado:

httpd.x86_64 0: 2.4.6-93.el7.centos

Dependencia instalada:

httpd-tools.x86_64 0: 2.4.6-93.el7.centos mailcap.noarch 0: 2.1.41-2.el7

¡Completar!

[espejos root @ localhost] #

[espejos root @ localhost] # árbol / etc / httpd /

/ etc / httpd /

├── conf

│ ├── httpd.conf

│ └── magia

├── conf.d

│ ├── autoindex.conf

│ ├── README

│ ├── userdir.conf

│ └── welcome.conf

├── conf.modules.d

│ ├── 00-base.conf

│ ├── 00-dav.conf

│ ├── 00-lua.conf

│ ├── 00-mpm.conf

│ ├── 00-proxy.conf

│ ├── 00-systemd.conf

│ └── 01-cgi.conf

├── registros -> ../../var/log/httpd

├── módulos -> ../../usr/lib64/httpd/modules

└── ejecutar -> / ejecutar / httpd

6 directorios, 13 archivos

[espejos root @ localhost] # cp /etc/httpd/conf/httpd.conf{,.original}

[espejos root @ localhost] #

[espejos @ localhost ~] $ grep "^ \ s [^ # \ t]. $" /etc/httpd/conf/httpd.conf | gato

ServerRoot "/ etc / httpd"

Escuchar 80

Incluya conf.modules.d / *. Conf

Usuario apache

Grupo apache

ServerAdmin root @ localhost

<Directorio />

AllowOverride none

Require all denied

</Directorio>

DocumentRoot "/ var / www / html"

<Directorio "/ var / www">

AllowOverride None

Require all granted

</Directorio>

<Directorio "/ var / www / html">

Options Indexes FollowSymLinks

AllowOverride None

Require all granted

</Directorio>

<IfModule dir_module>

DirectoryIndex index.html

</IfModule>

<Archivos ".ht *">

Require all denied

</Files>

ErrorLog "logs / error_log"

Advertencia de nivel de registro

<IfModule log_config_module>

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

LogFormat "%h %l %u %t \"%r\" %>s %b" common

<IfModule logio_module>

  LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio

</IfModule>

CustomLog "logs/access_log" combined

</IfModule>

<IfModule alias_module>

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

</IfModule>

<Directorio "/ var / www / cgi-bin">

AllowOverride None

Options None

Require all granted

</Directorio>

<IfModule mime_module>

TypesConfig /etc/mime.types

AddType application/x-compress .Z

AddType application/x-gzip .gz .tgz

AddType text/html .shtml

AddOutputFilter INCLUDES .shtml

</IfModule>

AddDefaultCharset UTF-8

<IfModule mime_magic_module>

MIMEMagicFile conf/magic

</IfModule>

EnableSendfile en

Incluir conf.d / *. Conf opcional

[espejos @ localhost ~] $

Después de modificar /etc/httpd/conf/httpd.conf, es:

[espejos @ localhost ~] $ grep "^ \ s [^ # \ t]. $" /etc/httpd/conf/httpd.conf | gato

ServerRoot "/ etc / httpd"

Escuchar 80

Incluya conf.modules.d / *. Conf

Usuario apache

Grupo apache

ServerAdmin root @ localhost

<Directorio />

AllowOverride none

Require all denied

</Directorio>

DocumentRoot "/ opt / mirrors / mirrorsData /"

<Directorio "/ var / www">

AllowOverride None

Require all granted

</Directorio>

<Directorio "/ opt / mirrors / mirrorsData /">

Options Indexes FollowSymLinks

AllowOverride None

Require all granted

</Directorio>

<IfModule dir_module>

DirectoryIndex index.html

</IfModule>

<Archivos ".ht *">

Require all denied

</Files>

ErrorLog "logs / error_log"

Advertencia de nivel de registro

<IfModule log_config_module>

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

LogFormat "%h %l %u %t \"%r\" %>s %b" common

<IfModule logio_module>

  LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio

</IfModule>

CustomLog "logs/access_log" combined

</IfModule>

<IfModule alias_module>

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

</IfModule>

<Directorio "/ var / www / cgi-bin">

AllowOverride None

Options None

Require all granted

</Directorio>

<IfModule mime_module>

TypesConfig /etc/mime.types

AddType application/x-compress .Z

AddType application/x-gzip .gz .tgz

AddType text/html .shtml

AddOutputFilter INCLUDES .shtml

</IfModule>

AddDefaultCharset UTF-8

<IfModule mime_magic_module>

MIMEMagicFile conf/magic

</IfModule>

EnableSendfile en

Incluir conf.d / *. Conf opcional

[espejos @ localhost ~] $

[espejos @ localhost ~] $ chmod -R 755 / opt / mirrors / mirrorsData

[espejos @ localhost ~] $ systemctl iniciar httpd.service

[mirrors @ localhost ~] $ systemctl habilita httpd.service

Enlace simbólico creado desde /etc/systemd/system/multi-user.target.wants/httpd.service a /usr/lib/systemd/system/httpd.service.

[espejos @ localhost ~] $

[root @ localhost Public] # chown -R espejos: grupo de espejos /opt/mirrors/mirrorsData/index.html

[espejos @ localhost ~] $ cat /opt/mirrors/mirrorsData/index.html

<! DOCTYPE html PUBLIC "- // W3C // DTD XHTML 1.0 Transitional // EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> ;

<html xmlns = " http://www.w3.org/1999/xhtml"> ;

<cabeza>

<meta http-equiv="content-type" content="text/html; charset=utf-8"/>

<link rel="stylesheet" type="text/css" href="/.resource/css/mirror.css" media="screen" />

<script type="text/javascript" src=".resource/js/jquery-1.11.3.min.js" ></script>

<script type="text/javascript" src=".resource/js/mirror.js" ></script>

<script type="text/javascript" src=".resource/js/main.js" ></script>

<title>CentOS</title>

</head>

<cuerpo>

<h1> Bienvenido al sitio espejo de CentOS </h1>

<table id = "distro-table" cellpadding = "0" cellspacing = "0">

<colgroup>

    <col width="12%"/>

    <col width="15%"/>

    <col width="35%"/>

    <col width="10%"/>

    <col width="8%"/>

    <col width="20%"/>

</colgroup>

<thead>

    <tr>

        <th>镜像名</th>

        <th>上次更新时间</th>

        <th>更新源</th>

        <th>状态</th>

        <th>镜像大小</th>

        <th>使用帮助</th>

    </tr>

</thead>

<tbody>

    <tr class="odd">

        <td><a href="/centos/">centos/</a></td>

        <td class="centos update-time">N/A</td>

        <td class="centos upstream">N/A</td>

        <td class="centos sync-status">N/A</td>

        <td class="centos mirror-size">N/A</td>

        <td><a href="/.help/centos.html">Centos/Redhat 使用帮助</a></td>

    </tr>

</tbody>

</table>

<div id = "pie de página">

</div>

</body>

</html>

[espejos @ localhost ~] $

[espejos @ localhost ~] $ chmod -R 755 / opt / mirrors / mirrorsData

En este punto, el sitio Mirror está configurado y puede acceder directamente a la IP del sitio a través de un navegador:

Configurar un sitio Mirror en un entorno aislado

Configurar un sitio Mirror en un entorno aislado

Supongo que te gusta

Origin blog.51cto.com/6286393/2536308
Recomendado
Clasificación