Rsync synchronizes/linux system logs via service/screen tool

Source: Internet
Author: User
Tags system log rsync dmesg

Rsync syncs through services

This approach can be understood as setting up an rsync server on a remote host, configuring the various applications of rsync on the server, and then connecting the machine to rsync as a client of rsync Server. Here's a look at how to set up an rsync server.

Create a directory First

[Email protected] tmp]# Mkdir/tmp/rsync

Then set permissions for the directory

[Email protected] tmp]# chmod 777/tmp/rsync/

Edit the rsync configuration file

[Email protected] tmp]# vim/etc/rsyncd.conf

In the bottom of the content from the start line, copy and paste the content

port=873

Log File=/var/log/rsync.log

PID File=/var/run/rsyncd.pid

address=192.168.74.130

[ASK-02]

Path=/tmp/rsync

Use Chroot=true

Max Connections=4

Read Only=no

List=true

Uid=root

Gid=root

#auth Users=haolinux
#
# #secrets FILE=/ETC/RSYNCD.PASSWD
#
#hosts allow=192.168.74.128

  • rsync.conf configuration file parameter function
  • Port: Specify on which port to start the Rsync service, default is Port 873
  • log file: Specify log files
  • pidFile: Specify the PID files, the role of this file involves the start of services, stop and other process management operations.
  • Address: Specifies the IP that initiates the rsync service. If your machine has multiple IPs, you can specify that one of them initiates the rsync service, and if you do not specify this parameter, the default is to start on all IPs.
  • []: Specifies the module name, inside the content customization.
  • Path: Specifies the path where the data is stored.
  • Use chroot true|false: Indicates that the file is first chroot to the directory specified by the path parameter before it is transferred. The reason for this is to implement additional security, but the disadvantage is that you need roots permissions, and you cannot back up the directory files that point to external symbolic links. By default, the Chroot value is true, and it is recommended to set false if there is a soft connection file in your data.
  • Max Connections: Specifies the maximum number of connections, which defaults to 0, with no restrictions.
  • Read Only Ture|false: If true, it cannot be uploaded to the path specified by the module.
  • List: Indicates whether the module is listed when the user queries the available modules on the server, set to True is listed, and set to False to hide.
  • Uid/gid: Transfers the file with the identity of which user/group is transferred.
  • AuthUsers: Specifies the user name to use when transferring.
  • SecretsFile: Specifies the password files, which, together with the parameters above, do not use password authentication if they are not specified. Note that the password file must have permissions of 600
  • hostsallow: Represents the host that is allowed to connect to the module, either IP or network segment, if multiple, separated by a space.

Start the rsync service

[Email protected] tmp]# rsync--daemon

Check that the rsync service is started

[[Email protected] ~]# PS aux |grep rsync
Root 1482 0.0 0.0 114652 524? Ss 21:42 0:00 rsync--daemon
Root 1484 0.0 0.0 112676 984 pts/0 r+ 21:42 0:00 grep--color=auto rsync

Switch to the second machine and use Telnet to check if the port is connected properly.

[[Email protected] ~]# telnet 192.168.74.130 873
Trying 192.168.74.130 ...
Connected to 192.168.74.130.
Escape character is ' ^] '.
@RSYNCD: 30.0//This display indicates normal connectivity
^]//Button "Ctrl +]" exit
Telnet> quit
Connection closed.

The files on the first server (Ask-01) can then be sent remotely to the second server (Ask-02).

[[email protected] ~]# RSYNC-AVP cs.txt 192.168.74.130::ask-02/cs1.txt//Ask-02 This indicates the module name that you set in front of the configuration file
Sending incremental file list
Cs.txt
3384 100% 0.00kb/s 0:00:00 (xfer#1, TO-CHECK=0/1)

Sent 3454 bytes received bytes 6962.00 bytes/sec
Total size was 3384 speedup is 0.97

Linux system logs

View System Log Configuration Accessories

[Email protected] ~]# cat/etc/logrotate.conf

In-memory system logs

[Email protected] ~]# DMESG

Clearing the in-memory system log

[Email protected] ~]# dmesg-c

View the correct user login history log

[[email protected] ~]# last//binary file path (/var/log/wtmp)

View failed user Login history log

[[email protected] ~]# LASTB//binary file path (/var/log/btmp)

View the Security log

[Email protected] ~]# less/var/log/secure

Screen tool

screen is a virtual terminal
Install Screen

[email protected] ~]# Yum install-y screen

Enter Virtual terminal

[Email protected] ~]# screen

Exit The screen virtual terminal, but do not close

Ctrl + A and press D

View Virtual Terminal list

[Email protected] ~]# Screen-ls
There is a screens on:
1895.PTS-0.ASK-02 (Detached)
1 Socket in/var/run/screen/s-root.

Enter the specified virtual terminal

[Email protected] ~]# Screen-r 1985

Custom Virtual terminal name

[Email protected] ~]# screen-c "Ask_screen"

Completely exit the virtual terminal

[[Email protected] ~]# exit

Rsync synchronizes/linux system logs via service/screen tool

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.