[[email protected] ~]# mkdir /tmp/rsync
[[email protected] ~]# chmod 777 /tmp/rsync
第二个机器
[[email protected] ~]# rsync -avP /tmp/lizhipeng.txt 192.168.5.128::test/lizhipeng0129.txt
rsync: failed to connect to 192.168.5.128 (192.168.5.128): No route to host (113) 不通,检查下原因
rsync error: error in socket IO (code 10) at clientserver.c(122) [sender=3.0.9]
[[email protected] ~]# ping 192.168.5.128
PING 192.168.5.128 (192.168.5.128) 56(84) bytes of data. 能ping通,再检查下telent
64 bytes from 192.168.5.128: icmp_seq=1 ttl=64 time=0.351 ms
64 bytes from 192.168.5.128: icmp_seq=2 ttl=64 time=0.218 ms
64 bytes from 192.168.5.128: icmp_seq=3 ttl=64 time=1.08 ms
^C
--- 192.168.5.128 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.218/0.552/1.089/0.384 ms
[[email protected] ~]# telnet 192.168.5.128 873 检查端口是否通,不通,检查一下iptables
Trying 192.168.5.128...
telnet: connect to address 192.168.5.128: No route to host
[[email protected] ~]# systemctl stop firewalld 关闭firewalld,机器1同样
[[email protected] ~]# telnet 192.168.5.128 873 通了
Trying 192.168.5.128...
Connected to 192.168.5.128.
Escape character is ‘^]‘.
@RSYNCD: 30.0
[[email protected] ~]# rsync -avP /tmp/lizhipeng.txt 192.168.5.128::test/lizhipeng0129.txt
Password:
密码关闭
[[email protected] ~]# rsync -avP /tmp/lizhipeng.txt 192.168.5.128::test/lizhipeng0129.txt 同步成功
sending incremental file list
lizhipeng.txt
1244 100% 0.00kB/s 0:00:00 (xfer#1, to-check=0/1)
sent 1321 bytes received 27 bytes 898.67 bytes/sec
total size is 1244 speedup is 0.92
[[email protected] ~]# ls /tmp/rsync/ 1机器下有这个文件
lizhipeng0129.txt
[[email protected] ~]# rsync -avP 192.168.5.128::test/lizhipeng0129.txt /tmp/123.txt 机器1同步到机器2
receiving incremental file list
lizhipeng0129.txt
1244 100% 1.19MB/s 0:00:00 (xfer#1, to-check=0/1)
sent 45 bytes received 1356 bytes 2802.00 bytes/sec
total size is 1244 speedup is 0.89
[[email protected] ~]# cd /tmp/rsync/
[[email protected] rsync]# ls
lizhipeng0129.txt
[[email protected] rsync]# ln -s /etc/passwd ./12.txt 机器1创建软链接12.txt指向/etc/passwd
[[email protected] rsync]# ls -l
总用量 4
lrwxrwxrwx 1 root root 11 1月 30 07:32 12.txt -> /etc/passwd
-rw-r--r-- 1 root root 1244 1月 29 01:06 lizhipeng0129.txt
机器2同步目录
[[email protected] ~]# rsync -avP 192.168.5.128::test/ /tmp/test/
receiving incremental file list
created directory /tmp/test
./
12.txt -> /etc/passwd
lizhipeng0129.txt
1244 100% 1.19MB/s 0:00:00 (xfer#1, to-check=0/3)
sent 51 bytes received 1407 bytes 2916.00 bytes/sec
total size is 1255 speedup is 0.86
没有同步成功
改成false
[[email protected] ~]# rsync -avP 192.168.5.128::test/ /tmp/test/ 同步成功了
receiving incremental file list
12.txt -> /etc/passwd
sent 29 bytes received 117 bytes 292.00 bytes/sec
total size is 1255 speedup is 8.60
[[email protected] ~]# ls -l /tmp/test/
总用量 4
lrwxrwxrwx. 1 root root 11 1月 30 07:32 12.txt -> /etc/passwd
-rw-r--r--. 1 root root 1244 1月 29 01:06 lizhipeng0129.txt
[[email protected] ~]#
[[email protected] ~]# rsync -avLP 192.168.5.128::test/ /tmp/test/ 机器2同步出错,因为端口号不对
rsync: failed to connect to 192.168.5.128 (192.168.5.128): Connection refused (111)
rsync error: error in socket IO (code 10) at clientserver.c(122) [Receiver=3.0.9]
[[email protected] ~]# rsync -avLP --port 8730 192.168.5.128::test/ /tmp/test/ --port 8730指定端口号
receiving incremental file list
./
12.txt
1244 100% 1.19MB/s 0:00:00 (xfer#1, to-check=2/4)
lizhipeng0130.txt
1244 100% 1.19MB/s 0:00:00 (xfer#2, to-check=0/4)
sent 67 bytes received 2701 bytes 5536.00 bytes/sec
total size is 3732 speedup is 1.35
[[email protected] ~]# vim /etc/rsyncd.conf
权限不够
[[email protected] ~]# vim /etc/rsyncd.conf uid,gid改成root
[[email protected] ~]# cd /tmp/rsync/
[[email protected] rsync]# ls
12.txt lizhipeng0129.txt lizhipeng0130.txt
[[email protected] rsync]# chmod 600 !$
chmod 600 /etc/rsyncd.passwd
[[email protected] ~]# rsync -avP /tmp/test/ --port=8730 [email protected]::test/
Password:
sending incremental file list
./
sent 105 bytes received 20 bytes 19.23 bytes/sec
total size is 3732 speedup is 29.86
[[email protected] ~]# touch /tmp/test/1.txt
[[email protected] ~]# rsync -avP /tmp/test/ --port=8730 [email protected]::test/
Password:
sending incremental file list
./
1.txt
0 100% 0.00kB/s 0:00:00 (xfer#1, to-check=3/5)
sent 149 bytes received 30 bytes 32.55 bytes/sec
total size is 3732 speedup is 20.85
客户端填写密码
[[email protected] ~]# vim /etc/rsync_pass.txt
[[email protected] ~]# chmod 600 !$
chmod 600 /etc/rsync_pass.txt
[[email protected] ~]# touch /tmp/test/2.txt
[[email protected] ~]# rsync -avP /tmp/test/ --port=8730 --password-file=/etc/rsync_pass.txt [email protected]::test/ 不需要输入密码
sending incremental file list
./
2.txt
0 100% 0.00kB/s 0:00:00 (xfer#1, to-check=2/6)
sent 163 bytes received 30 bytes 386.00 bytes/sec
total size is 3732 speedup is 19.34
[[email protected] ~]# ls /var/log/message*
/var/log/messages /var/log/messages-20180108 /var/log/messages-20180114 /var/log/messages-20180121 /var/log/messages-20180128
[[email protected] ~]# dmesg -c 清空日志 内存中的
[[email protected] ~]# last 记录正确的登陆时间
[[email protected] ~]# lastb 登陆失败
btmp begins Wed Jan 31 05:37:48 2018
[[email protected] ~]# ls /var/log/btmp
/var/log/btmp
[[email protected] ~]# ls /var/log/secure
/var/log/secure
[[email protected] ~]# screen ctrl+a同时按,然后按d
[detached from 3389.pts-0.lizhipenglinux01]
[[email protected] ~]# screen -ls
There is a screen on:
3389.pts-0.lizhipenglinux01 (Detached)
1 Socket in /var/run/screen/S-root.
[[email protected] ~]# screen -r 3389. 回去
[[email protected] ~]# screen
[detached from 3430.pts-0.lizhipenglinux01]
[[email protected] ~]# screen
[detached from 3449.pts-0.lizhipenglinux01]
[[email protected] ~]# screen
[detached from 3468.pts-0.lizhipenglinux01]
[[email protected] ~]# screen -lsn
There are screens on:
3468.pts-0.lizhipenglinux01 (Detached)
3449.pts-0.lizhipenglinux01 (Detached)
3430.pts-0.lizhipenglinux01 (Detached)
3 Sockets in /var/run/screen/S-root.
[[email protected] ~]# screen -r 3468.
[detached from 3468.pts-0.lizhipenglinux01]
[[email protected] ~]# screen -lsn
There are screens on:
3468.pts-0.lizhipenglinux01 (Detached)
3449.pts-0.lizhipenglinux01 (Detached)
3430.pts-0.lizhipenglinux01 (Detached)
3 Sockets in /var/run/screen/S-root.
[[email protected] ~]# screen -S "test_screen"
[detached from 3499.test_screen]
[[email protected] ~]# screen -ls
There are screens on:
3499.test_screen (Detached)
3468.pts-0.lizhipenglinux01 (Detached)
3449.pts-0.lizhipenglinux01 (Detached)
3430.pts-0.lizhipenglinux01 (Detached)
4 Sockets in /var/run/screen/S-root.
原文地址:https://www.cnblogs.com/sisul/p/8387833.html