For those users looking to seamlessly deploy CUBRID Database on Amazon Web Services (AWS), we have created Amazon EC2 Machine Images (AMI) with CUBRID and its APIs installed. In this tutorial I will explain the key steps you need to perform in order to get everything started on AWS. We will:
- Review available CUBRID AMIs.
- Review the software stack of the CUBRID AMI.
- Create an account on Amazon Web Services.
- Launch your instances based on CUBRID AMI.
- Configure your instance.
The following is a list of CUBRID AMI we (owner ID: 024941853939) provide officially. We distribute CUBRID AMIs to all available regions (if a new region is available and we do not distribute there, let us know and we will add it as well). Shortly we will add AMIs based on other Linux distirbutions as well.
||CUBRID 188.8.131.525 x64
||Ubuntu 12.04.1 x64
||us-east-1 (N. Virginia)
||us-west-1 (N. California)
||sa-east-1 (São Paulo)
I will explain how to use these Amazon Machine Images below. First, let's see what software will be available for you in this Amazon Machine Image.
- Official Ubuntu 12.04.1 (precise) x64 LTS cloud AMI distributed by Canonical (AMI ID: ami-8e109ebe; note, this is not CUBRID AMI ID).
We will soon provide CentOS based CUBRID AMIs.
The following software is installed on Ubuntu 12.04.1 by default.
- Python 2.7.3 with pip 1.0
- Perl 5.14.2 with CPAN 1.57
Now here we have installed the software necessary to work with CUBRID Database Server.
- CUBRID Database Server 184.108.40.2065 x64
- Python driver v8.4.3.0002
- Perl driver 8.4.3.0001
- PHP 5.3.10 with PECL/PEAR
- PHP driver 8.4.3.0001
- PDO driver 8.4.3.0001
- Apache HTTP Server 2.2.22 (installed automatically by PHP)
These are all you need to get started with CUBRID Database on Amazon Web Services.
Create an account on Amazon Web Services
If you already have an AWS account, you can skip this step and continue. If you do not have one:
- Go to http://aws.amazon.com, and click on the Sign Up button. Sign in to your existing AWS account or create a new one.
- Go to http://aws.amazon.com/ec2 and clck on teh Sign Up Now button. If it is the first time you are signing up, you may be eligible for free 750 hours of Micro instance every month for one year.
- Enter your credit card information and complete your signup for the Amazon EC2 service. It takes from several hours to couple of days for your EC2 account to set up. Eventually you should receive a confirmation email from Amazon Web Services.
- Once you have your EC2 account set up, go to EC2 Web Console.
- Create a key pair. You will need this key pair to launch EC2 instances and connect to them via SSH. The public key will remain in your EC2 account, while you will use the private key when establising an SSH connection to newly created instances.
- Click Key Pairs under Networking and Security in the Navigation pane and then click the Create Key Pair button (save it in e.g. ~/.ec2/ec2.pem). Download the private key. You will not be able to download it later. Do it now!
- Set up your Amazon API credentials. For this you need to create a new certificate.
- On the top right corner of the EC2 page go to the menu displayed by your name, there choose Security Credentials.
- Under the Access Credentials click on the X.509 Certificates tab.
- Create a new certificate.
- Once created, download the private key and the certificate (save them in e.g. ~/.ec2/cert-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem and ~/.ec2/pk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem).
- Make your credential files private. In your command line type:
chmod go-rwx ~/.ec2/*.pem
- If at a later time you need to create a new certificate, you can come back here and create a new certificate again.
Congratulations! Now you are ready to create your first Amazon EC2 instance.
Launching CUBRID Instance
There are different ways you can find and launch CUBRID Amazon Machine Images. Below I will explain two ways:
- From AWS site
- From your EC2 Web Console
From AWS site
You can navigate to http://aws.amazon.com/amis/cubrid-8-4-3-sql-database-ebs-64-bit-ubuntu-12-04-1 public AMI listing and press the Launch Instance button from there. Then continue as described below.
From your EC2 Web Console
- Go back to your EC2 Web Console.
- At the top right corner of the page you will see a dropdown menu with a list of availability zones. Switch to the one you think is most suitable for your needs.
- Once the Web Console is refreshed, you will see a Launch Instance button. Press it in order to see the Launch Wizard.
- Select the Classic Wizard and press Continue.
Configure EC2 Instance
- Now you need to choose one of CUBRID AMIs.ins
- Press on the Community AMIs tab.
- In the search box type cubrid or directly enter one of the CUBRID AMI IDs available in that region. The system will list matching AMIs as shown in the schreenshot below.
- Make sure the owner ID is 024941853939. You can find it the Manifest field as shown above. This owner ID proves that the selected AMI is created by us, the CUBRID Team, and we will provide support. In case another owner ID is set for some of our CUBRID AMIs, we will mention so in the table above.
- To select the desired CUBRID AMI, press the Select button on the right of that image.
- Next, configure your instances.
- Choose the number of instances. In this tutorial we will choose to launch only 1 instance.
- Then choose the Instance Type you want to launch. Each type differs in CPU units, CPU cores, Memory, and Price. You may want to check out the EC2 Pricing to make the right decision. For this tutorial we will choose the smallest T1.Micro instance which provides 613MB of memory and up to 2 EC units (for short periodic bursts). Notice, though, that this Micro instance does not guarantee 2 EC units. In fact, it will provide only short periodic bursts of 2 EC units, and often it will fall way below the expectation. For more details and test results on this matter check out Greg Wilson's blog about Amazon EC2 Micro Instance and Stolen CPU.
- Next, you may choose between Launch Instances (the normal EC2 instances) and Request Spot Instances. If you are just beginning, I suggest you go with a common Launch Instances option. This is what we will do in this tutorial.
- Availability Zone: if you have no preference on where exactly in your current region should the instance launch, simply leave it as No Preference.
- Once done, press the Continue button.
- Next, the Launch Wizard will show Advanced Options. You may leave everything with the default settings, and press Continue.
- Storage Device Configuration: the defult configuration of the CUBRID AMI will attach an 8GB EBS volume storage device (default from Ubuntu by Canonical) to the newly launched instance. You may leave it with the default settings, or if necessary change it by pressing on the Edit button. When done, press on the Continue button.
- Next, add tags to your instance. For example, you can give a Name to your instance such as My new instance with CUBRID 8.4.3 or something of that sort. Then press the Continue button.
- Now you need to choose the Key Pairs to let the EC2 know which keys will allow users to access this instance via SSH. Now, you have already created your Key Pair above when you created your EC2 account, have not you? If you have previously created your Key Pair and you have the private key downloaded, then choose it from the given list as shown below. If you have not created the Key Pair before or want to create a new one now, then choose the Create a new Key Pair option, and create one. In this tutorial, I will use the previously created Key Pair. Remember, that once you set this Key Pair in this step, you will not be able to change it after the instance is launched.
- Next, Configure the Firewall.
- If you have not created any Security Group before, you will be given a Default group as shown in the following screenshot. This default security group restricts any kind of access to this instance from outside. But we will not choose it. Instead, we will create a new Security Group specifically for CUBRID Database usage. So, continue reading.
- We will create a new Security Group to open CUBRID database related ports. So choose the Create a new Security Group option.
- For a Group Name enter CUBRID for you to know what this Security Group is related to.
- Group Description: Open CUBRID Database related ports.
- Choose Custom TCP rule.
- Enter 8001-8003 to a Port range.
- Leave Source as 0.0.0.0/0. This tells EC2 that the above specified port will listen to connections from any IP. If you want to limit only specific IP to have an access to this instance, enter the IP here.
- Once done, press the Add Rule button.
- Now repeat the last 3 steps to enter separate rules for 30000, 33000, 8282, 1523 ports as shown in the screenshot below.
- Finally open the SSH port 22. This time choose SSH from the Create a new rule dropdown box and press on the Add Rule button.
- We are done! Press the Continue button.
- Now, Review the Summary. If necessary, you can go back and customize any option as you wish. Once ready, press the Launch button to take off.
Quite a long way but you have made it! So, congratulations with your new CUBRID Instance! In fact, you can apply the same process with any other AMI distributed by other vendors.
Now let's connect to our CUBRID Amazon Server via SSH and have a sightseeing tour! For this we need two items:
- A Private Key.
- A Public DNS
The first thing to remember is that we have opened SSH port 22 in our "CUBRID" Security Group (step 5.10 above). This means we can connect to the newly created instance right away with our private key. In fact, only those users who posess this private key that matches the public key assosiated with the newly launched instance can access this instance. Just to remind you, once you have set a Key Pair during the instance initialization step, you will not be able to change it.
In order to connect to our remote Amazon EC2 instance, we need to know either the IP address or the Public DNS attached to that instance. You can find the Public DNS of your instance if you go to https://console.aws.amazon.com/ec2->Instances->My new instance with CUBRID 8.4.3.
Once you select your instance a detailed description will be displayed below it. You can find your Public DNS there as shown below.
Establish SSH connection
So, we now have both the private key and the Public DNS. Let's establish an SSH connection.
$ ssh -i MY_PRIVATE_KEY_FILE.pem ubuntu@MY_PUBLIC_DNS
The authenticity of host 'MY_PUBLIC_DNS (MY_PUBLIC_IP)' can't be established.
RSA key fingerprint is dc:17:a9:ca:b8:c4:e5:59:f3:e4:8a:1a:03:cb:94:9e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'MY_PUBLIC_DNS,MY_PUBLIC_IP' (RSA) to the list of known hosts.
Welcome to Ubuntu 12.04.1 LTS (GNU/Linux 3.2.0-31-virtual x86_64)
* Documentation: https://help.ubuntu.com/
System information as of Tue Jan 29 08:33:09 UTC 2013
System load: 0.08 Processes: 64
Usage of /: 14.9% of 7.87GB Users logged in: 0
Memory usage: 8% IP address for eth0: 10.248.26.17
Swap usage: 0%
Graph this data and manage this system at https://landscape.canonical.com/
80 packages can be updated.
35 updates are security updates.
Get cloud support with Ubuntu Advantage Cloud Guest
Thus, we are in!
Check CUBRID Server Status
The first thing you can do is check the status of CUBRID Database Server.
ubuntu@ip-MY_INTERNAL_IP:~$ cubrid service status
@ cubrid master status
++ cubrid master is not running.
@ cubrid server status
++ cubrid master is not running.
@ cubrid broker status
++ cubrid broker is not running.
@ cubrid manager server status
++ cubrid manager server is not running.
Since we have not yet started the CUBRID Service, everything is stopped.
Start CUBRID Server Status
Start the CUBRID Service status:
ubuntu@ip-MY_INTERNAL_IP:~$ cubrid service start
@ cubrid master start
++ cubrid master start: success
@ cubrid broker start
++ cubrid broker start: success
@ cubrid manager server start
++ cubrid manager server start: success
CUBRID Master, Broker and Manager Server services will start up.
Now, if you had created a database before and have set to auto start it, the CUBRID Server service would also start which would start the specified database.
Notice, that in case you restart your EC2 instance, you will need to start CUBRID Service manually each time as it is not set to start on system startup.
In this tutorial you have learnt how to find and launch Amazon EC2 instances based on CUBRID Amazon Machine Images. We provide CUBRID AMIs on all regions. Now go straight to CUBRID Tutorials and proceed to creating your first CUBRID database. For Driver related tutorials visit the CUBRID APIs wiki page.
If you ever need any help or have a question, feel free to comment below, ask a question at CUBRID Q&A site or forum, Facebook or Twitter, or at #cubrid Freenode Web Chat.