11月1日任务linux
10.32/10.33 rsync经过服务同步vim
10.34 linux系统日志安全
10.35 screen工具服务器
10.32 、rsync经过服务同步网络
rsync.conf 样例ssh
port=873socket
log file=/var/log/rsync.logtcp
pig file=/var/run/rsyncd.pid工具
address=192.168.55.128ui
[test]
path=/tmp/rsync
use chroot=true
msx connections=4
read only=no
list=true
uid=root
gid=root
auth users=test
secrets file=/etc/rsyncd.passwa
hosts allow=192.168.55.129
[root@zgxlinux-01 ~]# vim /etc/rsyncd.conf [root@zgxlinux-01 ~]# ps aux |grep rsync root 1885 0.0 0.0 114740 528 ? Ss 19:44 0:00 rsync --daemon root 1931 0.0 0.0 112720 980 pts/0 R+ 19:47 0:00 grep --color=autorsync [root@zgxlinux-01 ~]# netstat -lntp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 192.168.56.128:873 0.0.0.0:* LISTEN 1885/rsync tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 952/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1114/master tcp6 0 0 :::22 :::* LISTEN 952/sshd tcp6 0 0 ::1:25 :::* LISTEN 1114/master #这一步报错了,表示没有路由到远程机器上去。遇到这种问题首先检查网络连通性,而后检查端口是否通。 [root@zgxlinux-01 ~]# rsync -avP /root/1.txt 192.168.56.129::test/zgx.txt rsync: failed to connect to 192.168.56.129 (192.168.56.129): No route to host (113) rsync error: error in socket IO (code 10) at clientserver.c(125) [sender=3.1.2] [root@zgxlinux-01 ~]# ping 192.168.56.128 PING 192.168.56.128 (192.168.56.128) 56(84) bytes of data. 64 bytes from 192.168.56.128: icmp_seq=1 ttl=64 time=0.053 ms 64 bytes from 192.168.56.128: icmp_seq=2 ttl=64 time=0.048 ms 64 bytes from 192.168.56.128: icmp_seq=3 ttl=64 time=0.049 ms ^C [root@zgxlinux-01 ~]# telnet 192.168.56.128 873 #显示以下表示端口也是没有问题的 Trying 192.168.56.128... Connected to 192.168.56.128. Escape character is '^]'. @RSYNCD: 31.0 #从129主机同步文件到128主机。 [root@localhost ~]# rsync -avP /tmp/zgx.txt 192.168.56.128::test/zgx-02.txt sending incremental file list zgx.txt 928 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=0/1) sent 1,021 bytes received 35 bytes 2,112.00 bytes/sec total size is 928 speedup is 0.88 [root@zgxlinux-01 ~]# ls /tmp/rsync/ #此时文件zgx.txt就同步过来到128主机了 zgx-02.txt
#刚才试验的配置文件含义
rsyncd.conf配置文件详解
port :指定在哪一个端口启动rsyncd服务,默认是873端口。
log file : 指定日志文件。
pid file : 指定pid文件,这个文件的做用设计服务的启动,中止等进程管理操做。
address ;指定启动rsyncd服务的IP ,假如你的机器有多个IP ,就能够指定有其中 一个启动rsyncd服务,若是不指定该参数,默认是在所有IP上启动。
[]: 指定模块名 ,里面的内容自定义。
path :指定数据存放的路径,
use chroot true|false : 表示在传输文件前首先chroot到path参数所指定的目录下。这样作的缘由是实现额外的安全防御,但缺点是须要以roots权限,而且不能备份指向外部的符号链接所指向的目录文件。默认状况下chroot值为true,若是你的数据当中有软连接文件,建议你设置成false。
10.3三、rsync经过服务同步(下)
#--port 8730 ,表示指定端口
[root@zgxlinux-01 ~]# rsync -avLP --port 8730 192.168,56,128::test/ /tmp/test/
10.34 、Linux系统日志
[root@zgxlinux-01 ~]# ls /var/log/messages /var/log/messages [root@zgxlinux-01 ~]# du -sh !$ du -sh /var/log/messages 640K /var/log/messages [root@zgxlinux-01 ~]# ls /var/log/messages* #Linux无限切割日志机制 /var/log/messages /var/log/messages-20181028 /var/log/messages-20181014 /var/log/messages-20181104 /var/log/messages-20181021 [root@zgxlinux-01 ~]# ls /var/log/dmesg #跟dmesg命令不要紧 ,里边是一些系统启动文件 /var/log/dmesg [root@zgxlinux-01 ~]# last #last命令调用的是/var/log/wtmp里边的日志文件,这个日志不能用cat查看,只能用这个命令看。 root pts/0 192.168.56.1 Sun Nov 4 09:22 still logged in [root@zgxlinux-01 ~]# lastb #这个命令调用的是/var/log/btmp这个日志 btmp begins Thu Nov 1 19:09:02 2018 [root@zgxlinux-01 ~]# ls /var/log/btmp /var/log/btmp
#10.35 、screen工具