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:
- S10network
- S12syslog
- S13irqbalance
- S13iscsi
- S13portmap
- S22messagebus
- S25netfs
- 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:
- 151 # Add non interface-specific static-routes.
- 152 if [ -f /etc/sysconfig/static-routes ]; then
- 153 grep "^any" /etc/sysconfig/static-routes | while read ignore args ; do
- 154 /sbin/route add -$args
- 155 done
- 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.