Showing posts with label ec2. Show all posts
Showing posts with label ec2. Show all posts
Friday, November 01, 2019
mounting AWS (Amazon Web Services) EFS on Linux Ubuntu 18.04
Amazon Elastic File System (Amazon EFS) is a scalable file storage for EC2 and services that run on EC2 (for example Kubernetes clusters). The device is accessible on Linux via the NFS protocol and can be used my multiple instances and pods at the same time.
For more information on EFS visit AWS documentation.
Step one: Gather information
In our case ti is pretty straightforward. Ubuntu instance in the same VPC as the EFS and a DNS name of the file system we want to access. The format uses following convention:
http://file-system-id.efs.aws-region.amazonaws.com
And the exact URL is available on AWS console AWS home under filesystem's DNS name or via cli
Step two: Install the NFS Client for Linux
$ sudo apt-get update
$ sudo apt install nfs-kernel-server
Step three: Mount the file system on EC2 instance.
Create (if you don't have already) a mount point for the EFS
$ sudo mkdir -p /mnt/efs-mount-point
Mount the EFS share on the instance
$ sudo mount -t nfs -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport mount-target-DNS:/ /mnt/efs-mount-point
Now we have a mounted Amazon EFS file system on Ubuntu EC2 instance.
Keep in mind that command mounted doesn't persist across reboots. if you want it to be permanently accessible you have to add it to the fstab.
Common error:
efs mount.nfs: Connection timed out
This error can occur because either the Amazon EC2, mount target security groups or file system access are not configured properly.
For more troubleshooting tips you can visit:
https://docs.aws.amazon.com/efs/latest/ug/troubleshooting-efs-mounting.html
Tuesday, February 26, 2019
Getting AWS EC2 instance id (instanceid) from within the ec2 instance
In general you can get a lot of instance metadata by accessing API on
http://169.254.169.254/latest/meta-data/
That includes instance id.
On generic Linux system, you can get the ID either using curl:
curl http://169.254.169.254/latest/meta-data/instance-id
or wget:
wget -q -O - http://169.254.169.254/latest/meta-data/instance-id
If you instance is based on Amazon Linux or have cloud-utils installed you can also run:
ec2-metadata -i
for instance id.
more documentation on metadata is a available here:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
Provided by:Forthscale systems, cloud experts
http://169.254.169.254/latest/meta-data/
That includes instance id.
On generic Linux system, you can get the ID either using curl:
curl http://169.254.169.254/latest/meta-data/instance-id
or wget:
wget -q -O - http://169.254.169.254/latest/meta-data/instance-id
If you instance is based on Amazon Linux or have cloud-utils installed you can also run:
ec2-metadata -i
for instance id.
more documentation on metadata is a available here:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
Provided by:Forthscale systems, cloud experts
Tuesday, August 12, 2014
Creating a RAID device on Amazon AWS Elastic
Following procedure is for creating a software (OS managed) RAID disk devices.
EBS (Amazon web services elastic block storage) does not provide any RAID abilities by itself.
But you can use Linux SW raid option to increase either speed or device redundancy.
This tutorial will show you how.
For Debian based (Debian, Ubuntu) execute:
apt-get install mdadm
For Red Hat based (RHEL, Oracle linux, CentOS) execute:
yum install mdadm
For Gentoo execute:
emerge mdadm
Attach new EBS volumes to EC2 instance and write down the device name (for example xvdf and xvdg)
Set up RAID 0 on this EBS instance with the following command:
mdadm --create --verbose --auto=yes /dev/md0 --chunk=256 --level=0 --raid-devices=2 /dev/xvdf /dev/xvdg
blockdev --setra 65536 /dev/md0
Now verify that the raid device /dev/md0 exists
cat /proc/mdstat
Next step is to add devices to the mdadm.conf file (main sw raid configuration file)
echo DEVICE /dev/xvdf /dev/xvdg | sudo tee /etc/mdadm/mdadm.conf
Add the other device info about /dev/md0 to the mdadm.conf file so that it comes back on reboot
mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
To create XFS file system, you will need to install support for it first.
For Debian based (Debian, Ubuntu) execute:
apt-get install xfsprogs
For Red Hat based (RHEL, CentOS) execute:
yum install xfsprogs
For Oracle Linux:
Log in to ULN, and subscribe your system to the ol6_x86_64_latest channel.
Then run:
yum install xfsprogs xfsdump
For Gentoo execute:
emerge xfsprogs
Once installed, execute
mkfs.xfs -f /dev/md0
to create an actual filesystem on your new RAID device.
Now you can mount the file system
mkdir /MOUNTPOINT (for example /raid)
mount /dev/md0 /MOUNTPOINT (for example /raid)
Verify the volume exists and the size you expected
df -h
Edit /etc/fstab to make sure mount point comes back on reboot
/dev/md0 /raid xfs noatime,noexec,nodiratime 0 0
You have the new RAID based partition in your system.
Same procedure will work on both public EC2 cloud and VPC.
Provided by:Forthscale systems, cloud experts
EBS (Amazon web services elastic block storage) does not provide any RAID abilities by itself.
But you can use Linux SW raid option to increase either speed or device redundancy.
This tutorial will show you how.
First install RAID management tool on target EC2 instances
For Debian based (Debian, Ubuntu) execute:
apt-get install mdadm
For Red Hat based (RHEL, Oracle linux, CentOS) execute:
yum install mdadm
For Gentoo execute:
emerge mdadm
Now prepare the EBS devices.
Create desired EBS volumeAttach new EBS volumes to EC2 instance and write down the device name (for example xvdf and xvdg)
Now you can create the RAID device from them.
Set up RAID 0 on this EBS instance with the following command:
mdadm --create --verbose --auto=yes /dev/md0 --chunk=256 --level=0 --raid-devices=2 /dev/xvdf /dev/xvdg
blockdev --setra 65536 /dev/md0
Now verify that the raid device /dev/md0 exists
cat /proc/mdstat
Next step is to add devices to the mdadm.conf file (main sw raid configuration file)
echo DEVICE /dev/xvdf /dev/xvdg | sudo tee /etc/mdadm/mdadm.conf
Add the other device info about /dev/md0 to the mdadm.conf file so that it comes back on reboot
mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
Filesystem
One RAID is set up , you can create a file-system on it, we usually propose XFS, but you can use any file system (ext3/4, zfs or reiserfs)To create XFS file system, you will need to install support for it first.
For Debian based (Debian, Ubuntu) execute:
apt-get install xfsprogs
For Red Hat based (RHEL, CentOS) execute:
yum install xfsprogs
For Oracle Linux:
Log in to ULN, and subscribe your system to the ol6_x86_64_latest channel.
Then run:
yum install xfsprogs xfsdump
For Gentoo execute:
emerge xfsprogs
Once installed, execute
mkfs.xfs -f /dev/md0
to create an actual filesystem on your new RAID device.
Now you can mount the file system
mkdir /MOUNTPOINT (for example /raid)
mount /dev/md0 /MOUNTPOINT (for example /raid)
Verify the volume exists and the size you expected
df -h
Edit /etc/fstab to make sure mount point comes back on reboot
/dev/md0 /raid xfs noatime,noexec,nodiratime 0 0
You have the new RAID based partition in your system.
Same procedure will work on both public EC2 cloud and VPC.
Provided by:Forthscale systems, cloud experts
Thursday, September 06, 2012
Setting up Amazon AWS EC2 ftp server with Linux and VSFTP:
Install vsftp (example for Ubuntu / Debian)
apt-get -y install vsftpd
Edit configuration file (in our example with local authentication and no guest user)
vi /etc/vsftpd.conf
write_enable=YES
anonymous_enable=NO
local_umask=022
local_enable=YES
#to add passive ftp:
pasv_enable=YES
pasv_max_port=12100
pasv_min_port=12000
port_enable=YES
pasv_address="your external instance ip or address"
and open inbound port range 20-21 and 12000-12100 in your security groups
Provided by: ForthScale systems, scalable infrastructure experts
apt-get -y install vsftpd
Edit configuration file (in our example with local authentication and no guest user)
vi /etc/vsftpd.conf
write_enable=YES
anonymous_enable=NO
local_umask=022
local_enable=YES
#to add passive ftp:
pasv_enable=YES
pasv_max_port=12100
pasv_min_port=12000
port_enable=YES
pasv_address="your external instance ip or address"
and open inbound port range 20-21 and 12000-12100 in your security groups
Provided by: ForthScale systems, scalable infrastructure experts
Sunday, February 19, 2012
Amazon AWS EC2 storage types
You can connect different storage types to Amazon EC2 instances, two of them provided naively by Amazon platform and the rest are either provided by external sources or tweaks. In any EC2 instance (except micro) you have instance storage included in a package. You can also use elastic block storage (EBS) and have an option connecting different 3rd party storage over the network.
Instance storage is a fast non-persistent storage provided by Amazon. It means it will revert to it`s original state after any system shutdown, erasing any changes you have applied to the file-system. It is very useful for running “dumb” servers that do not store data locally or as an additional storage for temporary files.
Elastic block storage (EBS) is a persistent storage provided by Amazon. All and any data stored on it is available after instance shutdown and can be manipulated with on device level. For example you can detach an EBS volume from one instance and attach it to another. However EBS can not be attached to more then once instance at the same time.
Using S3 as a file system. S3 is a storage infrastructure provided by Amazon as a service, it is not a part of EC2 (Elastic cloud) but can be used to store and retrieve any amount of data from anywhere at any time. Because S3 infrastructure is fully managed and scaled by Amazon it is very useful for large scale web projects, backup media and large volume data transfers. Using S3 as a file system is done via FUSE in Linux or as a mapped network drive in MS Windows. We are providing a tutorial on Linux implementation of S3 as a file system .
There are also few companies out there providing iSCSI storage arrays for AWS, one of them is Zadara storage, company providing Virtual Private Storage Arrays and currently in beta stage. iSCSI as any other network attached storage systems will incorporate persistence and availability of EBS at much faster speed.
Sunday, February 12, 2012
Setting Filezilla Server on Amazon EC2 instance with passive ftp
If you want to set Filezilla ftp server to handle passive connections on your AWS EC2 instances, you should do the following.
Select non used TCP ports, for example 9024-9048 range
Configure firewalls:
In your AWS EC2 security group, allow the incoming connections on chosen ports:
tcp port 20
tcp port 21
tcp port 9024-9048
If using Windows firewall on you instance, allow connections on same ports.
Now configure Filezilla to use specific port range on Passive connections:
Open Filezilla management console.
Got to: Edit > Settings > Passive Mode Settings
'External Server IP Address for passive mode transfers'
If you use AWS Elastic IP, enter it in "Use the following IP",
if not - use Filezilla provided web service with "Retrieve external IP address from" option.
Check 'Don't use external IP for local connections'
Check 'Use custom port range'
Enter chosen values (in our example) 9024 - 9048 for custom port range.
Powered by 123ContactForm | Report abuse
Provided by:SiQ systems, Cloud expertsMonday, October 24, 2011
allowing public access to amazon s3 bucket
You might need to give public access to bucket contents, for example if you use the bucket to load images for your site. Simple GUI option supplied by Amazon only gives access for a specific files but if you need a whole bucket, you have to use policy.
To edit policy, in GUI go to
'Bucket => Properties => Add Bucket Policy'
And add for example (just change yourbucketname with the name of your bucket:
{
"Version": "2011-10-24",
"Statement": [
{
"Sid": "AddPerm",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::yourbucketname/*"
}
]
}
"Version": "2011-10-24",
"Statement": [
{
"Sid": "AddPerm",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::yourbucketname/*"
}
]
}
Tuesday, July 06, 2010
Setting DNS server on Amazon EC2
Setting up bind9 DNS server on Amazon EC2 today tough me that Amazon`s built in service definition in security group only includes TCP. be sure to open UDP port 53 as well for your server to function properly.
Provided by:SiQ systems, Cloud experts
Provided by:SiQ systems, Cloud experts
Subscribe to:
Posts (Atom)
2026. What I Actually Do Now
It’s been over 20 years of on-and-off dumping into this blog. 27 and going years in tech, more than 10 years around AI, going back to Heili ...
-
Following information is intended for bash shell only. The system variable TMOUT can be set to specify the amount of time the user is ina...
-
Amazon Elastic File System (Amazon EFS) is a scalable file storage for EC2 and services that run on EC2 (for example Kubernetes clusters). ...
-
To this day (8/8/2019) Terraform is not packaged in an official apt repository. There is an option to install it with Snap but be careful ...