亚马逊 FSx 构造库
AWS CDK v1在2023-06-01上达到了支持结束. 此软件包不再更新,用户应该迁移到 AWS CDK v2.
关于如何移徙的更多信息,请参见: 移动到 AWS CDK v2 指南。 。 。 .
亚马逊 FSx 提供充分管理的第三方文件系统 本地兼容性和功能集,用于工作量,如Microsoft Windows - 基于存储,高性能计算, 机器学习 电子设计自动化.
Amazon FSx支持两种文件系统类型: 鲁斯特 财务报告和审定财务报表 窗口 文件服务器.
卢斯特的FSx
Amazon FSx for Lustre 使得发布和运行受欢迎的高性能的 Lustre 文件变得容易且具有成本效益 系统。 您使用 Lustre 处理速度很重要的工作量, 如机器学习、 高性能计算( HPC), 视频处理,以及财务模型.
开源的 Lustre 文件系统是为需要快速存储的应用程序设计的 — 您想要存储的地方 要跟上你的计算。 Lustre是用来解决 快速和廉价地处理世界 不断增长的数据集。 这是一个被广泛使用的文件系统,为世界上最快的计算机所设计. 它规定 分毫秒后期,可达数百GBps的吞吐量,可达上百万IOPS. 详情 卢斯特,看 路斯特尔网站。 。 。 .
作为一个完全管理的服务,亚马逊FSx使您更容易使用Lustre来完成存储速度很重要的工作量. Amazon FSx for Lustre 消除了传统设置和管理 Lustre 文件系统的复杂性, 启用 几分钟后你就可以启动一个测试高性能的文件系统 它还提供多重部署 选项,这样您就可以为您的需要优化成本.
Amazon FSx for Lustre 是 POSIX 兼容的, 这样您就可以使用当前基于 Linux 的应用程序而无需制作 任何变化。 Lustre 的 Amazon FSx 提供了本地文件系统接口, 并像任何文件系统一样工作 Linux 操作系统. 它还提供读后写一致性,并支持文件锁定.
安装
导入到您的工程 :
import * as fsx from '@aws-cdk/aws-fsx';
基本用途
设置需要属性并创建 :
declare const vpc: ec2.Vpc;
const fileSystem = new fsx.LustreFileSystem(this, 'FsxLustreFileSystem', {
lustreConfiguration: { deploymentType: fsx.LustreDeploymentType.SCRATCH_2 },
storageCapacityGiB: 1200,
vpc,
vpcSubnet: vpc.privateSubnets[0],
});
连接中
要控制谁可以访问文件系统,请使用 .connections 属性。 FSx有一个固定的默认端口,所以你没有
需要指定端口。 此示例允许一个 EC2 实例连接到文件系统 :
declare const fileSystem: fsx.LustreFileSystem;
declare const instance: ec2.Instance;
fileSystem.connections.allowDefaultPortFrom(instance);
正在挂载
LustreFileSystem Construction 既暴露文件系统的 DNS 名称,又暴露其挂载名称,可以是 用于在 EC2 实例上挂载文件系统。 以下示例显示如何创建文件系统和 EC2 实例,然后使用用户数据在启动时挂载实例上的文件系统 :
import * as iam from '@aws-cdk/aws-iam';
declare const vpc: ec2.Vpc;
const lustreConfiguration = {
deploymentType: fsx.LustreDeploymentType.SCRATCH_2,
};
const fs = new fsx.LustreFileSystem(this, 'FsxLustreFileSystem', {
lustreConfiguration,
storageCapacityGiB: 1200,
vpc,
vpcSubnet: vpc.privateSubnets[0],
});
const inst = new ec2.Instance(this, 'inst', {
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T2, ec2.InstanceSize.LARGE),
machineImage: new ec2.AmazonLinuxImage({
generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2,
}),
vpc,
vpcSubnets: {
subnetType: ec2.SubnetType.PUBLIC,
},
});
fs.connections.allowDefaultPortFrom(inst);
// Need to give the instance access to read information about FSx to determine the file system's mount name.
inst.role.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonFSxReadOnlyAccess'));
const mountPath = '/mnt/fsx';
const dnsName = fs.dnsName;
const mountName = fs.mountName;
inst.userData.addCommands(
'set -eux',
'yum update -y',
'amazon-linux-extras install -y lustre2.10',
// Set up the directory to mount the file system to and change the owner to the AL2 default ec2-user.
`mkdir -p ${mountPath}`,
`chmod 777 ${mountPath}`,
`chown ec2-user:ec2-user ${mountPath}`,
// Set the file system up to mount automatically on start up and mount it.
`echo "${dnsName}@tcp:/${mountName} ${mountPath} lustre defaults,noatime,flock,_netdev 0 0" >> /etc/fstab`,
'mount -a',
);
导入
用于 Lustre 文件系统的 FSx 可以导入 fromLustreFileSystemAttributes(stack, id, attributes)编辑
后面的例子说明了您如何导入一个属于安全组的文件系统,使用它来导入文件
系统,然后导入 VPC 文件系统并添加一个 EC2 实例,使其访问文件
系统.
const sg = ec2.SecurityGroup.fromSecurityGroupId(this, 'FsxSecurityGroup', '{SECURITY-GROUP-ID}');
const fs = fsx.LustreFileSystem.fromLustreFileSystemAttributes(this, 'FsxLustreFileSystem', {
dnsName: '{FILE-SYSTEM-DNS-NAME}',
fileSystemId: '{FILE-SYSTEM-ID}',
securityGroup: sg,
});
const vpc = ec2.Vpc.fromVpcAttributes(this, 'Vpc', {
availabilityZones: ['us-west-2a', 'us-west-2b'],
publicSubnetIds: ['{US-WEST-2A-SUBNET-ID}', '{US-WEST-2B-SUBNET-ID}'],
vpcId: '{VPC-ID}',
});
const inst = new ec2.Instance(this, 'inst', {
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T2, ec2.InstanceSize.LARGE),
machineImage: new ec2.AmazonLinuxImage({
generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2,
}),
vpc,
vpcSubnets: {
subnetType: ec2.SubnetType.PUBLIC,
},
});
fs.connections.allowDefaultPortFrom(inst);
Windows 文件服务器的 FSx
用于Windows文件服务器的FSx的L2构建尚未被实施. 用于 Windows 的 FSx 即时化 文件系统,L1构造可以被CloudFormation定义.