rsync经过服务同步、Linux系统日志、screen工具

​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/
  • max connections:指定最大的链接数 ,默认是0,即没有限制
  • read only ture|false :若是为true,则不能上传到该模块指定的路径下。
  • list :表示当用户查询该服务器上的可用模块上的可用模块时,该模块是否被列出,设定为true则列出,false则隐藏
  • uid/gid :指定传输文件时以那个用户、组的身份传输。
  • auth users :指定传输时要使用的用户名。
  • secrets file :指定木马文件,该参数连同上面的参数若是不指定,则不使用密码验证。注意该密码文件的权限必定要是600.格式:用户名:密码
  • hosts allow :表示被容许链接该模块的主机,能够是IP或者网段,若是是多个,中间用空格隔开。
  • 当设置了author users 和secrets后,客户端链接服务端也须要用用户名密码了,若想在命令行中带上密码,能够设定一个密码文件。
  • rsync -avL test@192.168.56.128::test/test1/  tmp/test/ --password-file=/etc/pass
  • 其中/etc/pass内同就是一个密码,权限要改成600

 

10.34 、Linux系统日志

  • /var/log/messages   系统总日志
  • /etc/logrotate.conf 日志切割配置文而建
  • 参考http://my.oshina.net/u/2000675/blog/908189
  • dmesg命令    #dmesg -c   清空日志
  • /var/log/dmesg 日志
  • last命令,调用的文件时/var/log/wtmp
  • blast命令查看登录失败的用户,对用的文件时/var/log/btmp
  • /var/log/secure

 

[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工具

  • 为了避免让一个任务意外中断
  • nohup command &
  • screen是一个虚拟终端
  • yum install -y screen
  • screen直接回车就进入了虚拟终端
  • ctral +a 组合键再按d退出虚拟终端,但不是结束
  • screen -ls  查看虚拟终端列表
  • screen -r  id  进入指定的终端
  • screen  -S aming
  • screen -r aming  
相关文章
相关标签/搜索