Chinaunix

标题: red hat 5.5 rc.local 执行ifconfig失败 [打印本页]

作者: yblyx0806    时间: 2012-12-07 11:19
标题: red hat 5.5 rc.local 执行ifconfig失败
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

ifconfig eth1 txqueuelen 40000
sysctl net.core.netdev_max_backlog=40000
ethtool -G eth1 rx 4096 tx 4096


这个是我在服务器上配置的,主要是更改网卡参数,但是我重启后发现没有更改成功。
这几行就是命令,没有存在绝对路劲的问题?请问这是为什么重启失效呢?会是在服务器重启的时候因为重启服务是顺序的原因么?求助啊求助啊!!
作者: chenyx    时间: 2012-12-07 11:21
你所有的命令都用绝对路径的方式测试下.
rc.local是系统启动的最后才执行的.
作者: yblyx0806    时间: 2012-12-07 12:32
回复 2# chenyx 我在
外边[root@~]#这个下执行那几条命令是可以执行更改的。

   
作者: chenyx    时间: 2012-12-07 13:47
你测试下绝对路径吧,看看是不是环境变量的问题
作者: yblyx0806    时间: 2012-12-11 09:46
回复 4# chenyx
绝对路径该怎么测?

   
作者: chenyx    时间: 2012-12-11 09:48
你用which找一下ifconfig,ethtool,sysctl,然后用找到的命令的绝对路径替换你rc.local里面的命令
比如ifconfig改成/sbin/ifconfig ...
作者: yblyx0806    时间: 2012-12-11 14:59
回复 6# chenyx

绝对路径下面运行都没问题的。除了这个可能外,还会有什么能导致rc.local失效
   
作者: vermouth    时间: 2012-12-12 16:46
其他服务还没有正常运行,加个 sleep 看看?
作者: yblyx0806    时间: 2012-12-13 13:57
回复 8# vermouth
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/sbin/ifconfig eth0 txqueuelen 40000
/sbin/sysctl net.core.netdev_max_backlog=40000
/sbin/ethtool -G eth0 rx 4096 tx 4096
我已经加了绝对路径还是不行,sleep?这个要怎么加的?


   
作者: vermouth    时间: 2012-12-13 14:02
sleep 秒数 && 命令
作者: yblyx0806    时间: 2012-12-13 14:10
回复 10# vermouth
我需要让这些命令在最后启动,大体需要多少秒比较合理?


   
作者: yblyx0806    时间: 2012-12-13 14:17
回复 10# vermouth
我修改成 sleep 30 && ifconfig eth0 txqueuelen 40000
但是重启还是没有生效。


   
作者: vermouth    时间: 2012-12-13 14:58
回复 12# yblyx0806

你这个是30秒,改成120 2分钟看看
作者: vermouth    时间: 2012-12-13 15:00
还可以给命令后面加上 > log文件,记录一下运行日志。
作者: yblyx0806    时间: 2012-12-13 15:31
回复 14# vermouth

加了日志,但是是空的。
   
作者: vermouth    时间: 2012-12-13 17:34
命令后面加上 &&echo ok > log文件,看看是否有运行.
作者: yblyx0806    时间: 2012-12-13 18:10
回复 16# vermouth
我在rc.local里面单独执行ifconfig eth0 txqueuelen 40000 是可以的。三条同时执行不行,我写了个if语句。

   
作者: vermouth    时间: 2012-12-13 18:13
sysctl 可以直接放在/etc/sysctl.conf里啊,ethtool 可以在网卡配置文件中标注;
这三条的先后真不好说.
作者: yblyx0806    时间: 2012-12-14 13:28
回复 18# vermouth
我写了一个简单的脚本测试,不用每次开机。再更换三条命令的顺序,发现只有ifconfig eth0 txqueuelen 4000 这条命令失效。
而且sysctl net.core.netdev_max_backlog=40000 生效的时候,会ping不通主机。有没有可能是这条命令生效会重置网卡参数?


   
作者: vermouth    时间: 2012-12-14 13:54
netdev_max_backlog 是网络设备 最大 返回日志长度?
作者: vermouth    时间: 2012-12-14 14:01
net.core.netdev_max_backlog,该参数决定了 网络设备接收数据包的速率比内核处理这些包的速率快时,允许送到队列的数据包的最大数目。

根据需要调整改值,不要设置的过大。




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2