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  
相關文章
相關標籤/搜索