<?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; RDS</title>
	<atom:link href="http://aws-musings.com/tag/rds/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>Database in cloud &#8211; Amazon RDS or MySQL on ebs?</title>
		<link>http://aws-musings.com/database-in-cloud-should-i-use-amazon-rds-or-mysql-installed-on-an-ebs-backed-ec2-instance/</link>
		<comments>http://aws-musings.com/database-in-cloud-should-i-use-amazon-rds-or-mysql-installed-on-an-ebs-backed-ec2-instance/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 17:56:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[RDS]]></category>
		<category><![CDATA[cloud database]]></category>
		<category><![CDATA[ec2 database]]></category>
		<category><![CDATA[mysql in cloud]]></category>
		<guid isPermaLink="false">http://aws-musings.com/?p=114</guid>
		<description><![CDATA[Recently Amazon launched RDS &#8211; Relational Database Service. Before Amazon offered this service, we had a MySQL configured on an ec2 instance. We needed one more database in cloud. Which way did we go? In this article, I have tried to compare both the options. RDS Pros: 1) No need to maintain MySQL in the [...]]]></description>
			<content:encoded><![CDATA[<p>Recently Amazon launched <a href="http://aws.amazon.com/rds/">RDS &#8211; Relational Database Service</a>. Before Amazon offered this service, we had a MySQL configured on an ec2 instance. We needed one more database in cloud. Which way did we go? In this article, I have tried to compare both the options. </p>
<p><span id="more-114"></span><br />
<strong>RDS Pros:</strong><br />
1) No need to maintain MySQL in the cloud. Amazon will maintain it. Amazon will apply all the patches and upgrade the server software.</p>
<p>2) It&#8217;s very easy to scale up. All you have to do is execute <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=2936">rds-modify-db-instance command</a>. You can change your db class to the bigger/better machine.</p>
<p>3) Snapshot based backups are very easy to manage.</p>
<p>4) No need to manage an ec2 volume, backup and an ec2 instance separately to run your database in the cloud. RDS combines all the three in one package.</p>
<p><strong>RDS Cons:</strong><br />
1) The biggest problem about RDS is the 4 hour per week maintenance window. I don&#8217;t believe that this maintenance takes place every week. They only take down your database when they are applying patches or upgrading the database server. They will take down your database in your specified time only. This time can be changed any time by simply executing an api call. I also believe that in most cases the downtime  will be much less than 4 hours. Nevertheless the threat of downtime exists every week!</p>
<p>2) Does not expose my.cnf file of the database. It instead gives you an <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=2935">API to modify the parameters</a></p>
<p>3) If you are an advanced MySQL user and want to use tweaked MySQL (such as by Percona http://www.percona.com/), RDS is clearly not a solution.</p>
<p>4) As of now, there is no replication support. This means you cannot have any read only slaves. I have read somewhere that they are working on it. </p>
<p>Clearly RDS is not a silver bullet. In fact in many cases where your application cannot run without a database, you may not be able to afford the weekly downtime. I talked to some friends and the 4 hour weekly downtime was their the biggest problem with RDS.  I wish that Amazon would declare the downtime whenever the need arises (such as when new MySQL patches are ready) and less frequently (such as once a month).</p>
<p>We did not have a full time system administrator in our team. We were bunch of software engineers trying to manage our ec2 instances by ourselves. Furthermore our application wasn&#8217;t dependant on database completely. Most of the data was cached. Thus we could afford an occasional downtime. That is why we chose RDS.</p>
]]></content:encoded>
			<wfw:commentRss>http://aws-musings.com/database-in-cloud-should-i-use-amazon-rds-or-mysql-installed-on-an-ebs-backed-ec2-instance/feed/</wfw:commentRss>
		<slash:comments>2</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>

