Installing MySQL

I am exploring another database storage solution “MySQL” to understand practical applications of using MySQL in our environment.

This is one of the many articles that I will be writing on MySQL. This article gives you brief steps to installing MySQL on Linux.

Nothing different than what is provided in MySQL documentation except that this is less elaborate with only required steps compared to MySQL documentation.

This is how you can do the installation:-

Step 1) Down the software from http://dev.mysql.com/downloads/

If you are downloading only for checking out usability and features and for personal learning – go for community version. Click on “MySQL Community Server” link.

Select the OS as “Linux – Generic”

Scroll to the bottom and you will see last 2 lines provides the option to download binaries in the form of tar.gz files – “Linux – Generic (glibc 2.5) (x86, 64-bit), Compressed TAR Archive” andLinux – Generic (glibc 2.5) (x86, 32-bit), Compressed TAR Archive”

Depending on the hardware server you have download either 32 bit or 64 bit version

Step 2) Extract the files on server (login as root) 

Once you download the software (may be on your laptop), SCP the same to the linux server on which you want to install MySQL.

From here on you should be logged in as “root” user on your linux server

Extract the software on linux server at /usr/local location

In my case software was lying on my linux server at /home/advait/mysql location. I extracted using following commands

cd /usr/local 
tar xvfz /home/advait/mysql/mysql-5.6.16-linux-glibc2.5-x86_64.tar.gz

Create a new symlink “mysql” to point to extracted directory (it looks neat without version number and other details).

ln -s mysql-5.6.16-linux-glibc2.5-x86_64 mysql

Step 3) Run following steps to change ownerships

Since you want a superuser to have control of mysql and you dont want to login every time as “root” user on your server, you should be changing the ownership to the user which should be the administrator of mysql.

Usual convention suggests creating “mysql” user on your linux host and giving ownership to “mysql” user.

But on my desktop, I have a user called “advait” and I will be giving ownership to this user.

chown -R advait mysql
cd mysql
chown -R advait .
chgrp -R <grp name> .

Above <grp name> should be the group your user ID belongs to. In my case its again “advait”. To avoid confusion I have used <grp name> instead.

Step 4) Create MySQL database

you should be in /usr/local/mysql directory. Following script will create MySQL database named “mysql” and all required metadata tables inside that.

it will also create a test database for testing purpose.

scripts/mysql_install_db --user=advait

Step 5) Change permissions and create Log directory

you should be in /usr/local/mysql directory

chown -R advait data
chgrp -R <grp name> data
mkdir log
chown -R advait log
chgrp -R <grp name> log

data directory will hold data about tables and log directory will hold log files.

Step 6) Copy config file and modify

Copy my.cnf from /usr/local/mysql to /etc/

you should be in /usr/local/mysql directory

cp my.cnf /etc/my.cnf

modify following parameters in /etc/my.cnf and put them under [mysql.server] heading

[mysql.server]
log_bin = /usr/local/mysql/log
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
socket = /tmp/mysql.sock
user = advait
join_buffer_size = 256M
sort_buffer_size = 16M
read_rnd_buffer_size = 16M

These parameters will be used by mysql instance to during startup.

Step 7) Start MySQL instance

You should start mysql server using your user ID to which you have given the ownership. In my case “advait”.

Login as “advait” and run following commands to start MySQL instance

cd /usr/local/mysql

Use one of the following command to start MySQL instance.

bin/mysqld_safe &
support-files/mysql.server start

You can actually copy support-files/mysql.server in /etc/init.d and make MySQL instance start automatically when server starts

Step 8) Make MySQL instance start automatically with server reboot

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig --add mysql

Reference:

http://dev.mysql.com/doc/refman/5.0/en/installing.html

Hope this helps !!

Advertisements

A look into Amazon DynamoDB

Why noSQL ?

From past few years (after 2009) we are seeing high trend towards noSQL databases. Many big enterprises are exploring option for moving services to noSQL databases and many already did.

Its not that existing Oracle databases cannot support the system. We have many rich features and products from Oracle which can be made to work together to support huge internet applications. But there are many vantage points to consider when we are designing a data store for a system. Among those include availability, cost, performance, scalability etc.

Every system is made of many small  services and when system grows bigger, design is made decentralized and service oriented. Data stores are sharded to store information related to service rather than entire system. With this change in architecture even small data store solutions to support individual service is good enough. System will look like having many small services with there own data stores and services can talk to each other via independent API. This way we achieve a goal of isolated services and at the same time make sure data is exchanged to represent business flow.

With such architecture in mind, every services can design and choose the database solution depending on the type of data it supports. Representing every type of data into relational form and storing them in relational database is not a efficient option. That is why enterprises are analyzing data and choosing data store wisely to support there data. More over with smaller data store requirement to support only the required service (rather than entire system), one can always look for cheaper data storage solution especially for tire 2 or tire 3 services.

Few more reasons for considering noSQL data storage solution would be:

  • Data Velocity – Huge data getting generated in less time
  • Data Variety – Structured, semi-structures and unstructured
  • Data Volume – Terabytes and petabytes of data
  • Dynamic Schema – Flexible data model
  • Auto-sharding – Horizontal scalability
  • Continuous Availability
  • Integrated Caching
  • Replication – Automatic replication to support high availability
  • Dynamic provisioned throughput
Above reasons to some extend becomes the limitations for relational databases.

Amazon DynamoDB

Recently I explored a noSQL data store – Amazon DynamoDB.

This is one of the simplest form of data storage solution where data is stored in the form of key-value pair

I have presented the dynamoDB architecture, features and limitation.

You can view the presentation on slideshare – www.slideshare.net/advaitdeo/dynamodb-presentation-31000206

Hope this helps !!