In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
What this article shares with you is about the specific steps of building NFS service under Linux. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
NFS (Network File System), the network file system, is one of the file systems supported by FreeBSD, which allows computers in the network to share resources.
1. Introduction to NFS service:
The NFS service can mount the file sharing resources on the remote Linux system to the directory of the local host, so that the local host can read and write the shared files on the remote Linux system as if accessing its own resources, which makes our work efficiency more efficient and brief to some extent.
The NFS service uses the Cramp S architecture, which is composed of a client program and a server program. Server programs provide access to the file system to other computers, a process called output. When the NFS client program accesses the shared file system, it "transfers" them from the NFS server.
2. The system environment of this paper:
Operating system: CentOS 7.4
Server-side IP:192.168.178.128 (used to deploy NFS services)
Client IP:192.168.178.129 (used to verify that the NFS service is deployed successfully)
3. Environment preparation before deployment:
Turn off the server system firewall:
Systemctl stop firewalld.service
Temporarily shut down selinux:
Setenforce 04. Officially start the deployment of NFS server:
Create a new directory for NFS file sharing:
Mkdir nfsfile
Grant sufficient permissions to the shared directory to ensure that others have write permissions as well:
Chmod-R 777 nfsfile
Create a new test file test.txt in the shared directory for subsequent client verification:
Cd nfsfileecho "This is a test file" > / nfsfile/test.txt5, enter configuration items:
Open the configuration file / etc/exports for the NFS service using vim and enter the configuration items related to the client:
Note: by default, the content in the / etc/exports file is empty. We can configure it in the following format:
NFS clients allowed to be accessed by the shared directory path (share permissions parameter)
For example:
/ nfsfile 192.168.178.* (rw,sync,root_squash) # Note: there is no space between the NFS client address and permissions!
The above configuration items are explained as follows:
/ nfsfile # Native shared directory 192.168.178.* # allow all hosts in network segment 192.168.178.0 to access native shared directory rw # 192.168.178.0Universe 24 have read and write access to native shared directory sync # write data to memory and hard disk for every change Ensure no data loss root_squash # when the NFS client accesses the local shared directory as a root user, it is mapped to an anonymous user on the NFS server side 6. Start the RPC service and the NFS service:
Because before using NFS service for file sharing, we need to use RPC (remote procedure call) service to send information such as IP address and port number of NFS server to the client.
Therefore, before officially starting the NFS service, we need to start the RPC service first. (must be in this order! )
If the NFS and RPC services are not installed by default on the current system, then we also need to install the services first!
The corresponding installation package for RPC service is: the corresponding service program for rpcbindRPC service is: the corresponding installation package for rpcbindNFS service is: the corresponding service program for nfs-utilsNFS service is: nfs-serverrpm-qa nfs-utils rpcbind # to check whether to install the corresponding two packages. If there is no return message after execution, then there is no yum-y install nfs-utils rpcbind # install nfs and rpc package systemctl start rpcbindsystemctl enable rpcbind # add the rpcbind service to the boot startup item systemctl start nfs-serversystemctl enable nfs-server # add the nfs-server service to the boot startup item 7, start the deployment of the NFS client: (pay attention to the client! )
Just like the server, if you check that it is not installed, install NFS and RPC first, and start the service!
Let's learn a command: showmount
Usage: showmount parameter NFS server IP function: used to query the remote sharing information of the NFS server. Its output format is: shared directory name allowed client address common parameter:-e display NFS server share list-a show local mounted file resources-v display version number
We execute the following command on the client:
Showmount-e 192.168.178.128
The results are as follows:
Export list for 192.168.178.128:/root/nfsfile 192.168.178.*
The client starts mounting the shared directory:
Mkdir nfsfile # client mount point mount-t nfs 192.168.178.128:/root/nfsfile / root/nfsfile # Mount the server shared directory to the newly created mount point
The client verifies whether the mount is successful:
When cd / root/nfsfile # enters this directory, you will see that the test.txt file cat test.txt # created previously on the server side is opened, and the contents of the file are consistent with those of the server file. It shows that the nfs shared file system is built successfully!
Finally, if you need to mount the shared directory permanently (that is, to enable auto-mount on boot), you can do this in the following ways:
Echo "mount-t nfs 192.168.178.128:/root/nfsfile / root/nfsfile" > > / etc/rc.d/rc.local # writes mount commands to rc.local
What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.
These are the specific steps of building NFS services under Linux. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.