Benutzer-Werkzeuge

Webseiten-Werkzeuge


tachtler:repository_spiegeln_centos_7

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
tachtler:repository_spiegeln_centos_7 [2014/12/12 13:46] klaustachtler:repository_spiegeln_centos_7 [2014/12/12 15:00] (aktuell) – [Befehl: rsync] klaus
Zeile 153: Zeile 153:
 /usr/share/man/man5/rsyncd.conf.5.gz /usr/share/man/man5/rsyncd.conf.5.gz
 </code> </code>
 +
 +===== Befehl: rsync =====
 +
 +Mit nachfolgendem Befehl, **könnte** nun ein komplettes [[http://www.centos.org|CentOS]]-Repository von einem **öffentlichen Spiegel** transferiert und synchronisiert werden:
 +
 +:!: **HINWEIS** - **Bitte __NICHT__ oder __nur mit Bedacht__ ausführen, da hier, je nach eigener Anbindung ans Internet, eine __sehr__ lange Datentransferzeit zu erwarten ist !!!**
 +
 +<code>
 +# /usr/bin/rsync -varlHt --progress --delete-after --delay-updates --timeout=300 --exclude SRPMS/ ftp-stud.fht-esslingen.de::pub/Mirrors/centos/7.0.1406/ /srv/repository/pub/Mirrors/centos/7.0.1406/
 +</code>
 +
 +**Agenda der verwendeten Optionen**
 +  * **''-v''** - ''--verbose'' - Ausgabe von Laufzeitinformationen 
 +  * **''-a''** - ''--archive'' - Archiv-Modus 
 +  * **''-r''** - ''--recursive'' - Die Verzeichnisse rückwärts durchsuchen
 +  * **''-l''** - ''--links'' - Kopiere symbolische Links als symbolische Links
 +  * **''-H''** - ''--hard-links'' - Erhalte "hard" Links
 +  * **''-t''** - ''--times'' - Erhalte ursprüngliche Zeitangaben
 +  * **''--progress''** - Fortschrittsanzeige anzeigen 
 +  * **''--delete-after''** - Führe Löschungen erst nach den Änderungen durch, nicht vorher
 +  * **''--delay-updates''** - Führe alle Änderungen erst am Ende des Datentransfers durch (Zwischenspeicherung in **''.~tmp~  ''**)
 +  * **''--timeout=300''** - Zeitablauf für Operationen in Sekunden
 +  * **''--exclude SRPMS/''** - Nachfolgende Angabe ''SRPMS/ '' nicht mit einbeziehen
 +
 +:!: **HINWEIS** - Zum Test der Verbindung, kann nachfolgender Befehl verwendet werden, welcher nur den Inhalt des Verzeichnisses:
 +  * **''http://ftp-stud.fht-esslingen.de/pub/Mirrors/centos/7.0.1406/os/x86_64/repodata/''**
 +transferieren würde!
 +<code>
 +# /usr/bin/rsync -varlHt --progress --delete-after --delay-updates --timeout=300 --exclude SRPMS/ ftp-stud.fht-esslingen.de::centos/7.0.1406/os/x86_64/repodata/ /tmp/test
 +Welcome to the ftp-stud.hs-esslingen.de archives.
 +
 +If have any unusual problems, please report them via e-mail to
 +rsync@ftp-stud.hs-esslingen.de.
 +
 +  All transfers are logged.
 +  If you don't like this policy, then disconnect now.
 +  This server does not support --checksum (-c)
 +  This server does not support --compress (-z)
 +
 +
 +receiving file list ... 
 +10 files to consider
 +./
 +1a7dd0d315b39ad504f54ea88676ab502a48064cb2d875ae3ae29431e175861c-primary.xml.gz
 +     2466737 100%    1.15MB/   0:00:02 (xfer#1, to-check=8/10)
 +2bc0054a9f0f4cd3d2806d983edbe3d0dfc484d9f275d12be79eb67a040ba942-c7-x86_64-comps.xml
 +      725755 100%    1.16MB/   0:00:00 (xfer#2, to-check=7/10)
 +3cda64d1c161dd0fead8398a62ef9c691e78ee02fe56d04566f850c94929f61f-filelists.sqlite.bz2
 +     6048365 100%    1.04MB/   0:00:05 (xfer#3, to-check=6/10)
 +4b9ac2454536a901fecbc1a5ad080b0efd74680c6e1f4b28fb2c7ff419872418-c7-x86_64-comps.xml.gz
 +      160516 100%  198.42kB/   0:00:00 (xfer#4, to-check=5/10)
 +7a90ec1358cb1d9cab4c84793f9b96602fb49e7db90a6b8f5ddc441cb2a918c6-filelists.xml.gz
 +     6024471 100%    1.05MB/   0:00:05 (xfer#5, to-check=4/10)
 +ea8bacdf833619ea843887b0673a569633dc9853462219b50578d8247a1cf6c0-other.xml.gz
 +     1305746 100%  846.71kB/   0:00:01 (xfer#6, to-check=3/10)
 +efa521576f53587de26616ea1e45f902993abcd9d67e707b8993b5f29bd15956-primary.sqlite.bz2
 +     5161398 100%    1.05MB/   0:00:04 (xfer#7, to-check=2/10)
 +fdef8b31072b60b0cad9c0c63977ff9c5fb5080f3ecdb47bff0ec0b7bf9b7855-other.sqlite.bz2
 +     2198161 100%  961.33kB/   0:00:02 (xfer#8, to-check=1/10)
 +repomd.xml
 +        3735 100%   16.81kB/   0:00:00 (xfer#9, to-check=0/10)
 +                    
 +sent 228 bytes  received 24099321 bytes  1120909.26 bytes/sec
 +total size is 24094884  speedup is 1.00
 +</code>
 +
 +Mit nachfolgendem Befehl, kann der so eben transferierte Inhalt, angezeigt werden:
 +<code>
 +# ls -l /tmp/test
 +total 23548
 +-rw-r--r-- 1 406 75 2466737 Jul  4 18:00 1a7dd0d315b39ad504f54ea88676ab502a48064cb2d875ae3ae29431e175861c-primary.xml.gz
 +-rw-r--r-- 1 406 75  725755 Jul  4 18:01 2bc0054a9f0f4cd3d2806d983edbe3d0dfc484d9f275d12be79eb67a040ba942-c7-x86_64-comps.xml
 +-rw-r--r-- 1 406 75 6048365 Jul  4 18:01 3cda64d1c161dd0fead8398a62ef9c691e78ee02fe56d04566f850c94929f61f-filelists.sqlite.bz2
 +-rw-r--r-- 1 406 75  160516 Jul  4 18:01 4b9ac2454536a901fecbc1a5ad080b0efd74680c6e1f4b28fb2c7ff419872418-c7-x86_64-comps.xml.gz
 +-rw-r--r-- 1 406 75 6024471 Jul  4 18:00 7a90ec1358cb1d9cab4c84793f9b96602fb49e7db90a6b8f5ddc441cb2a918c6-filelists.xml.gz
 +-rw-r--r-- 1 406 75 1305746 Jul  4 18:00 ea8bacdf833619ea843887b0673a569633dc9853462219b50578d8247a1cf6c0-other.xml.gz
 +-rw-r--r-- 1 406 75 5161398 Jul  4 18:01 efa521576f53587de26616ea1e45f902993abcd9d67e707b8993b5f29bd15956-primary.sqlite.bz2
 +-rw-r--r-- 1 406 75 2198161 Jul  4 18:00 fdef8b31072b60b0cad9c0c63977ff9c5fb5080f3ecdb47bff0ec0b7bf9b7855-other.sqlite.bz2
 +-rw-r--r-- 1 406 75    3735 Jul  4 18:01 repomd.xml
 +</code>
 +
 +:!: **HINWEIS** - Mit nachfolgendem Befehl **__sollte__** der so eben transferierte Inhalt, wieder gelöscht werden, **__da dies NUR ein Test sein sollte, und sich die Daten im FALSCHEN Verzeichnis befinden !!!__**:
 +<code>
 +# rm /tmp/test -rf
 +</code>
 +
 +===== Script: rsync_centos70.sh =====
 +
 +Mit nachfolgendem Script, kann nun z.B. Zeitgesteuert durch einen **''cron''**-Job die Synchronisation durchgeführt werden. 
 +
 +:!: **HINWEIS** - **Bitte __bei der ERSTEN__ Ausführung bedenken, dass je nach eigener Anbindung ans Internet, eine __sehr__ lange Datentransferzeit zu erwarten ist !!!**
 +
 +:!: **WICHTIG** - Bei einer **__eignen__ Internetanbindung** mit **__hoher Bandbreite__** sollte noch der ''rsync''-Parameter (**RSYNC_CMDOPTS**)
 +  * <code>--bwlimit=900</code> = Max. Datentransfer Geschwindigkeit 900 KB
 +hinzugefügt werden, um in diesem Beispiel die [[http://ftp-stud.fht-esslingen.de/pub/Mirrors/centos/|CentOS Mirror - Hochschule Esslingen]]
 + **nicht zu sehr mit dem Datentransfer zu belasten!!!**
 +
 +Der Inhalt des Scripts, sieht wie folgt aus:
 +<code bash>
 +#!/bin/bash
 +
 +##############################################################################
 +# Script-Name : rsync_centos70.sh                                            #
 +# Description : Script to sync via rsync command repositorys from official   #
 +#               mirror servers. On successful execution only a LOG file will #
 +#               be written. On error while execution, a LOG file and a error #
 +#               message will be send by e-mail.                              #
 +#                                                                            #
 +# Last update : 12.12.2014                                                   #
 +# Version     : 1.00                                                         #
 +#                                                                            #
 +# Author      : Klaus Tachtler, <klaus@tachtler.net>                         #
 +# DokuWiki    : http://www.dokuwiki.tachtler.net                             #
 +# Homepage    : http://www.tachtler.net                                      #
 +#                                                                            #
 +# Base script : centos6.0_mirror.sh, Copyright (c) 2004-2011                 #
 +# created by  : Georg Kainzbauer, <georgkainzbauer@gmx.net>                  #
 +# Homepage    : http://www.gtkdb.de                                          #
 +#                                                                            #
 +#  +----------------------------------------------------------------------+  #
 +#  | This program is free software; you can redistribute it and/or modify |  #
 +#  | it under the terms of the GNU General Public License as published by |  #
 +#  | the Free Software Foundation; either version 2 of the License, or    |  #
 +#  | (at your option) any later version.                                  |  #
 +#  +----------------------------------------------------------------------+  #
 +#                                                                            #
 +# Copyright (c) 2011 by Klaus Tachtler.                                      #
 +#                                                                            #
 +##############################################################################
 +
 +##############################################################################
 +#                                H I S T O R Y                               #
 +##############################################################################
 +# Version     : x.xx                                                         #
 +# Description : <Description>                                                #
 +# -------------------------------------------------------------------------- #
 +# Version     : x.xx                                                         #
 +# Description : <Description>                                                #
 +# -------------------------------------------------------------------------- #
 +##############################################################################
 +
 +##############################################################################
 +# >>> Please edit following lines for personal command and/or repositorys. ! #
 +##############################################################################
 +
 +# CUSTOM - Script-Name.
 +SCRIPT_NAME='rsync_centos70'
 +
 +# CUSTOM - Command-Line.
 +RSYNC_CMDOPTS='-varlHt --progress --delete-after --delay-updates --timeout=300'
 +RSYNC_EXCLUDE='--exclude */SRPMS/ --exclude centosplus/ --exclude contrib/ --exclude fasttrack/ --exclude isos/ --exclude xen4/'
 +
 +# CUSTOM - Repository-Mirrors.
 +REPO_SOURCE='ftp-stud.fht-esslingen.de::centos/7.0.1406/'
 +#REPO_SOURCE='mirror.de.leaseweb.net::centos/7.0.1406/'
 +#REPO_SOURCE='ftp.fau.de::centos/7.0.1406/'
 +REPO_TARGET='/srv/repository/private/Mirrors/centos/7.0.1406/'
 +LINK_TARGET='/srv/repository/private/Mirrors/centos/7'
 +
 +# CUSTOM - Mail-Recipient.
 +MAIL_RECIPIENT='root@tachtler.net'
 +
 +# CUSTOM - Status-Mail [Y|N].
 +MAIL_STATUS='N'
 +
 +##############################################################################
 +# >>> Normaly there is no need to change anything below this comment line. ! #
 +##############################################################################
 +
 +# Variables.
 +RSYNC_COMMAND=`command -v rsync`
 +TOUCH_COMMAND=`command -v touch`
 +RM_COMMAND=`command -v rm`
 +PROG_SENDMAIL=`command -v sendmail`
 +CAT_COMMAND=`command -v cat`
 +DATE_COMMAND=`command -v date`
 +MKDIR_COMMAND=`command -v mkdir`
 +LN_COMMAND=`command -v ln`
 +FILE_LOCK='/tmp/'$SCRIPT_NAME'.lock'
 +FILE_LOG='/var/log/'$SCRIPT_NAME'.log'
 +FILE_LAST_LOG='/tmp/'$SCRIPT_NAME'.log'
 +FILE_MAIL='/tmp/'$SCRIPT_NAME'.mail'
 +VAR_HOSTNAME=`uname -n`
 +VAR_SENDER='root@'$VAR_HOSTNAME
 +VAR_EMAILDATE=`$DATE_COMMAND '+%a, %d %b %Y %H:%M:%S (%Z)'`
 +
 +# Functions.
 +function log() {
 +        echo $1
 +        echo `$DATE_COMMAND '+%Y/%m/%d %H:%M:%S'` " INFO:" $1 >>${FILE_LAST_LOG}
 +}
 +
 +function retval() {
 +if [ "$?" != "0" ]; then
 +        case "$?" in
 +        1)
 +                log "ERROR: Syntax or usage error"
 +        ;;
 +        2)
 +                log "ERROR: Protocol incompatibility"
 +        ;;
 +        3)
 +                log "ERROR: Errors selecting input/output files, dirs"
 +        ;;
 +        4)
 +                log "ERROR: Requested action not supported: an attempt was made to manipulate 64-bit files on a platform that cannot support them; or an option was specified that is supported by the client and not by the server."
 +        ;;
 +        5)
 +                log "ERROR: Error starting client-server protocol"
 +        ;;
 +        6)
 +                log "ERROR: Daemon unable to append to log-file"
 +        ;;
 +        10)
 +                log "ERROR: Error in socket I/O"
 +        ;;
 +        11)
 +                log "ERROR: Error in file I/O"
 +        ;;
 +        12)
 +                log "ERROR: Error in rsync protocol data stream"
 +        ;;
 +        13)
 +                log "ERROR: Errors with program diagnostics"
 +        ;;
 +        14)
 +                log "ERROR: Error in IPC code"
 +        ;;
 +        20)
 +                log "ERROR: Received SIGUSR1 or SIGINT"
 +        ;;
 +        21)
 +                log "ERROR: Some error returned by waitpid()"
 +        ;;
 +        22)
 +                log "ERROR: Error allocating core memory buffers"
 +        ;;
 +        23)
 +                log "ERROR: Partial transfer due to error"
 +        ;;
 +        24)
 +                log "ERROR: Partial transfer due to vanished source files"
 +        ;;
 +        25)
 +                log "ERROR: The --max-delete limit stopped deletions"
 +        ;;
 +        30)
 +                log "ERROR: Timeout in data send/receive"
 +        ;;
 +        *)
 +                log "ERROR: Unknown error $?"
 +        ;;
 +        esac
 +fi
 +}
 +
 +function movelog() {
 + $CAT_COMMAND $FILE_LAST_LOG >> $FILE_LOG
 + $RM_COMMAND -f $FILE_LAST_LOG
 + $RM_COMMAND -f $FILE_LOCK
 +}
 +
 +function sendmail() {
 +        case "$1" in
 +        'STATUS')
 +                MAIL_SUBJECT='Status execution '$SCRIPT_NAME' script.'
 +        ;;
 +        *)
 +                MAIL_SUBJECT='ERROR while execution '$SCRIPT_NAME' script !!!'
 +        ;;
 +        esac
 +
 +$CAT_COMMAND <<MAIL >$FILE_MAIL
 +Subject: $MAIL_SUBJECT
 +Date: $VAR_EMAILDATE
 +From: $VAR_SENDER
 +To: $MAIL_RECIPIENT
 +
 +MAIL
 +
 +$CAT_COMMAND $FILE_LAST_LOG >> $FILE_MAIL
 +
 +$PROG_SENDMAIL -f $VAR_SENDER -t $MAIL_RECIPIENT < $FILE_MAIL
 +
 +$RM_COMMAND -f $FILE_MAIL
 +
 +}
 +
 +# Main.
 +log ""
 +log "+-----------------------------------------------------------------+"
 +log "| Start synchronisation from official repository server (mirror). |"
 +log "+-----------------------------------------------------------------+"
 +log ""
 +log "Run script with following parameter:"
 +log ""
 +log "SCRIPT_NAME...: $SCRIPT_NAME"
 +log ""
 +log "RSYNC_CMDOPTS.: $RSYNC_CMDOPTS"
 +log "RSYNC_EXCLUDE.: $RSYNC_EXCLUDE"
 +log ""
 +log "REPO_SOURCE...: $REPO_SOURCE"
 +log "REPO_TARGET...: $REPO_TARGET"
 +log "LINK_TARGET...: $LINK_TARGET"
 +log ""
 +log "MAIL_RECIPIENT: $MAIL_RECIPIENT"
 +log "MAIL_STATUS...: $MAIL_STATUS"
 +log ""
 +
 +# Check if command (file) NOT exist OR IS empty.
 +if [ ! -s "$RSYNC_COMMAND" ]; then
 +        log "Check if command '$RSYNC_COMMAND' was found....................[FAILED]"
 +        sendmail ERROR
 + movelog
 +        exit 10
 +else
 +        log "Check if command '$RSYNC_COMMAND' was found....................[  OK  ]"
 +fi
 +
 +# Check if command (file) NOT exist OR IS empty.
 +if [ ! -s "$TOUCH_COMMAND" ]; then
 +        log "Check if command '$TOUCH_COMMAND' was found....................[FAILED]"
 +        sendmail ERROR
 + movelog
 +        exit 11
 +else
 +        log "Check if command '$TOUCH_COMMAND' was found....................[  OK  ]"
 +fi
 +
 +# Check if command (file) NOT exist OR IS empty.
 +if [ ! -s "$RM_COMMAND" ]; then
 +        log "Check if command '$RM_COMMAND' was found.......................[FAILED]"
 +        sendmail ERROR
 + movelog
 +        exit 12
 +else
 +        log "Check if command '$RM_COMMAND' was found.......................[  OK  ]"
 +fi
 +
 +# Check if command (file) NOT exist OR IS empty.
 +if [ ! -s "$CAT_COMMAND" ]; then
 +        log "Check if command '$CAT_COMMAND' was found......................[FAILED]"
 +        sendmail ERROR
 + movelog
 +        exit 13
 +else
 +        log "Check if command '$CAT_COMMAND' was found......................[  OK  ]"
 +fi
 +
 +# Check if command (file) NOT exist OR IS empty.
 +if [ ! -s "$DATE_COMMAND" ]; then
 +        log "Check if command '$DATE_COMMAND' was found.....................[FAILED]"
 +        sendmail ERROR
 + movelog
 +        exit 14
 +else
 +        log "Check if command '$DATE_COMMAND' was found.....................[  OK  ]"
 +fi
 +
 +# Check if command (file) NOT exist OR IS empty.
 +if [ ! -s "$MKDIR_COMMAND" ]; then
 +        log "Check if command '$MKDIR_COMMAND' was found....................[FAILED]"
 +        sendmail ERROR
 + movelog
 +        exit 15
 +else
 +        log "Check if command '$MKDIR_COMMAND' was found....................[  OK  ]"
 +fi
 +
 +# Check if command (file) NOT exist OR IS empty.
 +if [ ! -s "$LN_COMMAND" ]; then
 +        log "Check if command '$LN_COMMAND' was found.......................[FAILED]"
 +        sendmail ERROR
 + movelog
 +        exit 16
 +else
 +        log "Check if command '$LN_COMMAND' was found.......................[  OK  ]"
 +fi
 +
 +# Check if command (file) NOT exist OR IS empty.
 +if [ ! -s "$PROG_SENDMAIL" ]; then
 +        log "Check if command '$PROG_SENDMAIL' was found................[FAILED]"
 +        sendmail ERROR
 + movelog
 +        exit 17
 +else
 +        log "Check if command '$PROG_SENDMAIL' was found................[  OK  ]"
 +fi
 +
 +# Check if LOCK file NOT exist.
 +if [ ! -e "$FILE_LOCK" ]; then
 +        log "Check if script is NOT already runnig .....................[  OK  ]"
 +
 +        $TOUCH_COMMAND $FILE_LOCK
 +else
 +        log "Check if script is NOT already runnig .....................[FAILED]"
 +        log ""
 +        log "ERROR: The script was already running, or LOCK file already exists!"
 +        log ""
 +        sendmail ERROR
 + movelog
 +        exit 20
 +fi
 +
 +# Check if REPO_TARGET Directory NOT exists.
 +if [ ! -d "$REPO_TARGET" ]; then
 +        log "Check if REPO_TARGET exists................................[FAILED]"
 +        log ""
 +        log " INFO: Creating REPO_TARGET!"
 +        log " INFO: --> "$REPO_TARGET
 +        log ""
 +
 +        $MKDIR_COMMAND -p $REPO_TARGET
 +else
 +        log "Check if REPO_TARGET exists................................[  OK  ]"
 +fi
 +
 +# Check if LINK_TARGET symbolic Link NOT exists.
 +if [ ! -L "$LINK_TARGET" ]; then
 +        log "Check if LINK_TARGET exists................................[FAILED]"
 +        log ""
 +        log " INFO: Creating LINK_TARGET!"
 +        log " INFO: --> "$LINK_TARGET
 +        log ""
 +
 +        $LN_COMMAND -fs $REPO_TARGET $LINK_TARGET
 +else
 +        log "Check if LINK_TARGET exists................................[  OK  ]"
 +fi
 +
 +# Start syncing.
 +log ""
 +log "+-----------------------------------------------------------------+"
 +log "| Run synchronizing $SCRIPT_NAME repository.................... |"
 +log "+-----------------------------------------------------------------+"
 +log ""
 +
 +log "$RSYNC_COMMAND $RSYNC_CMDOPTS $RSYNC_EXCLUDE $REPO_SOURCE $REPO_TARGET"
 +
 +$RSYNC_COMMAND $RSYNC_CMDOPTS --log-file=$FILE_LAST_LOG $RSYNC_EXCLUDE $REPO_SOURCE $REPO_TARGET
 +
 +if [ "$?" != 0 ]; then
 +        retval $?
 +        log ""
 +        $RM_COMMAND -f $FILE_LOCK
 +        sendmail ERROR
 + movelog
 +        exit 99
 +else
 +        log ""
 +        log "+-----------------------------------------------------------------+"
 +        log "| End synchronizing $SCRIPT_NAME repository.................... |"
 +        log "+-----------------------------------------------------------------+"
 +        log ""
 +fi
 +
 +# Finish syncing.
 +log "+-----------------------------------------------------------------+"
 +log "| Finish......................................................... |"
 +log "+-----------------------------------------------------------------+"
 +log ""
 +
 +# Status e-mail.
 +if [ $MAIL_STATUS = 'Y' ]; then
 +        sendmail STATUS
 +fi
 +# Move temporary log to permanent log
 +movelog
 +
 +exit 0
 +</code>
 +
 +**__Das Script hat folgende WICHTIGE Merkmale:__**
 +  * Konfigurierbare Parameter
 +  * Überprüfung ob alle Befehle zur erfolgreichen Ausführung verfügbar sind (Evtl. wichtig für Portierungen)
 +  * Ausführungsschutz, __kein__ doppelte, gleichzeitige Ausführen des Scripts
 +  * Ausgabe von Laufzeitinformationen
 +    * auf dem Bildschirm zur Laufzeit
 +    * als **LOG**-Datei
 +    * als **e-Mail**
 +  * e-Mail Benachrichtigung im Fehlerfall
 +  * **optional** e-Mail Benachrichtigung bei erfolgreicher Ausführung
 +
 +==== Einbindung als cron-job ====
 +
 +Nachfolgend soll das oben genannte Script als **''cron''**-Job mit täglicher (nächtlicher) Ausführung eingerichtet werden.
 +
 +Dazu sollte als erstes nachfolgendes Verzeichnis
 +  * **''/root/bin''**
 +mit nachfolgendem Befehl erstellt werden:
 +<code>
 +# mkdir /root/bin/
 +</code>
 +
 +Anschließend sollte das Script, in dem mit obigem Befehl erstellte Verzeichnis hinterlegt werden. Das Verzeichnis sollte wie folgt aussehen, was mit nachfolgendem Befehl überprüft werden kann:
 +<code>
 +# ls -l /root/bin
 +total 56
 +-rw-r--r--  1 root root 12874 Dec 12 14:24 rsync_centos70.sh
 +</code>
 +
 +Evtl. sollten noch die Dateirechte mit nachfolgendem Befehl, wie folgt angepasst werden:
 +<code>
 +# chmod 750 /root/bin/rsync_centos70.sh
 +</code>
 +
 +Eine erneute Abfrage des Verzeichnisses mit nachfolgendem Befehl sollte dann eine Ausgabe in etwa wie folgende ergeben:
 +<code>
 +# ls -l /root/bin
 +total 56
 +-rwxr-xr-x  1 root root 12874 Dec 12 14:24 rsync_centos70.sh
 +</code>
 +
 +=== 1. Möglichkeit ====
 +
 +Einbindung des Scripts zur Ausführung als **''cron''**-job in die Konfigurationsdatei 
 +  * **''/etc/crontab''**
 +welches in diesem Fall eine Ausführung des Scripts **täglich** um **02:00 Uhr (nachts)** veranlassen würde.
 +
 +Was durch hinzufügen von nachfolgender Zeile zur Konfigurationsdatei **''/etc/crontab''** erfolgen kann (**nur relevanter Ausschnitt**):
 +<code ini>
 +...
 +00 02 * * * root /root/bin/rsync_centos70.sh  > /dev/null 2>&1
 +...
 +</code>
 +
 +=== 2. Möglichkeit ====
 +
 +Einbindung eines **Links** auf das Scripts, zur Ausführung als **''cron''**-job in das Verzeichnis
 +  * **''/etc/cron.daily''**
 +welches in diesem Fall eine Ausführung des Scripts **täglich** je nach Konfiguration in der Konfigurationsdatei
 +  * **''/etc/anacrontab''** 
 +hier als **Standard** zwischen **03:00-22:00 Uhr, mit einer addierten Zufälligkeit von 45 Minuten und einer zufälligen Abweichung von 5 Minuten** veranlassen würde.
 +
 +Dies kann durch Ausführen des nachfolgenden Befehls erfolgen:
 +<code>
 +# ln -fs /root/bin/rsync_centos70.sh /etc/cron.daily/rsync_centos70.sh
 +</code>
 +
 +Zu Überprüfung, ob der Link korrekt erstellt wurde, kann nachfolgender Befehl ausgeführt werden:
 +<code>
 +# ls -l /etc/cron.daily
 +total 8
 +-rwxr-xr-x. 1 root root 332 Jun 27 13:07 0yum-daily.cron
 +-rwx------. 1 root root 180 Jul 31  2013 logrotate
 +-rwxr-xr-x. 1 root root 618 Mar 17  2014 man-db.cron
 +lrwxrwxrwx  1 root root  27 Dec 12 14:42 rsync_centos70.sh -> /root/bin/rsync_centos70.sh
 +</code>
 +
 +==== Logrotate ====
 +
 +Das Script **''/root/bin/rsync_centos70.sh''** erzeugt eine **LOG**-Datei mit nachfolgender Bezeichnung und folgendem Speicherort:
 +  * **''/var/log/rsync_centos70.sh''**
 +
 +Um das stetige Anwachsen und die Größe dieser **LOG**-Datei nicht ins unendliche zu treiben, wäre es sinnvoll die **LOG**-Datei mit **Linux**-Bordmitteln in regelmäßigen Abständen zu rotieren.
 +
 +Dies kann durch die Anlage eines **neuen**, nachstehend gezeigten Scripts, erfolgen. Der Speicherort muss hier:
 +  * **''/etc/logrotate.d''**
 +sein und das Script kann folgenden Namen tragen:
 +  * **''rsync_centos70''**
 +
 +Der Inhalt des Scripts **''/etc/logrotate.d/rsync_centos70''** sieht folgendermaßen aus:
 +<code ini>
 +/var/log/rsync_centos70.log {
 +    weekly
 +    rotate 4
 +    compress
 +    delaycompress
 +    missingok
 +    notifempty
 +}
 +</code>
 +
 +Demnach wird die **LOG**-Datei nach nachfolgenden Regeln rotiert:
 +  * **''weekly''** - wöchentlich
 +  * **''rotate 4''** - die letzten 4 **LOG**-Dateien sollen jeweils erhalten bleiben
 +  * **''compress''** - Alte Versionen der **LOG**-Datei werden komprimiert
 +  * **''delaycompress''** - Verschiebt die Kompression des letzten **LOG**-Datei auf den nächsten Rotationszyklus
 +  * **''missingok''** - Das __nicht__ vorhanden sein der **LOG**-Datei soll zu __keinem__ Fehler führen 
 +  * **''notifempty''** - Nicht rotieren, wenn die **LOG**-Datei leer ist
  
tachtler/repository_spiegeln_centos_7.1418388362.txt.gz · Zuletzt geändert: 2014/12/12 13:46 von klaus