Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

CentOS 6.3How to install, configure, start and mount mount on NFS

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "CentOS 6.3NFS how to install and configure, start and mount mount". In daily operation, I believe many people have doubts about how to install and configure CentOS 6.3NFS, start and mount mount. Xiaobian 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 questions of "how to install and configure CentOS 6.3NFS, start and mount mount". Next, please follow the editor to study!

I. introduction to the environment:

Server: centos 192.168.1.225

Client: centos 192.168.1.226

2. Installation:

Installation configuration of NFS:

Centos 5:

Yum-y install nfs-utils portmap

Centos 6 (in CentOS 6.3, the portmap service is handled by rpcbind):

Yum-y install nfs-utils rpcbind

Server-side configuration:

1. Create a shared directory:

[root@centos2 /] # mkdir / usr/local/test

2. NFS file configuration:

[root@centos2 /] # vi / etc/exports # add one line: / usr/local/test/ 192.168.1.226 (rw,no_root_squash,no_all_squash,sync)

: X save exit

To make the configuration effective:

[root@centos2 /] # exportfs-r

Note: profile description:

/ usr/local/test/ is a shared directory, using an absolute path.

192.168.1.226 (rw,no_root_squash,no_all_squash,sync) is the address and permission of the client. The address can be a network segment, an IP address or a domain name. The domain name supports wildcards, such as: * .youxia.com. There is no space between address and permission. Permission description:

Rw:read-write, readable and writable

Ro:read-only, read-only

Sync: files are written to both hard disk and memory

Async: files are temporarily stored in memory instead of being written directly to memory

If the no_root_squash:NFS client connects to the server using root, it also has root permission for the directory shared by the server. It is obviously not safe to turn this on.

If the root_squash:NFS client connects to the server using root, then the directory shared by the server has anonymous user rights, and usually he will use nobody or nfsnobody identity

All_squash: no matter what user the NFS client uses to connect to the server, it has anonymous user permission for the directory shared by the server.

Anonuid: the UID value of an anonymous user, usually nobody or nfsnobody, which can be set here

Anongid: the GID value of anonymous users.

3. Start:

Centos6:

[root@centos2 /] # service rpcbind start

Starting rpcbind: [OK] [root@centos2 /] # service nfs startStarting NFS services: [OK] Starting NFS quotas: [OK] Starting NFS mountd: [ OK] Stopping RPC idmapd: [OK] Starting RPC idmapd: [OK] Starting NFS daemon: [OK] [root@centos2 /] #

Centos 5

[root@centos2 /] # service portmap start [root@centos2 /] # service nfs start [root@centos2 /] #

4. Client mount:

1. Create a directory to be mounted:

[root@localhost ~] # mkdir / usr/local/test [root@localhost ~] #

2. Test mount:

[root@localhost ~] # showmount-e 192.168.1.225Export list for 192.168.1.225:/usr/local/test 192.168.1.226 [root@localhost ~] #

If rpc mount export: RPC: Unable to receive; errno = No route to host is displayed, you need to turn off the firewall on the server side (more on that later).

3. Mount:

[root@localhost] # mount-t nfs 192.168.1.225:/usr/local/test / usr/local/test

[root@localhost ~] # mount/dev/mapper/VolGroup-lv_root on / type ext4 (rw) proc on / proc type proc (rw) sysfs on / sys type sysfs (rw) devpts on / dev/pts type devpts (rw,gid=5 Mode=620) tmpfs on / dev/shm type tmpfs (rw) / dev/sda1 on / boot type ext4 (rw) none on / proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on / var/lib/nfs/rpc_pipefs type rpc_pipefs (rw) nfsd on / proc/fs/nfsd type nfsd (rw) 192.168.1.225:/usr/local/test on / usr/local/test type nfs (rw,vers=4,addr=192.168.1.225,clientaddr=192.168.1.226) [root@localhost ~] #

If the message is shown above, the mount is successful!

4. Test:

The client generates a file:

[root@centos2 /] # cd / usr/local/test/ [root@centos2 test] # echo "hello nfs test" > > test [root@centos2 test] # lltotal 4Murray RWMUR test-1 root root 15 Apr 9 13:24 test [root@centos2 test] #

Server check:

[root@centos2 /] # cd / usr/local/test/ [root@centos2 test] # lltotal 4 RWMurray RWMULI-1 root root 15 Apr 9 13:24 test [root@centos2 test] #

Mounted successfully!

5. Unmount:

[root@localhost ~] # umount / usr/local/test

[root@localhost ~] # mount/dev/mapper/VolGroup-lv_root on / type ext4 (rw) proc on / proc type proc (rw) sysfs on / sys type sysfs (rw) devpts on / dev/pts type devpts (rw,gid=5 Mode=620) tmpfs on / dev/shm type tmpfs (rw) / dev/sda1 on / boot type ext4 (rw) none on / proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on / var/lib/nfs/rpc_pipefs type rpc_pipefs (rw) nfsd on / proc/fs/nfsd type nfsd (rw) [root@localhost ~] #

If you encounter: umount.nfs: / usr/local/test: device is busy

You may use a command:

[root@localhost /] # fuser-m-v / usr/local/test

User process number permission command / usr/local/test/: root 2798.. c.. Bash root 2996.. c.. Su [root@localhost /] # kill-9 2798 [root@localhost /] # kill-9 2996 [root@localhost /] # umount / usr/local/test [root@localhost /] #

6. Server-side firewall settings (NFS enable wall configuration):

1. Modify / etc/service and add the following (the port number must be below 1024 and is not occupied)

# Local services

Mountd 1011/tcp # rpc.mountd

Mountd 1011/udp # rpc.mountd

Rquotad 1012/tcp # rpc.rquotad

Rquotad 1012/udp # rpc.rquotad

2. Restart Linux NFS service

Service nfs restart

3. At this time, the relevant ports of rpc have been fixed, so you can add firewall rules for Linux NFS.

# portmap

/ sbin/iptables-An INPUT-s 192.168.1.0 pound 254p tcp-- dport 111j ACCEPT

/ sbin/iptables-An INPUT-s 192.168.1.0 pound 254p udp-- dport 111j ACCEPT

# nfsd

/ sbin/iptables-An INPUT-s 192.168.1.0 Universe 254-p tcp-- dport 2049-j ACCEPT

/ sbin/iptables-An INPUT-s 192.168.1.0 Universe 254-p udp-- dport 2049-j ACCEPT

# mountd

/ sbin/iptables-An INPUT-s 192.168.1.0 Universe 254-p tcp-- dport 1011-j ACCEPT

/ sbin/iptables-An INPUT-s 192.168.1.0 Universe 254-p udp-- dport 1011-j ACCEPT

# rquotad

/ sbin/iptables-An INPUT-s 192.168.1.0 Universe 254-p tcp-- dport 1012-j ACCEPT

/ sbin/iptables-An INPUT-s 192.168.1.0 Universe 254-p udp-- dport 1012-j ACCEPT

# rpc.statd

/ sbin/iptables-An INPUT-s 192.168.1.0 Universe 254-p tcp-- dport 32768-j ACCEPT

/ sbin/iptables-An INPUT-s 192.168.1.0 Universe 254-p udp-- dport 32768-j ACCEPT

-TCP method succeeded

-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 111j ACCEPT

-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 2049-j ACCEPT

-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 1011-j ACCEPT

-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 1012-j ACCEPT

-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 32768-j ACCEPT

One of the problems encountered by the client when mounting is as follows. It may be that the network is unstable. By default, NFS uses UDP protocol, which can be replaced with TCP protocol:

Mount-t nfs 192.168.1.225:/usr/local/test / usr/local/test-o proto=tcp-o nolock

At this point, the study on "how to install, configure, start and mount CentOS NFS" 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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report