Introduction
So you're ready to deploy a WebObjects application onto your WOlastic instance. You use either a PostgreSQL or MySQL database back-end for your application and you need to get it up and running. Simple enough! WOlastic comes with PostgreSQL and MySQL pre-installed.
By default, Amazon EC2 instances do not have persistent data storage. If you "power-off" your WOlastic EC2 instance or it "crashes", all changed data from the default AMI state is lost, including database information. If you need data persistence, which I'm sure most of you guys will want, there is a separate article on setting up your databases on an Amazon EBS volume.
Getting Started
If you haven't already started up a WOlastic instance, follow the directions here. Once you've got your WOlastic instance running, log in as "appserver" via SSH and if you haven't already changed the default password, please do so now using "passwd".
Once you're logged in, here are the steps to getting PostgreSQL and/or MySQL running.
Using PostgreSQL
1. PostgreSQL is pre-installed by default on all WOlastic images, but turned off on boot.
2. Log in as "appserver" via SSH to your WOlastic instance if you haven't already. Also, change the default password if you haven't already also using the "passwd" utility. Once you're logged in, you should see a prompt similar to this:
3. To start PostgreSQL, run the following command:
4. It may prompt for a password. Enter the password for "appserver". After entering the password, you should see the following occur:
5. PostgreSQL is now running.
6. If you want PostgreSQL to come up automatically during an WOlastic instance reboot, run the following command:
7. Double-check that postgresql is now set to run if the instance is rebooted:
It should look similar to the following:
"3:on" is the most important, but 2 through 5 should show "on".
Subsequently, if you want to reverse your changes, you can run "sudo chkconfig postgresql off".
8. To log into PostgreSQL, you can use the "psql" command as the "postgres" user like this:
9. All PostgreSQL data and configuration files are located in /vol/pgsql/data. You cannot access the directory while you are logged in as the "appserver" user. You need to change to the "postgres" user by doing the following as the "appserver" user:
10. If prompted for a password, type in your "appserver" password. You can now "cd /vol/pgsql/data". pg_hba.conf has been changed from the default configuration with "trust" being assumed.
Using MySQL
1. MySQL is pre-installed by default on all WOlastic images, but turned off on boot.
2. Log in as "appserver" via SSH to your WOlastic instance if you haven't already. Also, change the default password if you haven't already also using the "passwd" utility. Once you're logged in, you should see a prompt similar to this:
3. To start MySQL, run the following command:
4. It may prompt for a password. Enter the password for "appserver". After entering the password, you should see the following occur:
5. MySQL is now running.
6. If you want MySQL to come up automatically during an WOlastic instance reboot, run the following command:
7. Double-check that postgresql is now set to run if the instance is rebooted:
It should look similar to the following:
"3:on" is the most important, but 2 through 5 should show "on".
Subsequently, if you want to reverse your changes, you can run "sudo chkconfig mysqld off"
8. To log into MySQL, you can use the "mysql" command as the "root" user like this:
9. All MySQL data files are located in /vol/mysql. All files and directories are owned by the mysql" user and group. If you want to make changes, you need to change to the "mysql" user by doing the following as the "appserver" user:
10. If prompted for a password, type in your "appserver" password. You can now change/manipulate files within the directory.
Questions? Feel free to ask away!
So you're ready to deploy a WebObjects application onto your WOlastic instance. You use either a PostgreSQL or MySQL database back-end for your application and you need to get it up and running. Simple enough! WOlastic comes with PostgreSQL and MySQL pre-installed.
By default, Amazon EC2 instances do not have persistent data storage. If you "power-off" your WOlastic EC2 instance or it "crashes", all changed data from the default AMI state is lost, including database information. If you need data persistence, which I'm sure most of you guys will want, there is a separate article on setting up your databases on an Amazon EBS volume.
Getting Started
If you haven't already started up a WOlastic instance, follow the directions here. Once you've got your WOlastic instance running, log in as "appserver" via SSH and if you haven't already changed the default password, please do so now using "passwd".
Once you're logged in, here are the steps to getting PostgreSQL and/or MySQL running.
Using PostgreSQL
1. PostgreSQL is pre-installed by default on all WOlastic images, but turned off on boot.
2. Log in as "appserver" via SSH to your WOlastic instance if you haven't already. Also, change the default password if you haven't already also using the "passwd" utility. Once you're logged in, you should see a prompt similar to this:
02:38pm appserver@domU-12-31-38-00-90-64:/home/appserver%
3. To start PostgreSQL, run the following command:
sudo service postgresql start
4. It may prompt for a password. Enter the password for "appserver". After entering the password, you should see the following occur:
Starting postgresql service: [ OK ]
5. PostgreSQL is now running.
6. If you want PostgreSQL to come up automatically during an WOlastic instance reboot, run the following command:
sudo chkconfig postgresql on
7. Double-check that postgresql is now set to run if the instance is rebooted:
sudo chkconfig --list postgresql
It should look similar to the following:
postgresql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
"3:on" is the most important, but 2 through 5 should show "on".
Subsequently, if you want to reverse your changes, you can run "sudo chkconfig postgresql off".
8. To log into PostgreSQL, you can use the "psql" command as the "postgres" user like this:
:/home/appserver% psql -U postgres
Welcome to psql 8.3.7, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
postgres=#
9. All PostgreSQL data and configuration files are located in /vol/pgsql/data. You cannot access the directory while you are logged in as the "appserver" user. You need to change to the "postgres" user by doing the following as the "appserver" user:
sudo su - postgres
10. If prompted for a password, type in your "appserver" password. You can now "cd /vol/pgsql/data". pg_hba.conf has been changed from the default configuration with "trust" being assumed.
Using MySQL
1. MySQL is pre-installed by default on all WOlastic images, but turned off on boot.
2. Log in as "appserver" via SSH to your WOlastic instance if you haven't already. Also, change the default password if you haven't already also using the "passwd" utility. Once you're logged in, you should see a prompt similar to this:
02:38pm appserver@domU-12-31-38-00-90-64:/home/appserver%
3. To start MySQL, run the following command:
sudo service mysqld start
4. It may prompt for a password. Enter the password for "appserver". After entering the password, you should see the following occur:
Starting MySQL: [ OK ]
5. MySQL is now running.
6. If you want MySQL to come up automatically during an WOlastic instance reboot, run the following command:
sudo chkconfig mysqld on
7. Double-check that postgresql is now set to run if the instance is rebooted:
sudo chkconfig --list mysqld
It should look similar to the following:
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
"3:on" is the most important, but 2 through 5 should show "on".
Subsequently, if you want to reverse your changes, you can run "sudo chkconfig mysqld off"
8. To log into MySQL, you can use the "mysql" command as the "root" user like this:
:/home/appserver% mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.0.45 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
9. All MySQL data files are located in /vol/mysql. All files and directories are owned by the mysql" user and group. If you want to make changes, you need to change to the "mysql" user by doing the following as the "appserver" user:
sudo su - mysql
10. If prompted for a password, type in your "appserver" password. You can now change/manipulate files within the directory.
Questions? Feel free to ask away!
Leave a comment