scp跟cp类型,默认只能复制普通文件
复制目录,加上-r参数即可
[root@backup ~]# scp /etc/ 172.16.1.31:/tmp
[email protected]'s password:
/etc: not a regular file
远程服务器没有rsync这个命令,rsync这个命令是默认安装的,检查如果没有,yum install -y rsync 安装即可
[root@backup ~]# rsync -av /etc 172.16.1.31:/tmp
[email protected]'s password:
bash: rsync: command not found
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: remote command not found (code 127) at io.c(226) [sender=3.1.2]
1>检查是否能ping通对应服务器。
2>检查对应服务器的rsync服务是否启动,如果没有,启动即可。
[root@backup ~]# rsync -avz /etc 176.16.1.31:/tmp
ssh: connect to host 176.16.1.31 port 22: Connection refused
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]
未知模块“backup”
1>模块写错了,与rsync配置文件中配置的模块不一致,修改一致即可
2>书写的
[root@nfs01 ~]# rsync -avz /etc/hostname [email protected]::backup
@ERROR: Unknown module 'backup'
rsync error: error starting client-server protocol (code 5) at main.c(1648) [sender=3.1.2]
[root@nfs01 ~]#
1>密码写错
2>rsync服务/etc/rsyncd.conf配置文件中用户连接认证密码文件不存在,添加即可
3>密码文件的权限不对,修改600即可
[root@nfs01 ~]# rsync -avz /etc/hostname [email protected]::data
Password:
@ERROR: auth failed on module data
rsync error: error starting client-server protocol (code 5) at main.c(1648) [sender=3.1.2]
[root@nfs01 ~]#
[root@web01 ~]# rsync -avz /etc/hostname [email protected]::backup --password-file /etc/rsync.password
ERROR: password file must not be other-accessible
rsync error: syntax or usage error (code 1) at authenticate.c(196) [sender=3.1.2]
[root@web01 ~]#
[root@backup ~]# rsync -avz /etc/hosts [email protected]::data
sending incremental file list
rsync: read error: Connection reset by peer (104)
rsync error: error in socket IO (code 10) at io.c(785) [sender=3.1.2]
备份服务上的/backup目录不存在,去服务端创建并修改所有者和所有属组即可
[root@web01 /]# rsync -az /backup [email protected]::backup --password-file /etc/rsync.password
@ERROR: chdir failed
rsync error: error starting client-server protocol (code 5) at main.c(1648) [sender=3.1.2]
在/etc/mail.rc中配置可以使用外部SMTP服务器的配置时,配置错误,重新修改正确即可
[root@backup ~]# mail -s "dddddd" [email protected]
--password文件选项只能在访问rsync守护进程时使用
推送的格式书写错误::,修改即可
[root@web01 ~]# sh /server/scripts/client_rsync_backup.sh
tar: Removing leading `/' from member names
The --password-file option may only be used when accessing an rsync daemon.
rsync error: syntax or usage error (code 1) at main.c(1382) [sender=3.1.2]
[root@web01 ~]#
1>密码写错
2>密码文件不存在
3>密码文件权限不对
4>没有创建data这个目录
@ERROR: auth failed on module backup
rsync error: error starting client-server protocol (code 5) at main.c(1648) [sender=3.1.2]
服务端的nfs服务未重启,重启即可
[root@web01 ~]# showmount -e 10.0.0.31
clnt_create: RPC: Program not registered
[root@web01 ~]#
挂载的时候,mount -t 后面一定要指定文件系统类型
[root@web01 ~]# mount -t 172.16.1.31:/app/r /data/r
mount: can't find /data/r in /etc/fstab
只能查看,不能写入
[root@web01 ~]# touch /data/r/aa.txt
touch: cannot touch ‘/data/r/aa.txt’: Read-only file system
原因1:需要挂载的目录不存在,创建即可
原因2:共享的目录不能自己挂载自己
[root@backup ~]# mount -t nfs 172.16.1.31:/app/w /data/w
mount.nfs: mount point /data/w does not exist
[root@nfs01 ~]# mount -t nfs 172.16.1.31:/nfs /nfs
mount.nfs: mount point /nfs does not exist
资源设备正在使用中,不能删除,即已挂载
要删除目录,先umount卸载,再删除即可
[root@backup ~]# rm -rf /data/r
rm: cannot remove ‘/data/r’: Device or resource busy
[root@backup ~]#
原因:服务端共享目录自己挂载了自己
解决:卸载服务端的挂载,但服务端卸载报Device or resource busy的错,导致服务端无法卸载,这时用umount的-lt(强制卸载)或先将配置的共享目录注释掉,然后systemctl reload nfs之后,再用umount卸载;服务端卸载之后,客户端就可以正常挂载
[root@web01 ~]# mount -t nfs 172.16.1.31:/nfs /nfs/
mount.nfs: access denied by server while mounting 172.16.1.31:/nfs
因为/data/r这个目录并没有挂载信息,估卸载时报错
[root@backup ~]# umount /data/r
umount: /data/r: not mounted
df -h 查询并没有nfs的挂载信息,但是grep /nfs /proc/mounts显示已经挂载
解决:umount -lf强制卸载即可
[root@web01 ~]# cp /bin/ls /nfs
cp: failed to access ‘/nfs’: Stale file handle
[root@web01 ~]# cp /bin/ls /nfs/
cp: failed to access ‘/nfs/’: Stale file handle
[root@web01 ~]# cd /nfs/
-bash: cd: /nfs/: Stale file handle
指定了1个错误的挂载参数,修改正确即可
[root@backup ~]# mount -o rsize=131072,wsize-131072,suid,exec 172.16.1.31:/app/r /data/r
mount.nfs: an incorrect mount option was specified
[root@backup ~]#
[root@backup ~]# mount -o rsize=131072,wsize=131072,suid,exec 172.16.1.31:/app/r /data/r
[root@backup ~]#
nfs文件系统无法识别
因为没有安装nfs-utils,安装即可
>错误的文件系统类型 nfs文件系统无法识别
>没有安装nfs-utils
mount -t nfs 172.16.1.31:/data /mnt/
mount: wrong fs type, bad option, bad superblock on 172.16.1.31:/data,
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount. helper program)
In some cases useful info is found in syslog - try
dmesg | tail or so
[root@web01 ~]# showmount -e 172.16.1.31
clnt_create: RPC: Port mapper failure - Unable to receive: errno 111 (Connection refused)
[root@m01 ~]# ansible-playbook -C /server/ansible-playbook/nfs-deploy.yml
ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.
The error appears to be in '/server/ansible-playbook/nfs-deploy.yml': line 57, column 9, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: mount /upload
^ here
[root@m01 ~]#
playbook 创建目录时报错
TASK [make /upload] ******************************************************************************************************************
fatal: [172.16.1.7]: FAILED! => {"changed": false, "msg": "There was an issue creating /upload as requested: [Errno 17] File exists: '/upload'", "path": "/upload"}