rsync via service synchronization, linux system log, screen tool

rsync sync via service

  • Edit the configuration file /etc/rsyncd.conf

port=873
log file=/var/log/rsync.log
pid file=/var/run/rsyncd.pid
address=192.168.244.128   //本机ip
[test] //模块名
path=/tmp/rsync  //路径      
use chroot=true  //true 代表不能同步其他目录 false 代表可以同步其他目录
max connection=4
read only=no
list=true
uid=root
gid=root
auth users=test
secrets file=/etc/rsyncd.passwd
hosts allow=192.168.244.129   //指定连通的机器,多个ip用空格分开,也可1/25

 

  • rsync --daemon start service

  • Syntax: rsync -av 1.txt [the ip of the machine where the service is located]::[module name]/1_dest.txt

If an error is reported, you can try to check whether there is a problem with the network or whether the port is connected.

telnet 192.168.244.128 873 Check port 873 (if telnet is not installed, install it first)

If there is a problem with the port, you can stop firewalld first, and test whether the port is connected, successful~

systemctl stop firewalld

Exit telnet and hit "]" quit 

Run the sync command rsync -av 1.txt 192.168.244.128::test/1_dest.txt (test is the module name)

[root@glinux-02 ~]# rsync -av 1.txt 192.168.244.128::test
Password: 
@ERROR: auth failed on module test
rsync error: error starting client-server protocol (code 5) at main.c(1516) [sender=3.0.9]

When prompted for a password, you can modify the configuration file and comment out the following two lines.

Execute the synchronization command again, success~

[root@glinux-02 ~]# rsync -av 1.txt 192.168.244.128::test/1_dest.txt
sending incremental file list
1.txt

sent 65 bytes  received 27 bytes  184.00 bytes/sec
total size is 0  speedup is 0.00

change port

  1. Change configuration file port=8730
  2. killall rsync kill process
  3. Restart the service rsync daemon
  4. rsync -acLP --port 8730 ip::test/ /tmp/test plus --port

In the configuration file, list =true means how many modules can be listed in the service, and false cannot be listed

Usage: rsync --port 873 192.168.198.128::

[root@g_linux02 ~]# rsync --port 873 192.168.198.128::
ben            	

set user password,

auth users=test //username
secrets file=/etc/rsyncd.passwd //password file

Edit the password file vi /etc/rsyncd.passwd------------add test:123456

Change password file permissions to 600

Then execute rsync --port 873 [email protected]::ip and enter the password to synchronize.
If you do not want to enter the password, you can add a password file on the client side, such as: /etc/rsync_passwd.txt  

Write the password 123456 in the password file, change the password file permission to 600

运行rsync --port 873 --passwd-file=/etc/rsync_passwd.txt   [email protected]::ip

 

linux system log

/var/log/messages total system log

The /etc/logrotate.conf log cutting configuration file will cut the log into 4 parts,

[root@glinux-01 ~]# cat /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files weekly
weekly   每星期切割

# keep 4 weeks worth of backlogs
rotate 4   切割4星期

# create new (empty) log files after rotating old ones
create 覆盖旧文件

# use date as a suffix of the rotated file
dateext  日期

# uncomment this if you want your log files compressed
#compress 是否压缩

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d 配置文件

# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
    monthly
    create 0664 root utmp
	minsize 1M
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0600 root utmp
    rotate 1
}

# system-specific logs may be also be configured here.
[root@glinux-01 ~]# ls /var/log/message*
/var/log/messages           /var/log/messages-20180311  /var/log/messages-20180326
/var/log/messages-20180304  /var/log/messages-20180318

dmesg View hardware log files

dmesg -c is cleared, and it will be loaded after restarting. Logs are stored in memory.

/var/log/dmesg system startup log

last correct log history -------last called file is /var/log/wtmp

[root@glinux-01 ~]# last
root     pts/0        192.168.244.1    Thu Mar 29 19:14   still logged in   
root     tty1                          Wed Mar 28 21:43   still logged in   
root     pts/0        192.168.244.1    Wed Mar 28 21:43 - 22:25  (00:42)    
root     pts/0        192.168.244.1    Wed Mar 28 19:53 - 21:43  (01:49)    
root     pts/0        192.168.244.1    Tue Mar 27 19:52 - 22:25  (02:33)    
root     pts/1        192.168.244.1    Mon Mar 26 19:37 - 20:21 (1+00:44)  

The history of lastb login failures ------- the file called is /var/log/btmp

[root@glinux-01 ~]# lastb

btmp begins Sun Mar 18 19:15:09 2018

Security log /var/log/secure (for example, the wrong login password will be written to this log)

screen tool (virtual terminal)

Application scenario: For example, if I want to execute a script for one day and one night, in order to prevent abnormal interruption of ssh remote connection (such as network reasons), solution 1: throw it into the background nohup command & (but this method cannot view the output information in real time)

Method 2: Use a virtual terminal 

  • screen (exit to exit)
  • ctrl + a plus d to exit the terminal, but the task is executed in the background
  • screen -ls View the list of virtual terminals
  • screen -r id enter the specified terminal
[root@glinux-01 ~]# screen
[detached from 10491.pts-0.glinux-01]
[root@glinux-01 ~]# screen -ls
There is a screen on:
	10491.pts-0.glinux-01	(Detached)
1 Socket in /var/run/screen/S-root.

[root@glinux-01 ~]# screen -r 10491
  • screen -S "custom terminal name" 
  • screen -r "custom terminal name" enter the terminal name

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325118547&siteId=291194637