项目有台online机器需要迁移到另外1台上去 上面有多个不同目录需要
scp到另外1台上去 发现使用sshfs一次性的将目录挂载过来 在本地复制后在umount
这样省事也方便,也省去每次scp需要敲密码了。
基础环境
severA=192.168.1.122(6.0.10)debian
severB=192.168.1.120(6.6)centos
1、安装sshfs(SSHFS - filesystem client based on ssh)
apt-get -y install sshfs
2、挂载格式
sshfs [user@]host:[dir] mountpoint [options]
3、将severB机器上的/opt/111目录挂载到severA的/mnt下
echo "redhat"|sshfs -o nonempty,allow_other,password_stdin jimmy@192.168.1.120:/opt/111 /mnt
4、参数说明
-o password_stdin read password from stdin (only for pam_mount!)
-o nonempty allow mounts over non-empty file/dir
-o allow_other allow access to other users
5、查看挂载
df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 ext3 19G 2.1G 16G 12% /
tmpfs tmpfs 494M 0 494M 0% /lib/init/rw
udev tmpfs 490M 156K 490M 1% /dev
tmpfs tmpfs 494M 0 494M 0% /dev/shm
/dev/sda5 ext3 31G 179M 30G 1% /opt
jimmy@192.168.1.120:/opt/111
fuse.sshfs 26G 244M 25G 1% /mnt
==========================centos===========================
centos直接yum安装(前提是有epel源)
1、查询
yum list |grep sshfs
fuse-sshfs.x86_64 2.4-1.el6 epel
2、安装
yum -y install fuse-sshfs