(11)Linux 服務器安裝配置rsync服務,並實現兩臺機器同步文件


1111111111111111111111111111111
[root@dn3-hadoop2 ~]# yum -y install xinetd;vi /etc/xinetd.d/rsync
Loaded plugins: security
CentOS6-Base                                                                                                   | 3.7 kB     00:00     
CentOS6-Base/primary_db                                                                                        | 4.6 MB     00:01     
CentOS6-Updates                                                                                                | 3.4 kB     00:00     
CentOS6-Updates/primary_db                                                                                     | 2.1 MB     00:00     
epel_SOHU-6-x86_64                                                                                             | 4.4 kB     00:00     
epel_SOHU-6-x86_64/primary_db                                                                                  | 6.4 MB     00:03     
rsyslog_v7                                                                                                     | 2.5 kB     00:00     
rsyslog_v7/primary_db                                                                                          | 387 kB     00:00     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package xinetd.x86_64 2:2.3.14-39.el6_4 will be installed
--> Finished Dependency Resolution


Dependencies Resolved


======================================================================================================================================
 Package                    Arch                       Version                                 Repository                        Size
======================================================================================================================================
Installing:
 xinetd                     x86_64                     2:2.3.14-39.el6_4                       CentOS6-Base                     121 k


Transaction Summary
======================================================================================================================================
Install       1 Package(s)


Total download size: 121 k
Installed size: 259 k
Downloading Packages:
xinetd-2.3.14-39.el6_4.x86_64.rpm                                                                              | 121 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : 2:xinetd-2.3.14-39.el6_4.x86_64                                                                                    1/1 
  Verifying  : 2:xinetd-2.3.14-39.el6_4.x86_64                                                                                    1/1 


Installed:
  xinetd.x86_64 2:2.3.14-39.el6_4                                                                                                     


Complete!


# default: off
# description: The rsync server is a good addition to an ftp server, as it \
#       allows crc checksumming etc.
service rsync
{
        disable = yes
        flags           = IPv6
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/bin/rsync
        server_args     = --daemon
        log_on_failure  += USERID
}

2222222222222222222222222222222222222222

將/etc/xinetd.d/rsync中的 
disable = yes 改成 disable = no 。爲與58.111保持一致flags = IPv6  刪除(此操作有誤意義待知)


333333333333333333333333333333333333333333
cat: /etc/rsyncd.conf: No such file or directory
[root@dn3-hadoop2 ~]# vi /etc/rsyncd.conf(將15.4 nn1節點的對應文件的內容 賦值到該文本中)


port = 873
uid = root
gid = root
user chroot = no
max connections = 200
timeout = 600
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock
log file = /var/log/rsyncd.log

[backup]
path = /mnt/resource/data/      #(此處注意path的配置!!!!!)
ignore errors
read only = no
list = no
#hosts allow = 192.168.1.0/255.255.255.0
auth users = root
secrets file = /etc/rsyncd.secrets

44444444444444444444444444444444444444444444444444444

[root@dn3-hadoop2 ~]# echo 'root:123456789'>/etc/rsyncd.passwd;chown root:root /etc/rsyncd.secrets;chmod 600 /etc/rsyncd.secrets;yum -y install rsync;echo '123456789'>/etc/rsyncd.passwd;chmod 600 /etc/rsyncd.passwd
chown: cannot access `/etc/rsyncd.secrets': No such file or directory
chmod: cannot access `/etc/rsyncd.secrets': No such file or directory
Loaded plugins: security
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package rsync.x86_64 0:3.0.6-9.el6 will be updated
---> Package rsync.x86_64 0:3.0.6-12.el6 will be an update
--> Finished Dependency Resolution


Dependencies Resolved


======================================================================================================================================
 Package                     Arch                         Version                            Repository                          Size
======================================================================================================================================
Updating:
 rsync                       x86_64                       3.0.6-12.el6                       CentOS6-Base                       335 k


Transaction Summary
======================================================================================================================================
Upgrade       1 Package(s)


Total download size: 335 k
Downloading Packages:
rsync-3.0.6-12.el6.x86_64.rpm                                                                                  | 335 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : rsync-3.0.6-12.el6.x86_64                                                                                          1/2 
  Cleanup    : rsync-3.0.6-9.el6.x86_64                                                                                           2/2 
  Verifying  : rsync-3.0.6-12.el6.x86_64                                                                                          1/2 
  Verifying  : rsync-3.0.6-9.el6.x86_64                                                                                           2/2 


Updated:
  rsync.x86_64 0:3.0.6-12.el6                                                                                                         


Complete!
[root@dn3-hadoop2 ~]# 

555555555555555555555555555555555555555555555555555555
[root@dn3-hadoop2 ~]# echo 'root:123456789'>/etc/rsyncd.secrets;echo '123456789'>/etc/rsyncd.passwd;

[root@dn3-hadoop2 ~]# 


666666666666666666666666666666666666666666666666666666
[root@dn3-hadoop2 ~]# chown root:root /etc/rsyncd.secrets;chmod 600 /etc/rsyncd.secrets;chmod 600 /etc/rsyncd.passwd;
[root@dn3-hadoop2 ~]# 


7777777777777777777777777777777777777777777777777
[root@dn3-hadoop2 ~]# rsync --daemon
[root@dn3-hadoop2 ~]# ps -ef |grep rsync
34391 ?        00:00:00 rsync
[root@dn3-hadoop2 ~]# ps -ef |grep rsync
root     34391     1  0 10:24 ?        00:00:00 rsync --daemon
root     34402 34034  0 10:24 pts/1    00:00:00 grep rsync
#####################################################################
8888888888888888888888888888888888888888888

另一臺機器上運行命令

/usr/bin/rsync -avz --progress --exclude-from '/usr/local/scripts/exclude.txt' --password-file=/etc/rsyncd.passwd /data/logs/flume [email protected]::backup

執行出錯~~!!!!

在0.105上跑 rsync腳本報錯:
rsync error: error starting client-server protocol (code 5) at main.c(1530) [sender=3.0.6]

原因 同步到15.8上的 路徑文件夾不存在 創建。
mkdir data
mkdir flume

另一臺《15.9》
rsync error: error starting client-server protocol (code 5) at main.c(1530) [sender=3.0.6]

創建了文件還是錯  ,重啓 rsync可以了。

===============================================================================

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章