Combine several mount folder in multiply server into one folder
Summary
I have 04 servers:
- 01 Master server:
s1
- 03 Client:
s4
s5
s6
I need one "master" folder combine folder in three client
Steps
- In master server
Create ssh public key with
ssh-keygen
command. - In client
Save public key to
.ssh/authorized_keys
to login without password Create share foldermkdir /root/s6
Note:sx
is hostname - In master server
Create mount point:
mkdir /root/share/s6
mkdir /root/share/s5
mkdir /root/share/s4
Create combine point:mkdir /root/share/all
Installsshfs
andmhddfs
:apt-get install sshfs mhddfs
Mount remote folder:sshfs root@x.x.x.x:/root/s4 /root/share/s4
sshfs root@x.x.x.x:/root/s5 /root/share/s5
sshfs root@x.x.x.x:/root/s6 /root/share/s6
Combine all:mhddfs /root/share/s4,/root/share/s5,/root/share/s6 /root/share/all -o allow_other
Result
Run df -h
root@x.x.x.x:/root/s6 20G 9.9G 8.5G 54% /root/share/s6
root@x.x.x.x:/root/s4 20G 9.8G 8.6G 54% /root/share/s4
root@x.x.x.x:/root/s5 20G 9.7G 8.7G 53% /root/share/s5
/root/share/s4;/root/share/s5;/root/share/s6 58G 30G 26G 54% /root/share/all
Touch /root/share/test.txt
. test.txt will be created in most free space mount point automatically.