In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you about how to configure the nfs server to achieve directory sharing in CentOS. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
1.cpst01 external network ip is *. * (this is best connected to the Internet, because if you do not install some rpm bars in the disk, you can download it from the Internet with wget or yum search, which requires a network cable to connect to the outside), and the internal network IP is 192.168.1.10 (if you set up the ip, you will not talk about it here, search it yourself, and pay attention to which network card it is.)
Em2 Link encap:Ethernet HWaddr D4:AE:52:91:F8:11
Inet addr:192.168.1.10 Bcast:192.168.1.255 Mask:255.255.255.0
Inet6 addr: fe80::d6ae:52ff:fe91:f811/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7281946 errors:0 dropped:0 overruns:0 frame:0
TX packets:10709199 errors:0 dropped:0 overruns:0 carrier:0
Collisions:0 txqueuelen:1000
RX bytes:7212522964 (6.7 GiB) TX bytes:14043999341 (13.0 GiB)
Interrupt:17
Mine is on the No. 2 network card (No. 1 network card is connected to the external network, and there is a number 1 or 2 on the network cable Jack of the server).
Cpst02 does not need to be connected to the public network. Set a private network IP 192.168.1.20 as follows:
Em2 Link encap:Ethernet HWaddr D4:AE:52:91:F6:DC
Inet addr:192.168.1.20 Bcast:192.168.1.255 Mask:255.255.255.0
Inet6 addr: fe80::d6ae:52ff:fe91:f6dc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:10709309 errors:0 dropped:0 overruns:0 frame:0
TX packets:7282075 errors:0 dropped:0 overruns:0 carrier:0
Collisions:0 txqueuelen:1000
RX bytes:14044008517 (13.0 GiB) TX bytes:7212663244 (6.7 GiB)
Interrupt:17
This is also the No.2 network card.
At this time, the remaining network cable will be used to connect the No.2 network card of cpst01,cpst02. At this time, ping should be connected.
two。 Here I use cpst01 as the nfs server and cpst02 as the client. (nfs,portmap,rpcbind needs to be installed on the nfs server)
First check whether the above three rpm have been installed on the server side
[root@cpst01 test] # rpm-qa | grep nfs
Nfs-utils-lib-1.1.5-4.el6.x86_64
Nfs4-acl-tools-0.3.3-5.el6.x86_64
Nfs-utils-1.2.3-15.el6.x86_64
[root@cpst01 test] # rpm-qa | grep portmap
Portmap-4.0-65.2.2.1.x86_64
[root@cpst01 test] # rpm-qa | grep rpcbind
Rpcbind-0.2.0-8.el6.x86_64
[root@cpst01 test] #
If not, you can find it on the installation disk, or search for yum search on the Internet.
Here is a rpm website with a lot of things to see:
Portmap download address http://rpm.pbone.net/index.php3/stat/4/idpl/17838805/dir/centos_5/com/portmap-4.0-65.2.2.1.x86_64.rpm.html
Nfs and rpcbind can usually be installed together when installing the system. If not, you can search yum search nfs.
There is a bit of a struggle when installing portmap (it requires the library file libwrapper.so.0, which is available in the tcp_wrappers-7.6-57.el6.x86_64.rpm package, you can install it first and then install portmap).
3. After installing the above package, you can test, that is, to start and stop the above services. What is said on the Internet is that when you start, you install rpcbind,portmap,nfs in order to start, and when you stop, you start (service rpcbind start,service portmap start,service nfs start, / etc/init.d/nfs start is also fine). After starting, check the running status of the service, service nfs status, and the result is that there is something wrong with portmap. The new version of portmap uses hosts.deny and hosts.allow files to control the access source (http://www.centos.bz/2012/02/centos-install-deploy-nfs-file-system/). Here, modify the next / etc/hosts.deny to add a line of portmap:all, and modify the next / etc/hosts.allow to add a line of portmap:192.168.1.20. Some people here will ask whether it is already deny all, and the latter allow will not work, and the priority of allow is higher. Look at it first. When it is done, you can stop, start and check the above three services. There should be no problem.
4. Here we start to set up the shared directory under cpst01. I set the / test directory to create the user rg below. The key to the user group soft,nfs server shared directory is the / etc/exports file.
Under vi, add / test 192.168.1.20 (rw)
Here I only set read and write permissions, which means 192.168.1.20, that is, cpst02 has read and write permissions in the / test directory, and of course there are many other permissions.
W: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.
Some people don't understand, so they don't get it (http://www.centos.bz/2012/02/centos-install-deploy-nfs-file-system/)
If you don't have stop for the three services in the previous step, you need to use exportfs-rv to re-output the set sharing information. If it is vi / etc/exports, then you don't need to start the service, just like source export.
5. At this time, on the client side, you can view the server-side mount.
Use showmount-e 192.168.1.10
Export list for 192.168.1.10:
/ test 192.168.1.20
It is set under / etc/exports, which proves that it is connected to the nfs server.
But you can't share the / test directory under cpst01 yet, because you haven't mounted the / test directory on the client's directory.
Here I created a user rg in cpst02 (it is said on the Internet that you want to have the same users and user groups as the server / test directory). You don't have to mount it under the / test directory of cpst02. Other directories are fine. Here, you can use chown-R rg:soft / test to modify permissions in cpst02.
Now it is mounted:
Mount-t nfs 192.168.1.10:/test / test
If it is mounted quickly, it will be successful. If it is wrong, it will be like a firewall problem. Just service iptables stop on the server side, and then execute mount on the client side.
At this point, the / test under cpst01 is mounted under / test of cpst02, and the directory can be shared.
6. If you want to automatically mount / test under cpst02 when you boot up, you need to add something to / etc/fstab under cpst02.
192.168.1.10:/test / test nfs defaults 0 0
This is fine, and you don't have to mount yourself every time.
This is how the CentOS shared by Xiaobian implements directory sharing by configuring the nfs server. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to 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.