我在我的EC2实例(Amazon linux AMI)上使用EFS卷。我可以毫无问题地安装卷,如果我进入服务器并执行类似的操作:
sudo mount -t nfs -o nfsvers = 4.1,RSIZE = 1048576,WSIZE = 1048576,硬,Timeo酒店= 600,重传= 2 fs-xxxxxxxxx.efs.ap-southeast-2.amazonaws.com:/ efs
但是如果我在我的实例的用户数据部分中添加一个shell脚本并启动它,我什么也得不到,我该怎么调试呢?我可以看看文件系统中是否有一些日志或其他内容?我没有错误,只是没有安装驱动器。任何帮助表示赞赏。
我正在使用以下shell脚本:
#!/bin/bash
# Make sure all packages are up-to-date
yum update -y
# Make sure that NFS utilities and AWS CLI utilities are available
yum install -y jq nfs-utils python27 python27-pip awscli
pip install --upgrade awscli
# Name of the EFS filesystem (match what was created in EFS)
EFS_FILE_SYSTEM_NAME="xxxx.efs.ap-southeast-2.amazonaws.com"
# Gets the EC2 availability zone for the current ECS instance
EC2_AVAIL_ZONE="ap-southeast-2b"
# Gets the EC2 region for the current ECS instance
EC2_REGION="Asia Pacific (Sydney)"
# Creates the mount-point for the EFS filesystem
DIR_TGT="efs"
mkdir "${DIR_TGT}"
# Get the EFS filesystem ID.
EFS_FILE_SYSTEM_ID="$(/usr/local/bin/aws efs describe-file-systems --region "${EC2_REGION}" | jq '.FileSystems[]' | jq "select(.Name==\"${EFS_FILE_SYSTEM_NAME}\")" | jq -r '.FileSystemId')"
if [ -z "${EFS_FILE_SYSTEM_ID}" ]; then
echo "ERROR: variable not set" 1> /etc/efssetup.log
exit
fi
# Create the mount source path
DIR_SRC="${EC2_AVAIL_ZONE}.${EFS_FILE_SYSTEM_ID}.efs.${EC2_REGION}.amazonaws.com"
# Actually mount the EFS filesystem
mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,soft,timeo=600,retrans=2 "${DIR_SRC}:/" "${DIR_TGT}"
# Create a backup of the existing /etc/fstab
cp -p "/etc/fstab" "/etc/fstab.back-$(date +%F)"
# Add the new mount point to /etc/fstab
echo -e "${DIR_SRC}:/ \t\t ${DIR_TGT} \t\t nfs \t\t nfsvers=4.1,rsize=1048576,wsize=1048576,soft,timeo=600,retrans=2 \t\t 0 \t\t 0" | tee -a /etc/fstab
答案 0 :(得分:1)
您可以在cloud-init-output.log
/var/log/cloud-init.log and
/var/log/cloud-init-output.log
日志
ap-southeast-2
您的EC2_REGION应该是Asia Pacific (Sydney)
而不是mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,soft,timeo=600,retrans=2 "${EFS_FILE_SYSTEM_NAME}:/" "${DIR_TGT}"
,因为您已经提到了端点名称,所以您不需要构建EFS端点。
file-system-id.efs.aws-region.amazonaws.com
如果要构建它,请使用以下EFS DNS Endpoint convention:
DIR_SRC="${EFS_FILE_SYSTEM_ID}.efs.${EC2_REGION}.amazonaws.com"
所以,它应该是
void setup() {
// initialize communication
Serial.begin(115200);
Serial.println("Comm Started");
// initialize Pins
pinMode(30, INPUT); // Pin 30: Strain Gauge 1, DATA channel
pinMode(31, INPUT); // Pin 31: Strain Gauge 2, DATA channel
/* some other codes*/
Serial.println("Pin Mode Set");
/* some other codes*/
Serial.println("Starting init gauges");
}