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