I have been running CentOS 5.4 for a while now, and my website http://www.blincmagazine.com has gotten to the point where I need to scale for additional traffic. So I decided instead of scaling vertically by adding more ram to my LAMP server, I would rather scale horizontally to ensure I have options later with additional traffic as well.

Add the server

I started with adding a server to my Rackspace Cloud Server starting with a 256mb image just to work on the configuration. This was very simple, and only took a few minutes to build.

There are easy instructions on the Rackspace site http://cloudservers.rackspacecloud.com/index.php/Creating_a_Cloud_Server and they where simple to follow.

The first thing I had to do, was wait for the server to be built, then I was able to login with the password given on the create server screen. I immediately logged in and changed it as I would never have remembered that password.

 Usage: passwd [OPTION...] <accountName>

Update CentOS 5.5

The next thing I did was

 sudo yum -y update 

There where a few installs and upgrades

 Transaction Summary
==========================
Install       6 Package(s)
Upgrade      39 Package(s) 

This was easy, and I always liked YUM.

Install MySql

Once the updates have finished we will be ready to install the MySQL server. Type the following command to install the MySQL server:

 sudo yum -y install mysql-server 

The install should look like this

 Transaction Summary
======================================
Install       4 Package(s)
Upgrade       0 Package(s)

Total download size: 15 M
Downloading Packages:
(1/4): perl-DBD-MySQL-3.0007-2.el5.x86_64.rpm         | 148 kB     00:00
(2/4): perl-DBI-1.52-2.el5.x86_64.rpm                           | 600 kB     00:00
(3/4): mysql-5.0.77-4.el5_5.3.x86_64.rpm                     | 4.8 MB     00:01
(4/4): mysql-server-5.0.77-4.el5_5.3.x86_64.rpm          | 9.8 MB     00:01
-------------------------------------------------
Total                                                                 5.2 MB/s |  15 MB     00:02
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing     : perl-DBI                                                     1/4
Installing     : mysql                                                         2/4
Installing     : perl-DBD-MySQL                                        3/4
Installing     : mysql-server                                              4/4

Installed:
mysql-server.x86_64 0:5.0.77-4.el5_5.3

Dependency Installed:
mysql.x86_64 0:5.0.77-4.el5_5.3        perl-DBD-MySQL.x86_64 0:3.0007-2.el5        perl-DBI.x86_64 0:1.52-2.el5

Complete! 

Once the updates have finished we will be ready to install the MySQL server. Type the following command to install the MySQL server:

 sudo /etc/init.d/mysqld start 

You should see MySql startup like this

 Initializing MySQL database:  Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h xxx password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &amp;

You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
[  OK  ]
Starting MySQL:                                            [  OK  ]</pre>
Now that we have the MySQL server running we need to secure our  installation.  Type the following command below to start the secure  setup script:

[code language="bash"] sudo /usr/bin/mysql_secure_installation 

Current Root Password

You will be asked for your current root password. Because this is a new installation it is set to none. Press enter.

 NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 

Remember, just hit [ENTER] here.

Set Root Password

If the above step worked correctly you should be prompted with a question asking you if you would like to set your root password. Please press Y and press Enter.

You will be asked for your root password twice. If it works you will see Success!.

Removing Anonymous Users

You will be prompted to remove the MySQL anonymous users. For security reasons we want to do this. The text above the question explains this topic in more detail. Press Y and then Enter.

Disallow Root Login

You will be asked if you would like to disallow remote login for the root user and only allow connections from the server itself. To keep our server secure you want to say Y and press Enter.

Delete test Database

MySQL ships with a default database called test. This is not needed and can be deleted. Press Y and then Enter to delete the test database and it’s associated users.

Reload Privilege Tables

This step will reload the user settings (called privilege tables) so all user changes will take effect. Press Y and then Enter to continue.

Finished

Your MySQL installation is now finished. Keep in mind that this will only support local connections and does not allow you to connect remotely.

 Reload privilege tables now? [Y/n] y
... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL! 

Not too hard. The next step will be

Conclusion

All-in-all, creating cloud servers is super easy. The next part will be to move my data to this MySql instance and start re-configuring my applications to use the new server. I also plan to setup DNS to alias server.baselogic.com to make everything easier, and to shield me if I change IP addresses.

Mick Knutson

Java, JavaEE, J2EE, WebLogic, WebSphere, JBoss, Tomcat, Oracle, Spring, Maven, Architecture, Design, Mentoring, Instructor and Agile Consulting. http://www.baselogic.com/blog/resume

View all posts

Java / JavaEE / Spring Boot Channel

BLiNC Supporters

BLiNC Adsense

Archives

Newsletter