About automatic nfs mounting

Source: Internet
Author: User

In the previous article, we learned about automatic nfs mounting. However, I have discovered some problems recently, so let's summarize them and share them with you. The Network Department adjusted the location of my server, so my server was shut down. As a result, when the server was restored, it was found that nfs was not automatically mounted. So what is the problem? First, it is found that it is normal to manually mount nfs, indicating that the portmap service is good and/etc/init is used. d/netfs status to view the status. You can also view the path to be mounted and run/etc/init. d/netfs start: the nfs path can be mounted. It indicates that the netfs service is also normal.

Check the startup script under/etc/rc. d/rc3.d, as shown below:

 
 
  1. S10network     
  2. S12syslog      
  3. S13irqbalance  
  4. S13iscsi       
  5. S13portmap     
  6. S22messagebus  
  7. S25netfs       
  8. S28autofs     

From this we can see that the netfs service is started after the portmap and after the network, so it should not be a problem with the Service startup sequence.

Then I came up with another question: not all servers cannot automatically mount nfs, but some machines can. The ip address of the company's nfs server and the ip address of my server are not in the same CIDR block, the server is in the 10 CIDR block, and the nfs is in the 192 CIDR block. Therefore, you must add a route when starting the server.

Here, two methods are used to automatically add a route

1. Use the rc. local file

2. Use the static-routes File

The problem is that the first method cannot be used for automatic mounting, but the second method can be used for automatic mounting. Later, I changed the first method to the second method to solve the problem. After the server is restarted, nfs can be automatically mounted.

Summary:

Rc. the content in local is executed only after all linux services are started. That is to say, the content is executed only after netfs, that is to say, when netfs is started, the static route on the server is not added, so netfs cannot be mounted successfully.

What is the static-routes file? This is a file called when the network script is executed. The file is placed in the/etc/sysconfig directory, and the location in the network script is:

 
 
  1. 151         # Add non interface-specific static-routes.  
  2. 152         if [ -f /etc/sysconfig/static-routes ]; then  
  3. 153            grep "^any" /etc/sysconfig/static-routes | while read ignore args ; do  
  4. 154               /sbin/route add -$args  
  5. 155            done  
  6. 156         fi 

From this script, we can see that this is the method for adding static routes. The static-routes method is

Any net 192.168.0.0/16 gw gateway ip Address

In this way, the route is automatically added when the network script is started. Because the network is started before netfs, it is normal when nfs is automatically mounted.

In this case, if you need to add a static route, the use of the static-routes file is better than the use of rc. local is good, and when the network configuration is changed and the network script needs to be restarted, the corresponding static route can be automatically added, but if rc is used at this time. local, when the network service is restarted, the originally added static route disappears.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.