阿里云服务器 centos 7.3 ,开始是通过 fstab 配置的自动挂载:

xxx.cn-hangzhou.nas.aliyuncs.com:/  /nas  nfs4  auto  0  0

但服务器启动后不能自动挂载 nas ,用 mount 命令可以手动挂载:

mount -t nfs4 xxx.cn-hangzhou.nas.aliyuncs.com:/  /nas

在 /var/log/boot.log 中发现了对应的错误日志:

[FAILED] Failed to mount /nas.
See 'systemctl status nas.mount' for details.

systemctl status nas.mount 命令查看错误详情:

ount.nfs4: Failed to resolve server xxx.cn-hangzhou.nas.aliyuncs.com: Name or service not known

原来是在启动过程中解析 nas 的主机名失败。

于是改用 systemd 挂载 nas ,systemd unit 配置(/etc/systemd/system/nas.mount)是这么写的:

Description=mount aliyun nas
Requires=network.target [Mount]
What=xxx.cn-hangzhou.nas.aliyuncs.com:/
Where=/nas
Type=nfs4 [Install]
WantedBy=multi-user.target

启用 systemd 配置后,重启服务器依然无法自动挂载。

systemctl enable nas.mount

将 Requires=network.target 改为 Requires=network-online.target ,问题依旧。

后来查看 systemd 的 multi-user.target.wants 发现了几个 cloud 开头的 service

# ls /etc/systemd/system/multi-user.target.wants/ | grep cloud
cloud-config.service
cloud-final.service
cloud-init-local.service
cloud-init.service
cloud-init-upgrade.service

估计是阿里云添加的一些 service ,试了试在 Requires 中 添加 cloud-final.target ,结果问题解决了!

[Unit]
Description=mount aliyun nas
Requires=cloud-final.target [Mount]
What=xxx.cn-hangzhou.nas.aliyuncs.com:/
Where=/nas
Type=nfs4 [Install]
WantedBy=multi-user.target

估计是 dns 解析依赖阿里云的某些 service 。

* 参考资料:systemd 编写服务管理脚本

阿里云 centos 服务器无法自动挂载 nas 的问题的更多相关文章

  1. 阿里云CentOs服务器 安装与配置mysql数据库

    阿里云CentOs服务器 安装与配置mysql数据库 以上为Linux安装mysql数据库 Linux 安装mysql 数据库 一下为mysql 安装教程 Using username "r ...

  2. 阿里云CENTOS服务器挂载数据盘

    阿里云Linux云服务器数据盘默认是未做分区和格式化的,使用前需要先挂载数据盘.步骤如下: 1.查看数据盘 在没有分区之前,使用   1 df -h 2.命令,是无法查看到数据盘的,可以使用   1 ...

  3. 搭建yum本地源_阿里云CentOS服务器初始化设置

    CentOS服务器初始化设置其实不分阿里云或其它服务器了,操作配置过程与步骤也差不多一.挂载硬盘 1.磁盘分区 fdisk -l #查看设备,一般可以看到设备名为/dev/xvdb fdisk /de ...

  4. 新手上路,配置阿里云CentOS服务器LAMP

    最近出了个9.9包月的阿里云一直想弄就买了个半年的,脑子一热选了个CentOS系统的然后就是无尽的代码...... 话不多说直接上步骤:  在实例中选择"连接管理终端",输入一些应 ...

  5. 在阿里云 CentOS 服务器(ECS)上搭建 nginx + mysql + php-fpm 环境

    阿里云的云服务器(ECS)可以选择多种操作系统,打算用它运行 Drupal或者 WordPress ,你最好选择 Linux 系统,这篇文章的演示是基于阿里云的 CentOS 操作系统的服务器.我们在 ...

  6. (转)在阿里云 CentOS 服务器(ECS)上搭建 nginx + mysql + php-fpm 环境

    阿里云的云服务器(ECS)可以选择多种操作系统,打算用它运行 Drupal或者 WordPress ,你最好选择 Linux 系统,这篇文章的演示是基于阿里云的 CentOS 操作系统的服务器.我们在 ...

  7. 关于阿里云Centos服务器搭建Java网站不能访问的问题

    首先阿里云提供的手册是没问题的 手工搭建 然后我在地址栏输入服务器地址之后总是提示无法访问! 输入命令 netstat -tunlp,80端口确实是在监听(这里不是8080,因为我在tomcat的配置 ...

  8. 在阿里云CentOS服务器上安装Python3.7并设置为默认Python

    1.引言 Linux操作系统自带一个python2.7,没有python3,在开发的时候非常不便,因此需要安装一个python3,并且将python3设置系统默认python,同时还不能影响那些Lin ...

  9. 阿里云CentOS服务器下安装Golang1.13并配置代理

    注:root账户或添加sudo命令运行. 下载到/usr/local位置并解压 cd /usr/local wget https://studygolang.com/dl/golang/go1.13. ...

随机推荐

  1. Docker查看运行中容器并进入容器

    一.简述 Docker查看运行中容器并进入容器. 二.方法 $ sudo docker ps $ sudo docker exec -it 775c7c9ee1e1 /bin/bash 将黄色文字替换 ...

  2. Substr与mb_substr区别

      <?php $str = substr('helloword',3,4);//从下标3开始截取截取4个字符 $str = substr('helloword',3);//从截取掉前三个字符 ...

  3. InfluxDB源码阅读之httpd服务

    操作系统 : CentOS7.3.1611_x64 go语言版本:1.8.3 linux/amd64 InfluxDB版本:1.1.0 服务模块介绍 源码路径: github.com/influxda ...

  4. CouchDB 简单HTTP接口使用说明

    目录 1.简介 2.安装 2.HTTP接口简单使用 2.1.认证接口 2.1.1 Basic Authentication 2.1.2 Cookie Authentication 2.2 创建与删除数 ...

  5. ###My SQL Date相关函数

    ###My SQL Date相关函数 #获得当前日期时间 select now(); #date_format(date,format) select date_format('2008-08-08 ...

  6. go get fatal: could not read Username for 'https://code.xxx.org': terminal prompts disabled

    用go get下载私有代码库的时候,莫名其妙产生了以下错误,公有代码库没有影响. chenchideMacBook-Pro:~ chenchi$ go get code.xxx.org/adarch/ ...

  7. JTable动态刷新数据

    http://www.cnblogs.com/fnlingnzb-learner/p/6025408.html 注意下面几个方法的应用场景,不限于JTable,其他swing组件一样 ———————— ...

  8. k8s的使用

    . 查看 kubectl 的状态 kubectl version . 查看集群信息 kubectl cluster-info . 查看节点信息 kubectl get nodes . 创建一个发布 k ...

  9. php utf8编码字符串的截取

    function sub_str($str, $length = 0, $append = true) { $str = trim($str); $strlength = strlen($str); ...

  10. windows 10系统 上安装scrapy

    1.python的安装(我已安装完) 2.pip的安装(我已安装) 3.安装twisted https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted 命令 ...