In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to install and configure NFS services under the CentOS6.5 system". In the daily operation, I believe that many people have doubts about how to install and configure NFS services under the CentOS6.5 system. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how to install and configure NFS services under the CentOS6.5 system". Next, please follow the editor to study!
Install the software packages required for the NFS server:
# yum install nfs-utils
This will complete the necessary package and install it.
Note that NFS4 is different from NFS3 in that it is no longer necessary to install portmap. Many articles in the article still insist that portmap should be installed. This is bullshit.
Configure NFS Shar
Edit / etc/exports file, there is no content in the initial state of this file, add it yourself.
# vi / etc/exports
/ home/exp 192.168.0.10 (rw,sync,fsid=0) 192.168.0.11 (rw,sync,fsid=0)
192.168.0.10 and 192.168.0.11 machines can load the / home/exp directory on the NFS server to their own file system.
Rw means writable; sync means to write memory and magnets synchronously, and fsid=0 means to package the export file / home/exp into the starting root directory.
Start the nfs service:
First turn on rpcbind and nfs machine self-startup:
# chkconfig rpcbind on
# chkconfig nfs on
Then start the rpcbind and nfs services, respectively:
# service rpcbind start
# service nfs start
Confirm that the nfs service started successfully:
# rpcinfo-p
Program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100003 2 udp 2049 nfs
100003 3 udp 2049 nfs
100003 4 udp 2049 nfs
...
100005 3 tcp 750 mountd
Check that the NFS server outputs the directory / home/exp that we want to share:
# exportfs
/ home/exp 192.168.0.10
/ home/exp 192.168.0.11
NFSv4 no longer uses portmap, but rpcbind, which should be noted.
NFS client
First of all, install the nfs suite, just like the server side.
Then start the rpcbind service:
Start the rpcbind service machine first:
# chkconfig rpcbind on
Then start the rpcbind service:
# service rpcbind start
Check if there is a directory share on the NFS server side:
# IP of showmount-e nfs server
Use mount to mount the server-side directory / home/exp to a client-side directory:
# mkdir / home/exp
# mount-t nfs4 nfs server IP:/ / home/exp
# df-h check to see if it's coming up.
If you want to auto-switch when the guest machine is started, add to / etc/fstab:
# vi / etc/fstab
Nfs server IP:/ / home/exp nfs4 ro,hard,intr,proto=tcp,port=2049,noauto 0 0
After the client has finished writing the file, there may be a permission issue: Permission denied. To solve this problem, you can modify the server file / etc/exports to the following content:
# vi / etc/exports
/ home/exp 192.168.0.10 (rw,sync,fsid=0,anonuid=48,anongid=48) 192.168.0.11 (rw,sync,fsid=0,anonuid=48,anongid=48)
Anonuid=48 means to treat all anonymous users as users with an ID of 48 on the server and apache on my server; the same anongid=48 means that all anonymous users are treated as users with an ID of 48 on the server and apache groups on my server. This setting is not bad, there must also be a user and user group with an ID of 48 on the server, and a user and user group with an ID of 48 on the client machine at the same time, and the name of the user and user group must be the same as that on the server.
Once set up, restart the NFS service and the problem can be solved.
Reread the NFS configuration file:
# exportfs-rv
You can view it using the following command
# exportfs-v
Share multiple directories
When using NFSv4 to share multiple directories, all directories are subdirectories of the shared root directory. For example, the following directories need to be shared:
/ first/very/long/path2
/ second/very/long/path3
At the same time, the directories that make the client look shared are / dir1 and / dir2.
Create a subdirectory # mkdir / home/NFSv4/dir1 on the server side
# mkdir / home/NFSv4/dir2
Use parameters to mount the directory to be shared # mount-- bind / first/very/long/path2
/ home/NFSv4/dir1
# mount-- bind / secend/very/long/path3
/ home/NFSv4/dir2
Modify / etc/exports file / home/NFSv4/dir1 * (rw,nohide,sync)
/ home/NFSv4/dir2 * (rw,nohide,sync)
Note: you need to reread the NFS configuration file # exportfs-rv using the nohide parameter
At this point, you can mount multiple shared folders on the server on the client:
Mount from the root directory
# mount server1:/ / mount/point/
Separate mount
# mount server1:/dir1 / mount/point1/
# mount server1:/dir2 / mount/point2/
Authority control
Modify the / ect/export file, similar to the following:
/ home/NFSv4 192.168.1.0/24
(ro,fsid=0,sync,anonuid=65534,anongid=65534)
Tuning
By default, the configuration of NFS is not suitable for high-capacity disks.
Each client should mount the remote file system with rsize=32768,wsize=32768,intr,noatime, such as.
Mount-o rsize=32768,wsize=32768,intr,noatime server1:/
/ mount/point/
To ensure that:
Use large read / write blocks (numbers specify the maximum block size, in this case 32KB).
NFS operations can be interrupted when suspended.
Do not update atime continuously.
You can put these settings in / etc/fstab. If you use an automounter, you should put these settings in the appropriate / etc/auto.* file.
On the server side, make sure that there are enough NFS kernel threads to handle all clients. By default, only one thread is started, but Red Hat and Fedora systems start eight threads. For busy NFS servers, you should increase this number, such as 32 or 64. You can evaluate the client for blocking with the nfsstat-rc command, which displays client remote procedure call (RPC) statistics. The following table shows client statistics for a Web server.
# nfsstat-rc
Client rpc stats:
Calls retrans authrefrsh
1465903813 0 0
The second column retrans is zero, which means that there has been no need for retransmission since the last reboot. If this number is large, you should consider adding NFS kernel threads. The setting method is to pass the required number of threads to rpc.nfsd, for example, rpc.nfsd 128 will start 128 threads. This setting can be made at any time, and the thread will be started or destroyed as needed. Again, this setting should be placed in startup scripts, especially those that enable NFS on the system.
One final note about NFS: you should avoid using NFSv2 if possible, because the performance of NFSv2 is much worse than v3 and v4. This should not be a problem in modern Linux distributions, but you can check the output of nfsstat on the server to see if there are any NFSv2 calls.
NFSv4 configuration reference:
Exports file content format:
[client 1 options (access rights, user mapping, other)] [client 2 options (access rights, user mapping, other)]
1. Output directory:
The output directory refers to the directory in the NFS system that needs to be shared with the client.
two。 Client:
A client is a computer on a network that can access this NFS output directory.
The common way of specifying the client
The host 192.168.0.200 that specifies the ip address
Specify all hosts in the subnet 192.168.0.0and24
Specify the host a.liusuping.com of the domain name
Specify all hosts in the domain * .liusuping.com
All hosts *
3. Options:
Option is used to set the access rights of the output directory, user mapping, and so on. There are three main types of options for NFS:
Access option
Set the output directory to read-only ro
Set output directory read / write rw
User mapping option
All_squash maps all ordinary users and groups accessed remotely to anonymous users or user groups (nfsnobody)
No_all_squash is inverted from all_squash (default)
Root_squash maps root users and their groups to anonymous users or user groups (default)
The reverse of no_root_squash and rootsquash
Anonuid=xxx maps all users accessed remotely to anonymous users and specifies that the user is a local user (UID=xxx)
Anongid=xxx maps all user groups accessed remotely to anonymous user group accounts and specifies the anonymous user group account as a local user group account (GID=xxx)
Other options
Secure restricts clients to connect to nfs servers only from tcp/ip ports less than 1024 (default)
Insecure allows clients to connect to the server from a tcp/ip port greater than 1024
Sync writes data synchronously to memory buffer and disk, which is inefficient, but can ensure data consistency.
Async saves the data in a memory buffer before writing to disk if necessary
Wdelay checks if there are related writes, and if so, performs them together, which improves efficiency (the default)
If there is a write operation in no_wdelay, it should be executed immediately. It should be used with sync.
Subtree if the output directory is a subdirectory, the nfs server will check the permissions of its parent directory (default)
No_subtree even if the output directory is a subdirectory, the nfs server does not check the permissions of its parent directory, which can improve efficiency
At this point, the study on "how to install and configure NFS services under the CentOS6.5 system" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.