可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I'm trying to write to FIFO file locate on NFS mount and it blocks. What could be the problem?
My /etc/export:
/tmp/test/ 10.0.0.0/24(rw,no_root_squash,async)
ls /tmp/test on NFS server and client is the same
prw--w--w- 1 root root 0 2009-06-24 17:28 ui-input
and I'm writing as root
Thanks.
回答1:
A FIFO is meant to be an inter-process communication mechanism. By trying to export the FIFO via NFS, you are asking the kernel to treat the local inter-process communication as more of a network communication mechanism.
There are a number of issues associated with that, the most obvious one being that the FIFO read implementation inside the kernel expects a buffer in userspace to copy the data to. Such a buffer is not directly available in NFS. Thus, the Kernel does not support the export of FIFOs over NFS.
You may want to use sockets for network communication instead.
回答2:
This response is probably too late to help you now, but it's notable that you could achieve a similar effect using named pipes and the "nc" (netcat) command. Netcat can accept input from standard input (or a named pipe) and echo it out over a socket to another instance of netcat on another host, optionally to a named pipe.
So basically, your setup would look like this:
Host1$ mkfifo Host1_named_pipe
Host1$ nc -l 1234 > Host1_named_pipe
Host2$ mkfifo Host2_named_pipe
Host2$ nc Host1 1234 < Host2_named_pipe
Now, when you run a program on Host2 and send its output to Host2_named_pipe, that output will come out of Host1_named_pipe on Host1.
or via ssh :
Host1$ mknode Host1_named_pipe p
Host2$ mknode Host2_named_pipe p
Host1$ cat Host1_named_pipe | ssh Host2 'cat - > Host2_named_pipe'
回答3:
It is a named fifo, but I guess it only works on the system where the filesystem is mounted.
Do you have a reader on this fifo ?
Are the writer and the reader on the same system ?
The fifo works like this : when a process opens the fifo, the kernel creates the pipe.
If another process opens the fifo, then the kernel know (from the name) that it is the same pipe as the one previously opened.
This can not work on two different machine. Ie if process A runs on client1 and process B runs on client2, then process A and process B can't communicate through the fifo, because a fifo is created on each machine.
The fifo does not exist until it is opened, and it only exits locally, it as no effect on the content of the filesystem.
回答4:
Do you have a reader on the FIFO? FIFOs will block until there is something reading on the other end. (Usual exceptions for opening in non-blocking mode apply.)
回答5:
NFS was designed as a multi-OS, lowest common denominator filesystem. As such, it does not support full Unix file system semantics. In particular, FIFOs/named pipes, if available at all, will not be shared across systems. (Two processes on the same host may be able to communicate via an NFS FIFO, though I would not recommend doing this).
If you want full Unix semantics, you'd have to use something like RFS. Note that the complexity and reduced performance of RFS, compared to the portability and 95% solution of NFS, has made it basically obsolete. The recommended solution for cross-host interprocess communication is to use BSD style sockets or AT&T style Streams, depending on your OS environment. For Linux, use sockets.