Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
centos:rsynd_c8 [04.07.2020 20:34. ] – angelegt django | centos:rsynd_c8 [18.11.2024 19:02. ] (aktuell) – Externe Bearbeitung 127.0.0.1 | ||
---|---|---|---|
Zeile 9: | Zeile 9: | ||
===== Installation und Konfiguration ===== | ===== Installation und Konfiguration ===== | ||
==== manuelle Weg ==== | ==== manuelle Weg ==== | ||
- | === TFTP-Server | + | === rsync-Daemon |
Als erstes installieren wir uns die für den rsyslog-Daemon-Server notwendigen Pakete via **'' | Als erstes installieren wir uns die für den rsyslog-Daemon-Server notwendigen Pakete via **'' | ||
# | # | ||
Zeile 16: | Zeile 16: | ||
# rpm -qil rsync | # rpm -qil rsync | ||
+ | === rsync-Daemon konfigurieren === | ||
+ | Der rsync-Daemon wird über seine Konfigurationsdatei **''/ | ||
+ | Bei Bedarf lohnt sich ein Blick in diese Datei sicherlich! | ||
+ | # man / | ||
+ | Wir legen uns also unsere individuelle Konfigurationsdatei an. | ||
+ | # vim / | ||
+ | <file bash / | ||
+ | # # | ||
+ | # Django : 2020-07-04 - Musterkonfiguration rsync-Daemon unter CentOS 8 # | ||
+ | # # | ||
+ | ################################################################################ | ||
+ | # Eine Aufstellung aller möglichen Variablen findet man in der man-page zu | ||
+ | # rsyncd.conf : # man rsyncd.conf | ||
+ | # Auf der Webseite https:// | ||
+ | # findet man darüber hinaus noch viele Erklärungen zur Konfiguration des | ||
+ | # rsyn-Daemon. | ||
+ | ################################################################################ | ||
+ | ## GLOBAL PARAMETERS | ||
+ | # | ||
+ | |||
+ | # This parameter allows you to specify a " | ||
+ | # clients on each connect. This usually contains site information and any | ||
+ | # legal notices. The default is no motd file. | ||
+ | # motd file | ||
+ | |||
+ | # This parameter tells the rsync daemon to write its process ID to that file. | ||
+ | # If the file already exists, the rsync daemon will abort rather than overwrite | ||
+ | # the file. | ||
+ | # pid file = / | ||
+ | |||
+ | # Specifies the default port the daemon will listen (defaults to 873). | ||
+ | # port 873 | ||
+ | |||
+ | # Defines the default IP address where the daemon will listening. The default | ||
+ | # is listening on all IPv4 and IPv6-adresses. | ||
+ | # address | ||
+ | |||
+ | # This parameter specifies | ||
+ | # to and from that module should take place as when the daemon | ||
+ | # root. In combination with the " | ||
+ | # permissions are available. The default when run by a super-user is to | ||
+ | # switch to the system’s " | ||
+ | # to not try to change the user. See also the " | ||
+ | uid = nobody | ||
+ | |||
+ | # This parameter specifies one or more group names/IDs that will be used when | ||
+ | # accessing the module. The first one will be the default group, and any extra | ||
+ | # ones be set as supplemental groups. | ||
+ | # You may also specify a " | ||
+ | # replaced by all the normal groups for the transfer’s user (see " | ||
+ | # default when run by a super-user is to switch to your OS’s " | ||
+ | # perhaps " | ||
+ | # a non-super-user is to not change any group attributes (and indeed, your OS | ||
+ | # may not allow a non-super-user to try to change their group settings). | ||
+ | gid = nobody | ||
+ | |||
+ | # When the "log file" parameter is set to a non-empty string, the rsync daemon | ||
+ | # will log messages to the indicated file rather than using syslog. This is | ||
+ | # particularly useful on systems (such as AIX) where syslog() doesn’t work for | ||
+ | # chrooted programs. The file is opened before chroot() is called, allowing it | ||
+ | # to be placed outside the transfer. If this value is set on a per-module basis | ||
+ | # instead of globally, the global log will still contain any authorization | ||
+ | # failures or config-file error messages. | ||
+ | # If the daemon fails to open the specified file, it will fall back to using | ||
+ | # syslog and output an error about the failure. | ||
+ | # log file = / | ||
+ | |||
+ | # This parameter allows you to specify the syslog tag to use when logging | ||
+ | # messages from the rsync daemon. The default is " | ||
+ | # This setting has no effect if the "log file" setting is a non-empty string | ||
+ | # (either set in the per-modules settings, or inherited from the global | ||
+ | # settings). | ||
+ | # syslog tag = rsyncd | ||
+ | |||
+ | # This parameter allows you to specify the syslog facility name to use when | ||
+ | # logging messages from the rsync daemon. You may use any standard syslog | ||
+ | # facility name which is defined on your system. | ||
+ | # Common names are auth, authpriv, cron, daemon, ftp, kern, lpr, mail, news, | ||
+ | # security, syslog, user, uucp, local0, local1, local2, local3, local4, local5, | ||
+ | # local6 and local7. The default is daemon. This setting has no effect if the | ||
+ | # "log file" setting is a non-empty string (either set in the per-modules | ||
+ | # settings, or inherited from the global settings). | ||
+ | # syslog facility = daemon | ||
+ | |||
+ | # This parameter enables per-file logging of downloads and uploads in a format | ||
+ | # somewhat similar to that used by ftp daemons. The daemon always logs the | ||
+ | # transfer at the end, so if a transfer is aborted, no mention will be made in | ||
+ | # the log file. | ||
+ | # transfer logging = yes | ||
+ | |||
+ | # This parameter allows you to specify the maximum number of simultaneous | ||
+ | # connections you will allow. Any clients connecting when the maximum has been | ||
+ | # reached will receive a message telling them to try later. The default is 0, | ||
+ | # which means no limit. A negative value disables the module. | ||
+ | # max connections = 0 | ||
+ | |||
+ | # This parameter specifies the directory in the daemon’s filesystem to make | ||
+ | # available in this module. You must specify this parameter for each module | ||
+ | # in rsyncd.conf. | ||
+ | # path = /home/ftp | ||
+ | |||
+ | # This parameter takes a space-separated list of daemon exclude patterns. As | ||
+ | # with the client --exclude option, patterns can be qualified with " | ||
+ | # " | ||
+ | # can apply to a given module. | ||
+ | # exclude = lost+found/ | ||
+ | |||
+ | # If "use chroot" | ||
+ | # starting the file transfer with the client. This has the advantage of extra | ||
+ | # protection against possible implementation security holes, but it has the | ||
+ | # disadvantages of requiring super-user privileges, of not being able to | ||
+ | # follow symbolic links that are either absolute or outside of the new root | ||
+ | # path and of complicating the preservation of users and groups by name | ||
+ | # See rsyncd.conf man page for more options. | ||
+ | # use chroot = yes | ||
+ | |||
+ | # This parameter allows you to override the clients choice for I/O timeout for | ||
+ | # this module. Using this parameter you can ensure that rsync won’t wait on a | ||
+ | # dead client forever. The timeout is pecified in seconds. A value of zero | ||
+ | # means no timeout and is the default. A good choice for anonymous rsync | ||
+ | # daemons may be 600 (giving a 10 minute timeout). | ||
+ | timeout = 600 | ||
+ | |||
+ | # This tells the rsync daemon to completely ignore files that are not readable | ||
+ | # by the user. This is useful for public archives that may have some non-read- | ||
+ | # able files among the directories, | ||
+ | # to be seen at all. | ||
+ | # ignore nonreadable = yes | ||
+ | |||
+ | # This parameter allows you to select filenames based on wildcard patterns that | ||
+ | # should not be compressed when pulling files from the daemon (no analogous | ||
+ | # parameter exists to govern the pushing of files to a daemon). Compression is | ||
+ | # expensive in terms of CPU usage, so itis usually good to not try to compress | ||
+ | # files that won’t compress well, such as already compressed files. | ||
+ | # The "dont compress" | ||
+ | # tive wildcard patterns. Any source filename matching one of the patterns will | ||
+ | # not be compressed during transfer. | ||
+ | # dont compress | ||
+ | |||
+ | ################################################################################ | ||
+ | ## MODULES | ||
+ | # | ||
+ | # A module begins with the name of the module in square brackets and continues | ||
+ | # until the next module begins. Modules contain parameters of the form | ||
+ | # "name = value" | ||
+ | |||
+ | # This parameter specifies the directory in the daemon’s filesystem to make | ||
+ | # available in this module. You must specify this parameter for each module in | ||
+ | # rsyncd.conf. | ||
+ | # path = / | ||
+ | |||
+ | # This parameter specifies a description string that is displayed next to the | ||
+ | # module name when clients obtain a list of available modules. | ||
+ | # The default is no comment. | ||
+ | # comment = | ||
+ | |||
+ | # This parameter determines whether this module is listed when the client asks | ||
+ | # for a listing of available modules. In addition, if this is false, the daemon | ||
+ | # will pretend the module does not exist when a client denied by "hosts allow" | ||
+ | # or "hosts deny" attempts to access it. Realize that if " | ||
+ | # disabled globally but enabled for the module, the resulting reverse lookup | ||
+ | # to a potentially client-controlled DNS server may still reveal to the client | ||
+ | # that it hit an existing module. The default is for modules to be listable. | ||
+ | # list = yes | ||
+ | |||
+ | # This parameter allows you to specify a list of comma- and/or whitespace- | ||
+ | # separated patterns that are matched against a connecting | ||
+ | # and IP address. If the pattern matches then the connection is rejected. | ||
+ | # hosts deny = 192.168.1.0/ | ||
+ | |||
+ | # This parameter allows you to specify a list of comma- and/or whitespace- | ||
+ | # separated patterns that are matched against a connecting | ||
+ | # hostname and IP address. If none of the patterns match, then the connec- | ||
+ | # tion is rejected. | ||
+ | # hosts allow = *.nausch.org | ||
+ | |||
+ | # Module examples: | ||
+ | # [ftp] | ||
+ | # path = / | ||
+ | # comment | ||
+ | # | ||
+ | # [object] | ||
+ | # max connections = 2 | ||
+ | # path = /srv/node/ | ||
+ | # read only = false | ||
+ | # write only = no | ||
+ | # list = yes | ||
+ | # incoming chmod = 0644 | ||
+ | # outgoing chmod = 0644 | ||
+ | # lock file = / | ||
+ | # hosts allow = *.nausch.org | ||
+ | |||
+ | #[REPO] | ||
+ | #path = / | ||
+ | # | ||
+ | #allow = 88.217.171.167 | ||
+ | |||
+ | [demo] | ||
+ | max connections = 2 | ||
+ | path = / | ||
+ | comment | ||
+ | list = yes | ||
+ | hosts allow = 10.0.0.0/ | ||
+ | |||
+ | === rsynd.service starten ===== | ||
+ | Nun ist es an der Zeit unseren rsync-Daemon Server das erste mal mit Hilfe von **systemd** zu starten. | ||
+ | # systemctl start rsyncd.service | ||
+ | |||
+ | Im Syslog wird uns der Start des Daemon entsprechend protokolliert. | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | Ob auf unserem Server nun der TFTP Server läuft und auf Port **69** horcht können wir bei Bedarf auch noch überprüfen. | ||
+ | # netstat -tulpen | grep 873 | ||
+ | |||
+ | < | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | </ | ||
+ | |||
+ | |||
+ | Ebenso kann man den Status des Daemons mit Hilfe des Befehls **systemctl** abfragen. | ||
+ | # systemctl status rsyncd.service | ||
+ | |||
+ | < | ||
+ | <font style=" | ||
+ | | ||
+ | | ||
+ | Main PID: 5920 (rsync) | ||
+ | Tasks: 1 (limit: 12494) | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Jul 05 00:03:30 vml000190.dmz.nausch.org systemd[1]: Started fast remote file copy program daemon. | ||
+ | Jul 05 00:03:30 vml000190.dmz.nausch.org rsyncd[5920]: | ||
+ | </ | ||
+ | |||
+ | Den automatischen Start unseres TFTP-Serverdienstes aktivieren wir für den Systemstart nun noch mit: | ||
+ | # systemctl enable rsyncd.service | ||
+ | |||
+ | Created symlink / | ||
+ | |||
+ | Ob der rsyncd-Service gestartet wird können wir bei Bedarf wie folgt abfragen: | ||
+ | # systemctl is-enabled rsyncd.service | ||
+ | |||
+ | enabled | ||
Zeile 24: | Zeile 271: | ||
Damit die Clients später Verbindungsanfragen zu dem geöffneten Port **tftp/ | Damit die Clients später Verbindungsanfragen zu dem geöffneten Port **tftp/ | ||
- | Unter **[[# | + | Unter **[[# |
Im ersten Konfigurationsbeispiel werden wir nun den Port **873/tcp** für alle öffnen, also unabhängig von der source-IP-Adresse können alle vbeliebeigen clients Daten synchronisieren. Mit Hilfe des Programms **firewall-cmd** legen wir nun eine **permanente** Regel in der Zone **public** für den Port ***873/ | Im ersten Konfigurationsbeispiel werden wir nun den Port **873/tcp** für alle öffnen, also unabhängig von der source-IP-Adresse können alle vbeliebeigen clients Daten synchronisieren. Mit Hilfe des Programms **firewall-cmd** legen wir nun eine **permanente** Regel in der Zone **public** für den Port ***873/ | ||
Zeile 71: | Zeile 318: | ||
+ | ==== automatisierter Weg mit Hilfe von Ansible ==== | ||
+ | Da wir aber in unserer Produktiven Umgebung alle Server, Dienste und Services mit Hilfe von **[[centos: | ||
+ | |||
+ | /* | ||
+ | Erzeugen des tar.gz einer Ansible-Rolle: | ||
+ | $ cd ~/ | ||
+ | $ tar -czvPf / | ||
+ | */ | ||
+ | |||
+ | |||
+ | Wir holen uns also das Verzeichnis mit der **role** auf unseren Rechner. | ||
+ | $ wget https:// | ||
+ | |||
+ | Da wir bei der Installation und **[[centos: | ||
+ | $ tar -xvf ansible-role-rsync.tar.gz -C ~/ | ||
+ | |||
+ | Jetzt brauchen wir nur noch die Rolle unserem Server **rsync-server** zuordnen. | ||
+ | $ vim ~/ | ||
+ | |||
+ | <file yml ~/ | ||
+ | - hosts: rsync-server | ||
+ | |||
+ | roles: | ||
+ | #- base # Basiskonfiguration (User anlegen) | ||
+ | #- chrony # Installation und Konfiguration NTP-Client | ||
+ | - rsync # Installation und Konfiguration rsync-Daemon | ||
+ | |||
+ | ... # Ende des Playbooks für den rsyncd-Server | ||
+ | </ | ||
+ | |||
+ | Bevor wir nun das Playbook ausführen, passen wir noch ggf. die Firewall-Einstellungen an. Beispiele dazu sind im entsprechenden **'' | ||
+ | $ vim ~/ | ||
+ | <file bash ~/ | ||
+ | - name: "*{{ daemon_name }}* : Firewall-Daemon für den {{ daemon_name }} anpassen" | ||
+ | firewalld: # | ||
+ | zone: public | ||
+ | port: 873/tcp | ||
+ | permanent: yes | ||
+ | immediate: yes | ||
+ | state: enabled | ||
+ | # | ||
+ | #zone: public | ||
+ | #rich_rule: rule family=" | ||
+ | #permanent: yes | ||
+ | #immediate: yes | ||
+ | #state: enabled</ | ||
+ | |||
+ | Die Definition der Parameter für den **'' | ||
+ | $ vim ~/ | ||
+ | <file yml ~/ | ||
+ | daemon_name | ||
+ | config_file | ||
+ | config_backup_file | ||
+ | template_file | ||
+ | # rsyncd config-options | ||
+ | rsyncd_motd | ||
+ | rsyncd_pid | ||
+ | rsyncd_port | ||
+ | rsyncd_address | ||
+ | rsyncd_uid | ||
+ | rsyncd_gid | ||
+ | rsyncd_log_file | ||
+ | rsyncd_syslog_tag | ||
+ | rsyncd_syslog_facility | ||
+ | rsyncd_transfer_logging | ||
+ | rsyncd_max_connections | ||
+ | rsyncd_path | ||
+ | rsyncd_exclude | ||
+ | rsyncd_use_chroot | ||
+ | rsyncd_timeout | ||
+ | rsyncd_ignore_nonreadable: | ||
+ | rsyncd_dont_compress | ||
+ | rsyncd_module | ||
+ | </ | ||
+ | |||
+ | <WRAP center round tip 80%> | ||
+ | Wenn man die hostspezfische Konfiguration des rsync-Daemon lieber in der Host-spezifischen Konfiguration vornehmen möchte, braucht man die **# rsyncd config-options** nur hier bei der Rolle auskommentieren bzw. löschen und in die Hostvariable im Inverntory aufnehmen. | ||
+ | <WRAP center round important 100%> | ||
+ | **WICHTIG**: | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | Nun brauchen wir nur noch das Playbook ausführen und unser TFTP-Server steht bereit. | ||
+ | $ ansible-playbook -v ~/ | ||
+ | |||
+ | < | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | |||
+ | PLAY [rsync-server] ******************************************************************************************************************** | ||
+ | |||
+ | TASK [Gathering Facts] *****************************************************************************************************************</ | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" | ||
+ | <font style=" |