D
D
Djoesan2018-07-26 20:17:56
linux
Djoesan, 2018-07-26 20:17:56

Files and folders created by the application go past the NFS mounted folder - how to fix it?

Hello!
There is a Debian9 VPS that needed more disk space to store images. It has a service that loads images for the site using links and writes them to the catalog by category subfolders.
There is a Server with Debian9 and a large disk.
The nfs-kernel-server is installed on the Server, the host1 user is added, which is identical to the user on the VPS with the same uid and gid. A folder for images /home/host1/img was created in its directory.
In /etc/exports Server were written:

/home/host1/img VPS_ip(rw,no_root_squash,no_subtree_check,crossmnt,fsid=0)

nfs-common is installed on the VPS and the home/host1/www/host1.ru/content/img directory is mounted.
In /etc/fstab it is written:
Server_ip:/home/host1/img /home/host1/www/host1.ru/content/img nfs rw,async,hard,intr,noexec 0 0

I also added both Server and VPS to /etc/default/nfs-common:
NEED_IDMAPD=yes
And I wrote to /etc/idmapd.conf:
[Mapping]
host1-User = host1
host1-Group = host1

The problem is that the mounted folder supposedly works - I can manually create a file or folder in it or copy from my desktop via WinSCP, and also duplicate files and folders using it. And all this is visible on the VPS and on the server.
However, the service does not create folders and files in it; he writes that everything is checked-loaded, but it's empty there.
I thought maybe this is a problem in it, I decided to check it without mounting the folder and after umount /home/host1/www/host1.ru/content/img I saw that he had created the necessary directories and loaded pictures into them.
Those. it loads in the same folder but locally and it is visible only when I do umount. Moreover, files also pass a check for the presence during mount. It's like I have two different folders stacked on top of each other.
How it does it and why I can’t understand, I’ve already tried everything, re-read a bunch of everything and completely blurred my brain.
Please guide me to the truth.
Thanks to!

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Djoesan, 2018-09-28
@Djoesan

I solved the problem, it turned out that the whole thing was in the code that recorded everything only locally, even when mounting.
I checked with a simple script that checks the entry in the directory.
I had to rewrite the entire code for myself - everything works, but I still don’t understand why the source code behaves this way. It seems that the directories are calculated from the root, and this should not affect the location of the folder. As if it also prescribes ip root. And yet, I didn’t really get to the bottom of it.
I met another similar unresolved issue on a stack or similar, but there the application was in java. Apparently, you can somehow dodge, so that it would write exclusively locally, ignoring the mounts.
NFS also had to be abandoned, a day later an abuse came from the German network supervision with a warning that the portmap could be used remotely for DDoS attacks. Although in the manuals for version 4 they write that it is not needed and has been replaced by another service, for some reason portmap is included. Of course, you can configure it and register ports, but nevertheless.
Installed and configured SSHFS, it seemed to me a little easier to set up, although it has its own nuances. Especially if you put it on a permanent basis with the task of autorun after a server reboot and for a specific user. But it is better suited if the ball is needed for access by a limited number of users.
I should note that the network is full of different manuals copying each other with different variations and on different versions, both on NFS and on SSHFS, which, due to inexperience, are misleading and misunderstanding. And official docks are very scarce.
In detail on NFS, I recommend:
1) www.k-max.name/linux/network-file-system-nfs
2) chschneider.eu/linux/server/nfs.shtml
For SSHFS, perhaps you should start from here: https://wiki. archlinux.org/index.php/SSHFS_(%D0%A0...
And then it depends on the ability to configure SSH, access by keys, rights and automounters.

D
Dimonchik, 2018-07-26
@dimonchik2013

1) rights
2) soft link
options, when something does not write to NFS folders, I also met, but now I can’t remember

P
Pavel Elizariev, 2014-12-19
@effetto

It is impossible to give an unambiguous answer to the question, since the type of variables is unknown. The expression means checking for the possibility of having a null value.

C
Cyril, 2014-12-19
@teoadal

var (meaning the type is determined by the compiler) x = y ?? (this is a null check) 10.
If y = null, then x = 10. If y != null, x = y.
At the same time, the important thing is that y must be either a reference value or Nullable. Those. y is most likely declared as int? y.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question