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
报错,可尝试查看网络是否有问题,或者端口是否通linux
telnet 192.168.244.128 873 检查873端口(如未安装telnet 先安装)安全
发现端口有问题,能够先停掉firewalld,在测试端口是否通,成功~网络
systemctl stop firewalldssh
退出telnet 打“]” quit 工具
运行同步命令rsync -av 1.txt 192.168.244.128::test/1_dest.txt (test是模块名字)测试
[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]
提示输入密码,能够修改配置文件,将以下两行注释掉。ui
再次执行同步命令,成功~this
[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
配置文件中list =true 表示能够列出该服务有多少模块,false 不能列出spa
用法:rsync --port 873 192.168.198.128::日志
[root@g_linux02 ~]# rsync --port 873 192.168.198.128:: ben
auth users=test //用户名
secrets file=/etc/rsyncd.passwd //密码文件
编辑密码文件 vi /etc/rsyncd.passwd------------添加test:123456
更改密码文件权限为600
再执行rsync --port 873 test@192.168.198.128::ip 输入密码才能同步
若是不想输入密码,能够在客户端增长一个密码文件,如:/etc/rsync_passwd.txt
密码文件中写入密码123456,更改密码文件权限为600
运行rsync --port 873 --passwd-file=/etc/rsync_passwd.txt test@192.168.198.128::ip
/etc/logrotate.conf日志切割配置文件,会将日志切割成4份,
[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 -c清空,重启后会在加载。日志存在内存中。
/var/log/dmesg系统启动的日志
last 正确的登陆历史-------last 调用的文件是/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)
lastb 登陆失败的历史 -------调用的文件是 /var/log/btmp
[root@glinux-01 ~]# lastb btmp begins Sun Mar 18 19:15:09 2018
安全日志 /var/log/secure (好比登陆密码输错等信息会写入这个日志)
应用场景:好比我一个脚本要执行一天一晚上,那我为了防止ssh远程链接出现异常中断(好比网络缘由),解决方法1:丢到后台nohup command & (但这种方法无法实时查看输出信息)
方法2:使用虚拟终端
[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