背景
之前买了个树莓派2,闲置了很久,最近正好有NAS需求,就打算拿它装个OpenMediaVault玩玩。
安装过程不表。
事实上是在使用过程中,遇到的某个问题比较奇葩,就拿来分享了。
林尽水源
在网页端对OMV进行配置时,经常会遇到一个弹窗monit: Cannot connect to the monit daemon. Did you start it with http support?。
详细错误代码如下:
| |
ssh到OMV终端,输入命令:monit status,似乎错误信息也一样:
| |
在这种情况下,OMV就无法应用配置,必须解决这问题。
初仿佛若有光
于是去google上找啊,找啊,终于找到一篇帖子,遇到了相似的问题(竟然不是StackOverflow,差评!)
Because ntpdate is installed in the image. Both ntp server and ntpdate cannot be installed at the same time. Also, the config for the ntp server does not work….
apt-get –purge remove ntpdate
Then in the OMV web gui set your timezone because after these changes you cannot set it again.
then edit /etc/ntp.conf:
remove these lines: server 127.127.1.0 # Local clock fudge 127.127.1.0 stratum 12 server pool.ntp.org iburst
And replace with these: server 0.no.pool.ntp.org iburst server 1.no.pool.ntp.org iburst server 2.no.pool.ntp.org iburst server 3.no.pool.ntp.org iburst
Then you can: service ntp restart
Do not disable/enable in the OMV web gui again. The mkconf file for the ntp service will overwrite thesechanges. There need to be some updates so it works properly with the rpi 2.
Your logs files and dates at boot will be all messed up with wrong dates until you install a RTC module. After boot it takes some minutes before the ntp server will update the time/date. With a RTC module everything is perfect at boot.
总结几点就是:
Monit的错误和系统时间有关- (检查了一下,确实系统当前时间错误)
ntpdate与ntp server有冲突,不能同时安装- (检查了一下,ntp服务启动失败)
OMV自带的ntp配置/etc/ntp.conf有错误- 你应该安装
RTC模块
复行数十步
按照前面这位贤者的建议,我分别进行了一下几个测试:
- 测试一: 手动修改当前时间,卸载
ntpdate,关闭ntp服务- 重启以后,时间丢失
- 测试二: 卸载
ntpdate,不修改ntp配置文件ntp服务正常启动,时间同步正确- 重启以后,
ntp服务正常启动,时间无法同步
- 测试三: 卸载
ntpdate,修改ntp配置文件ntp服务正常启动,时间同步正确- 重启以后,
ntp服务正常启动,时间无法同步
- 测试四: 运行
ntpdate,强制同步- 时间同步正确
- 重启以后,
ntp服务不能正常启动,时间无法同步
测试后发现,因为树莓派本身的硬件限制,系统重启后会丢失当前时间。
尽管开启了ntp服务,但是如果系统当前时间与真实时间跨度太大,则不会进行同步。
所以只能放弃ntp server,转而使用ntpdate来强制同步时间,并设置开机启动。
代码如下:
| |
重启系统,系统时间已经正确了。
在网页端对OMV重新进行配置。WTF,怎么还是monit这个问题!
豁然开朗
登入终端,重新进行检查:
| |
到这里时,我当时确实很疑惑,明明系统时间已经正确了,为什么monit还是报错呢。
突然灵光乍现,重新启动monit服务,然后十几秒过后:
| |
在此个人分析,在monit服务启动时,系统时间还未同步,所以monit初始化失败。只要保证在时间同步后,再重启monit服务应该就可以了。
| |
重启系统,一切正常。END!