<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>My AWS Musings &#187; EC2</title>
	<atom:link href="http://aws-musings.com/tag/ec2/feed/" rel="self" type="application/rss+xml" />
	<link>http://aws-musings.com</link>
	<description>Cloud computing, EC2, RDS, SQS, S3, Java...</description>
	<lastBuildDate>Mon, 30 May 2011 18:13:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Amazon Relational Database Service (RDS) &#8211; The Timezone Problem</title>
		<link>http://aws-musings.com/amazon-relational-database-service-rds-the-timezone-problem/</link>
		<comments>http://aws-musings.com/amazon-relational-database-service-rds-the-timezone-problem/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 05:41:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[EC2]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[RDS]]></category>
		<category><![CDATA[mysql in cloud]]></category>
		<category><![CDATA[time zone]]></category>
		<category><![CDATA[timezone]]></category>
		<guid isPermaLink="false">http://aws-musings.com/?p=155</guid>
		<description><![CDATA[The default time zone of your RDS database instance is UTC. It simply can not be changed. RDS does not give you super privileges. That is why you won&#8217;t be able to change the global time zone by simply executing: SET GLOBAL time_zone = 'US/Pacific'; The default_time_zone db parameter is not modifiable. In this Amazon [...]]]></description>
			<content:encoded><![CDATA[<p>The default time zone of your <a href="http://aws.amazon.com/rds/">RDS</a> database instance is UTC. It simply can not be changed. </p>
<p>RDS does not give you super privileges. That is why you won&#8217;t be able to change the global time zone by simply executing:<br />
<code><br />
SET GLOBAL time_zone = 'US/Pacific';<br />
</code><br />
<span id="more-155"></span><br />
The default_time_zone db parameter is not modifiable.</p>
<p>In <a href="http://developer.amazonwebservices.com/connect/thread.jspa?messageID=161339">this Amazon forum thread</a>, you can clearly see the AWS guy saying that there is no way to change the time zone of a RDS instance.</p>
<p>It is very important to understand that unlike Java (or other programming languages), MySQL does not store time zone in its date, datetime or timestamp datatypes. That is why it&#8217;s important that all the dates are stored in one time zone. Most people prefer to store them in their own time zone for easier calculations.</p>
<p>Since you cannot change the database server settings, you will have to change your application. Here are some approaches you can take to make sure that the date and time stored in your database is in your desired time zone.</p>
<p><strong>1) Set time zone per database connection </strong><br />
When ever you create a connection, set time zone using<br />
<code><br />
SET time_zone = 'US/Pacific';<br />
</code><br />
This time zone will be valid only for the connection. That is why it must be done for every single connection you open. If you have a java application, you can use a wrapper around the JDBC driver to accomplish this.</p>
<p>Please note that MySQL allows you to specify time zone by its name (such as &#8216;US/Pacific&#8217;) or by the difference in hours  (such as &#8216;-8:00&#8242;). If you are in a part of United States or any other part of the world that uses day light savings, do not use the difference of hours option for obvious reasons.</p>
<p>Named time zones can only be used if the time zone related tables are populated in MySQL. Thankfully they seem to be populated in RDS.</p>
<p><strong>2) Use convert_tz function</strong><br />
You can use MySQL&#8217;s convert_tz function to convert the time zone. For example:</p>
<p><code><br />
insert into my_table (created_date) values (convert_tz(now(), 'GMT', 'US/Pacific'));<br />
</code></p>
<p>For more information on convert_tz function visit  <a href="http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_convert-tz">convert_tz documentation on MySQL website</a> </p>
<p><strong>3) Set the date/time pragmatically in your application code in every query. </strong><br />
Thus if you have created_date column in your table, do not rely on timestamp datatype&#8217;s default value. The default value will be in  UTC time zone. Set the value explicitly using application code. If you are using a prepared statement this becomes very easy. All you have to make sure is to pass a date object with appropriate time zone set in it. In order for your application to calculate correct date, you have to make sure that your application instance&#8217;s time zone is set to your time zone.</p>
<p>Amazon ec2 instances allow you to change their default time zones. If your web server is also deployed in ec2, I would suggest you to bundle an AMI with your time zone and use it to launch all your instances. I think most of the ubuntu public AMIs have time zone set to UTC.</p>
]]></content:encoded>
			<wfw:commentRss>http://aws-musings.com/amazon-relational-database-service-rds-the-timezone-problem/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>4 easy steps to enable remote desktop on your ubuntu ec2 instance</title>
		<link>http://aws-musings.com/4-easy-steps-to-enable-remote-desktop-on-your-ubuntu-ec2-instance/</link>
		<comments>http://aws-musings.com/4-easy-steps-to-enable-remote-desktop-on-your-ubuntu-ec2-instance/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 23:18:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[EC2]]></category>
		<category><![CDATA[freenx]]></category>
		<category><![CDATA[gui]]></category>
		<category><![CDATA[nx]]></category>
		<category><![CDATA[remote desktop]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[vnc]]></category>
		<guid isPermaLink="false">http://aws-musings.com/?p=124</guid>
		<description><![CDATA[Enabling remote desktop on an ubuntu ec2 instance is pretty easy by using NX. We will use FreeNX at the server and NoMachine NX client on the client machine. NX is a much better alternative to VNC. You can install NoMachine client on windows, mac or linux. For more information visit http://www.nomachine.com Here are the [...]]]></description>
			<content:encoded><![CDATA[<p>Enabling remote desktop on an ubuntu ec2 instance is pretty easy by using NX.  We will use FreeNX at the server and NoMachine NX client on the client machine. NX is a much <a href="http://www.keycruncher.com/blog/2008/07/07/vnc-vs-nomachine-nx-nomachine-wins-hands-down/">better alternative to VNC</a>. You can install NoMachine client on windows, mac or linux. For more information visit <a href="http://www.nomachine.com">http://www.nomachine.com</a></p>
<p><span id="more-124"></span><br />
Here are the easy steps:</p>
<p><strong>1) Install ubuntu desktop on your server instance</strong><br />
By default X server, GNOME etc is not installed on your ubuntu instance. You can install it by simply executing the following commands:<br />
<code><br />
export DEBIAN_FRONTEND=noninteractive<br />
sudo -E apt-get update<br />
sudo -E apt-get install -y ubuntu-desktop<br />
</code><br />
It will install lot of stuff. So don&#8217;t get surprised if it takes 10 to 15 minutes to finish it.</p>
<p><strong>2) Install FreeNX server on your server</strong><br />
The following commands assume that you are using ubuntu 9.10 (Karmic Koala) image.<br />
<code><br />
sudo add-apt-repository ppa:freenx-team<br />
sudo apt-get update<br />
sudo aptitude install -y freenx<br />
sudo /usr/lib/nx/nxsetup --install<br />
</code></p>
<p><em>If you are using older ubuntu versions, please visit <a href="https://help.ubuntu.com/community/FreeNX">FreeNX server installation page on ubuntu website</a> to get the instructions for installing FreeNX  server.</em></p>
<p>While executing the last command, you will get the following prompt:</p>
<p><code>It is recommended that you use the NoMachine key for<br />
        easier setup. If you answer "y", FreeNX creates a custom<br />
        KeyPair and expects you to setup your clients manually.<br />
        "N" is default and uses the NoMachine key for installation</code>.</p>
<p>I would say answer &#8216;N&#8217; which is the default. If you answer Y, you will have to generate keys and put them at a specific location in the client.</p>
<p><strong>3) Enable password authentication on the ssh server</strong><br />
Edit  /etc/ssh/sshd_config and set PasswordAuthentication to yes. By default password authentication is disabled.<br />
You will need to restart ssh process by executing</p>
<p><code>sudo /etc/init.d/ssh restart</code></p>
<p>Now that you have enabled password authentication, you should make sure that the the user you are going to use for using remote desktop has a password. Cannonical&#8217;s karmic images come with &#8216;ubuntu&#8217; user. This user does not have a password. You can set a password by executing</p>
<p><code>sudo passwd ubuntu</code></p>
<p><strong>4) Install and setup NX client </strong><br />
Now install the NoMachineNX client on your Desktop. You can download the client form <a href="http://www.nomachine.com/download.php">http://www.nomachine.com/download.php</a>. You can install it by simply double clicking the downloaded file. Once you install it, click on the NX Connection wizard to setup a new connection. Fill in the values as shown below. Make sure that you put in your server address in the host field.</p>
<p><a href="http://aws-musings.com/wp-content/uploads/2010/02/NX-1.jpg"><img src="http://aws-musings.com/wp-content/uploads/2010/02/NX-1-300x213.jpg" alt="" title="NX-1" width="300" height="213" class="alignnone size-medium wp-image-144" /></a></p>
<p><a href="http://aws-musings.com/wp-content/uploads/2010/02/NX-2.jpg"><img src="http://aws-musings.com/wp-content/uploads/2010/02/NX-2-300x213.jpg" alt="" title="NX-2" width="300" height="213" class="alignnone size-medium wp-image-145" /></a></p>
<p>And that&#8217;s it! NX client will create a desktop shortcut for the server connection (Only if you choose to do so). Double click the shortcut, fill in the username (ubuntu) and the password (set in step 3) and you are in!</p>
]]></content:encoded>
			<wfw:commentRss>http://aws-musings.com/4-easy-steps-to-enable-remote-desktop-on-your-ubuntu-ec2-instance/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>autoscaling in 10 mins</title>
		<link>http://aws-musings.com/autoscaling-in-10-mins/</link>
		<comments>http://aws-musings.com/autoscaling-in-10-mins/#comments</comments>
		<pubDate>Sat, 26 Dec 2009 21:46:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Autoscaling]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[aws]]></category>
		<guid isPermaLink="false">http://aws-musings.com/?p=94</guid>
		<description><![CDATA[Amazon documentation states that Auto Scaling allows you to automatically scale your Amazon EC2 capacity up or down according to conditions you define. Simply put, it can start and stop ec2 instances based on a condition you define. This is especially important in an environment where you pay more for more capacity. Thus if a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://aws.amazon.com/autoscaling/">Amazon documentation</a> states that </p>
<blockquote><p>Auto Scaling allows you to automatically scale your Amazon EC2 capacity up or down according to conditions you define.</p></blockquote>
<p> Simply put, it can start and stop ec2 instances based on a condition you define. This is especially important in an environment where you pay more for more capacity. Thus if a website has a defined traffic pattern such as traffic peaks every afternoon and goes down in the night, you can have autoscaling start more web servers in the afternoon and shut down unnecessary ones in the night. Isn&#8217;t that amazing?</p>
<p><span id="more-94"></span><br />
You need to be using an <a href="http://aws.amazon.com/elasticloadbalancing/">elastic load balancer</a> to configure auto scaling. Configuring autoscaling consists of three steps:<br />
1) Create launch configuration<br />
2) Create auto scaling group<br />
3) Create auto scaling trigger</p>
<p><strong>Create launch configuration</strong><br />
Launch configuration provides information about the instance to be launched. You can see that an AMI, instance type, availability zone and security groups are specified when a luanch configuration is created.<br />
<code><br />
as-create-launch-config web --image-id ami-656583ff --instance-type m1.small --group ssh,web --key my-keypair<br />
</code></p>
<p><strong>Create autoscaling group</strong><br />
A launch configuration is attached with an autoscaling group.  The group consists of pool of instances. You can specify minimum and maximum size of the pool<br />
<code><br />
as-create-auto-scaling-group myasgroup --launch-configuration web --availability-zones us-east-1a --min-size 4 --max-size 10 --cooldown 120 --load-balancers myloadbalancer<br />
</code></p>
<p><strong>Create autoscaling trigger</strong><br />
The trigger defines the conditions to start or stop ec2 instances. For example:<br />
<code><br />
as-create-or-update-trigger my-latency-trigger --auto-scaling-group myasgroup --dimensions "LoadBalancerName=myloadbalancer" --measure Latency --period 60 --statistic Average --lower-threshold 0.25 --upper-threshold 0.75 --breach-duration 300 --lower-breach-increment=-1 --upper-breach-increment 1 --namespace "AWS/ELB" --unit Seconds<br />
</code><br />
will create a latency trigger with 0.25 as the lower threshold and 0.75 seconds as the upper threshold. If your website latency goes beyond 0.75 seconds, this trigger will be activated and hence an instance will be launched (as specified by upper breach increment). Besides latency you can use <a href="http://docs.amazonwebservices.com/AmazonCloudWatch/latest/DeveloperGuide/arch-AmazonCloudWatch-metricscollected.html#loadbalancing-metrics">different dimensions monitored by cloudwatch</a> such as request count, health host count and unhealthy host count.</p>
<p>That&#8217;s it! It&#8217;s that simple. More information about autoscaling can be read <a href="http://docs.amazonwebservices.com/AutoScaling/latest/DeveloperGuide/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://aws-musings.com/autoscaling-in-10-mins/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Amazon RDS in 10 mins</title>
		<link>http://aws-musings.com/amazon-rds-in-10-mins/</link>
		<comments>http://aws-musings.com/amazon-rds-in-10-mins/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 19:49:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[RDS]]></category>
		<category><![CDATA[aws]]></category>
		<category><![CDATA[cloud database]]></category>
		<category><![CDATA[EC2]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql in cloud]]></category>
		<category><![CDATA[relational database service]]></category>
		<guid isPermaLink="false">http:/?p=1</guid>
		<description><![CDATA[Amazon&#8217;s Relational Database Service (RDS) offers hosted MySQL database in the cloud. In pre RDS era, you would have fired up an instance, installed MySQL yourself on it, configured an EBS volume so that the database data storage is persistent. You would have setup a cron to snapshot your EBS volume. But RDS saves the [...]]]></description>
			<content:encoded><![CDATA[<p>Amazon&#8217;s Relational Database Service (RDS) offers hosted MySQL database in the cloud.</p>
<p>In pre RDS era, you would have fired up an instance, installed MySQL yourself on it, configured an EBS volume so that the database data storage is persistent. You would have setup a cron to snapshot your EBS volume. But RDS saves the headache of managing an EBS volume and your instance separately. It offers you installed MySQL with persistent storage. It also offers you automated database backup. And setting it up is as easy as 1,2,3&#8230;</p>
<p><span id="more-1"></span><br />
Here is what you do to setup a database using RDS:</p>
<p>1) Sign up for RDS by visiting http://aws.amazon.com/rds.</p>
<p>2) Install RDS tools on your local machine so that you can execute RDS setup commands. You can download the toolkit from the <a title="RDS CLI Download Page" href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=2928&amp;categoryID=294" target="_blank">download page</a>.<br />
Installation of the client toolkit involves the following procedure:</p>
<p>a) Unzip the downloaded file into a suitable folder, say /home/vaibhav/software/rds-tools</p>
<p>b) Make sure that you have java 1.5 or up installed on your machine and  JAVA_HOME variable is set. If not <a title="Install latest version of java" href="http://java.com/en/download/help/5000010500.xml" target="_blank">install the latest version of java</a> and <a title="How to set JAVA_HOME?" href="http://www.ehow.com/how_5120825_change-java-home.html" target="_blank">set JAVA_HOME</a> to the folder where java is installed.</p>
<p>c) Set AWS_RDS_HOME=/home/vaibhav/software/rds-tools in your .bashrc or execute the following command to  set AWS_RDS_HOME for this session</p>
<p><code>export AWS_RDS_HOME=/home/vaibhav/software/rds-tools</code></p>
<p>d)Add AWS_RDS_HOME to your path by executing <code>export PATH=$PATH:$AWS_RDS_HOME/bin</code></p>
<p>e) Rename credential-file-path.template in AWS_RDS_HOME (/home/vaibhav/software/rds-tools) to any name of your choice say credentials.txt. Set AWS_CREDENTIAS_FILE variable by executing</p>
<p><code>export AWS_CREDENTIAL_FILE=&lt;the path of the file created above - credentials.txt</code></p>
<p>3) Now let&#8217;s create a security group before creating a database instance. This is because we would like to supply this security group while creating an instance. A security group can be created by executing</p>
<p><code>rds-create-db-security-group --db-security-group-name database  --db-security-group-description 'Default mysql database security group'</code></p>
<p>This will create a security group called database. If you want to connect to the mysql server from your local machine, you will need to add authorization to this group by executing</p>
<p><code>rds-authorize-db-security-group-ingress --db-security-group-name database -i 71.168.56.100/32</code></p>
<p>Here 71.168.56.100/32 is the ip address range of the network from which you want to access the database and 123456789012 is your Amazon AWS account number</p>
<p>4) Now create the database instance. The database instance can be created by executing the following command:<br />
<code><br />
rds-create-db-instance --db-instance-identifier reporting --allocated-storage 5 --db-instance-class db.m1.small --engine MySQL5.1 --master-username master --master-user-password s0mePassw0rd --db-name MyFirstDb --availability-zone us-east-1a  --preferred-maintenance-window  Sun:12:00-Sun:16:00   --preferred-backup-window  10:00-12:00 --db-security-groups database --headers<br />
</code></p>
<p>There are few parameters that you need to understand very well before executing this command. The preferred-maintenance-window is the 4 hour time period Amazon requires to apply patches and to carry out other maintenance tasks on the database server.  preferred-backup-window  is the daily two hour window in which your database will be backed up. The database won&#8217;t be down in the period, but its performance could get affected because of the backup operation. Please note that both the time periods must be specified in UTC time. If you are going to access this database from an Amazon ec2 instance then choose an availability zone that is the same as the web server so that you are not charged for the bandwidth. You should change other parameters such as the database instance type, allocated storage as per your requirement. More information on these parameters can be obtained from the <a title="CLI Reference" href="http://docs.amazonwebservices.com/AmazonRDS/latest/CommandLineReference/" target="_blank">CLI reference page</a>. The instance name will be <em>reporting</em> as specified. To find out its address, you can simply execute</p>
<p><code> rds-describe-db-instances</code></p>
<p>This command will list all the db instances with their dns names. The dns name will be something like reporting.crly0gpnhroz.us-east-1.rds.amazonaws.com. The port will also be in the output (3306). You can use this dns name and port to connect to the database using any mysql client.</p>
]]></content:encoded>
			<wfw:commentRss>http://aws-musings.com/amazon-rds-in-10-mins/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

