Converting Amazon EC2 On Demand Instance to Reserved Instance

Converting Amazon EC2 On Demand Instance to Reserved Instance

If you’ve created an Amazon EC2 On Demand instance and you later realize you’ll be running the server indefinitely, you can convert the instance to a Reserved Instance to save some money.

However, there really isn’t anything to “convert”; your existing On Demand instance stays running and you simply purchase a Reserved Instance inside the same Zone (this part is important, see below). It’s entirely a billing thing and Amazon handles this seamlessly.

[…] the conversion of an on-demand instance to a reserved instance is purely a billing issue. Simply buy a reserved instance, and the instances will be billed as reserved instance. No changes need to be made to your AutoScaling group.

Please note that reserved instances currently need to be purchased for a specific AZ. In order to get the benefit of reserved instance pricing, your AutoScaling group should be configured to launch instances in those AZs.

For example, if you only buy a reserved instance in us-east-1a, you should setup your AutoScaling group to launch instances in us-east-1a. If your AutoScaling group is configured to launch instances in us-east-1a and us-east-1b, and AutoScaling launches an instance in us-east-1b, it will be billed as an on-demand instance unless you also buy a reserved instance in us-east-1b. (source)

change localtime on Centos

Firstly you’ll need to know your timezone and/or country, a list can be found in /usr/share/zoneinfo/

The more generic procedure to change the timezone is to create a symlink to file /etc/localtime

# ln -sf /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime

OR you can copy and replace the current localtime setting

# cp /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime

To verify that your timezone is changed use the date command:

# date

 

CentOS Change Timezone

add bash script syntax on Eclipse

Using the update site

Use the regular install method with the following update site link http://sourceforge.net/projects/shelled/files/shelled/update/

Using zipped update site

  1. Download net.sourceforge.shelled-site-2.0.3.zip
  2. Select Help > Install New Software…
  3. Now select the “Add” again, use the “Archive…” button to select the downloaded zip-file as source.
  4. Install ShellEd

Important note: ShellEd is compiled with Java 7, it might work with Java 6 but it’s not tested, so ensure you’re using Java 7 with Eclipse. If you use Java 6 you are on your own though I’ll happily apply any patch to fix compatibility. Thank you to zero_sum, who wrote: “After changing the -vm arg in eclipse.ini and restarting I can see my shell scripts in all their glory.”

To check ShellEd is installed:

  1. Select Help > Install New Software…
  2. Click What is already installed?
  3. Look for Shelled in the list under the Installed Software tab.
  4. Try opening a shell script with a .sh file extension. It should be syntax highlighted.
  5. Try creating a Shell Script Project (File > New > etc.). Create a blah.sh shell script. Put a common Unix command in there like “cat”. Double-click cat. A man page for cat should pop-up after a short delay.

 

http://sourceforge.net/apps/trac/shelled/wiki/Documentation/InstallGuide

Create a user account and grant permission for database on Postgresql

A. You need to use following commands.
=> adduser – UNIX/Linux adduser command to add a user to /etc/passwd file

=> psql => It is a terminal-based front-end to PostgreSQL.

=> CREATE USER – Adds a new user to a PostgreSQL database cluster.

=> CREATE DATABASE – create a new database

=> GRANT ALL PRIVILEGES – define access privileges

Procedure to add a user to PostgreSQL database

To create a normal user and an associated database you need to type the following commands. The easiest way to use is to create a Linux / UNUX IDENT authentication i.e. add user tom to UNIX or Linux system first.

Step # 1: Add a Linux/UNIX user called tom

Type the following commands to create a UNIX/Linux user called tom:
# adduser tom
# passwd tom

Step # 2: Becoming a superuser

You need to login as database super user under postgresql server. Again the simplest way to connect as the postgres user is to change to the postgres unix user on the database server using su command as follows:
# su - postgres

Step #3: Now connect to database server

Type the following command
$ psql template1
OR
$ psql -d template1 -U postgres
Output:

Welcome to psql 7.4.16, the PostgreSQL interactive terminal.
Type:  copyright for distribution terms
       h for help with SQL commands
       ? for help on internal slash commands
       g or terminate with semicolon to execute query
       q to quit
template1=#

Step #4: Add a user called tom

Type the following command to create a user called tom with a password called myPassword (you need to type command highlighted with red color):
template1=# CREATE USER tom WITH PASSWORD 'myPassword';

Step #5: Add a database called jerry

Type the following command (you need to type command highlighted with red color):
template1=# CREATE DATABASE jerry;
Now grant all privileges on database
template1=# GRANT ALL PRIVILEGES ON DATABASE jerry to tom;
Type q to quit:
template1=# q

Step #6: Test tom user login

In order to login as tom you need to type following commands. Login as tom or use su command:
$ su - tom
$ psql -d jerry -U tom

Output:

Welcome to psql 7.4.16, the PostgreSQL interactive terminal.
Type:  copyright for distribution terms
       h for help with SQL commands
       ? for help on internal slash commands
       g or terminate with semicolon to execute query
       q to quit
jerry=>

source:http://www.cyberciti.biz/faq/howto-add-postgresql-user-account/

Enable md5 auth on Postgresql

By default, connection via TCP/IP is disabled. PostgreSQL supports multiple client authentication methods. By default, IDENT authentication method is used for postgres and local users. Please refer the PostgreSQL Administrator’s Guide.

The following discussion assumes that you wish to enable TCP/IP connections and use the MD5 method for client authentication. PostgreSQL configuration files are stored in the /etc/postgresql/<version>/main directory. For example, if you install PostgreSQL 8.4, the configuration files are stored in the /etc/postgresql/8.4/main directory.

To configure ident authentication, add entries to the /etc/postgresql/8.4/main/pg_ident.conf file.

To enable TCP/IP connections, edit the file /etc/postgresql/8.4/main/postgresql.conf

Locate the line #listen_addresses = ‘localhost’ and change it to:

listen_addresses = 'localhost'
To allow other computers to connect to your PostgreSQL server replace ‘localhost’ with the IP Address of your server.

You may also edit all other parameters, if you know what you are doing! For details, refer to the configuration file or to the PostgreSQL documentation.

Now that we can connect to our PostgreSQL server, the next step is to set a password for the postgres user. Run the following command at a terminal prompt to connect to the default PostgreSQL template database:

sudo -u postgres psql template1

The above command connects to PostgreSQL database template1 as user postgres. Once you connect to the PostgreSQL server, you will be at a SQL prompt. You can run the following SQL command at the psql prompt to configure the password for the user postgres.

ALTER USER postgres with encrypted password 'your_password';

After configuring the password, edit the file /etc/postgresql/8.4/main/pg_hba.conf to use MD5 authentication with the postgres user:

local   all         postgres                          md5

Finally, you should restart the PostgreSQL service to initialize the new configuration. From a terminal prompt enter the following to restart PostgreSQL:

sudo /etc/init.d/postgresql-8.4 restart

 

source:https://help.ubuntu.com/10.04/serverguide/postgresql.html

Disable SELinux CentOS 6

# vi /etc/selinux/config

 

Change SELINUX=enforcing

1
2
3
4
5
6
7
8
9
10
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

to SELINUX=disabled

1
2
3
4
5
6
7
8
9
10
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted

This will disable SELinux on your next reboot.