unexpected[it]

Professional IT Blog

  • 29th, Jul 2010

MySQL Cluster on Amazon EC2

Tags: , , , , , ,

I created two cluster servers and one management server for MySQL Cluster

AMI: Minimal Fedora Core 8, 32-bit architecture, Apache 2.0, and Amazon EC2 AMI Tools
MySQL Cluster version 7.1
Fedora Version: 8
Security Group: default

1) Download RPM files
From http://www.mysql.com/downloads/cluster/#downloads all rpm files for Red Hat & Oracle Enterprise Linux for (x86, 32-bit).

2) In each instance

yum --enablerepo=remi erase mysql mysql-libs mysql-server mysqlclient15.i386
rpm -iv MySQL-Cluster-gpl-*

3) Config Management Server
Server IP ( ec2-79-11-111-11.eu-west-1.compute.amazonaws.com )

vi /var/lib/mysql-cluster/config.ini
[NDBD DEFAULT]
NoOfReplicas=2
[MYSQLD DEFAULT]
[NDB_MGMD DEFAULT]
[TCP DEFAULT]
# Managment Server
[NDB_MGMD]
HostName=ec2-79-11-111-11.eu-west-1.compute.amazonaws.com		# the IP of THIS SERVER
# Storage Engines
[NDBD]
HostName=ec2-79-22-222-22.eu-west-1.compute.amazonaws.com		# the IP of the FIRST SERVER
DataDir= /var/lib/mysql-cluster
[NDBD]
HostName=ec2-79-33-333-33.eu-west-1.compute.amazonaws.com		# the IP of the SECOND SERVER
DataDir=/var/lib/mysql-cluster
# 2 MySQL Clients
# I personally leave this blank to allow rapid changes of the mysql clients;
# you can enter the hostnames of the above two servers here. I suggest you dont.
[MYSQLD]
[MYSQLD]

ndb_mgmd -f /var/lib/mysql-cluster/config.ini

The Management Server is now ready, you can check the conexions with the other servers doing this

ndb_mgm
ndb_mgm> show
Cluster Configuration
---------------------
[ndbd(NDB)]	2 node(s)
id=2	@79.22.222.22  (mysql-5.1.44 ndb-7.1.4, Nodegroup: 0, Master)
id=3	@79.33.333.33  (mysql-5.1.44 ndb-7.1.4, Nodegroup: 0, Master)

[ndb_mgmd(MGM)]	1 node(s)
id=1	@79.11.111.11  (mysql-5.1.44 ndb-7.1.4)

[mysqld(API)]	2 node(s)
id=4	@79.22.222.22  (mysql-5.1.44 ndb-7.1.4)
id=5	@79.33.333.33  (mysql-5.1.44 ndb-7.1.4)

4) Config Cluster Servers
Cluster Server IPs: (ec2-79-22-222-22.eu-west-1.compute.amazonaws.com and ec2-79-33-333-33.eu-west-1.compute.amazonaws.com )

/etc/my.cnf
[mysqld]
ndbcluster
ndb-connectstring=ec2-79-11-111-11.eu-west-1.compute.amazonaws.com     # the IP of the MANAGMENT SERVER
[mysql_cluster]
ndb-connectstring=ec2-79-11-111-11.eu-west-1.compute.amazonaws.com	# the IP of the MANAGMENT SERVER

/usr/sbin/ndbd --initial

/etc/init.d/mysql start

5) Testing
You can check in FIRST or SECOND server this and it will be duplicated in both servers.

mysql -u root -p
use test;
CREATE TABLE ctest (i INT) ENGINE=NDBCLUSTER;
INSERT INTO ctest () VALUES (1);
SELECT * FROM ctest;

6) Starting and Shutting down the MySQL Cluster
Starting
Management Server: db_mgmd -f /var/lib/mysql-cluster/config.ini
Cluster Servers: ndbd

Shutting down
Management Server: ndb_mgm> shutdown

Notes
Error: ERROR 1005 (HY000): Can’t create table ‘test.ctest’ (errno: 157)
Try to track the error with SHOW WARNINGS; When I have this problem I had disabled SELinux with “setenforce 0″.

Error: There is no populating changes trough the cluster servers.
Make sure they are connected each other, you can check this from management server with ndb_mgm> SHOW
Also double check all servers are in the security group “default” to leave the ports open. (see image)

Pages related: http://dev.mysql.com/tech-resources/articles/mysql-cluster-for-two-servers.html

  • 29th, Jul 2010

Setting up a Magento Server in Amazon Cloud EC2

Tags: , , , , , , , , , ,

How to create an instance for Magento in Amazon Cloud EC2

You can also get this ebs Image in Amazon EC2. Choose “426063643107/Magento 1.4.x on Fedora 8″
when you launch an instance in the tab “Community AMIs”
MySQL Admin
Username: root Password: 123456

Once the image is initialized
a) Install Magento 1.4.1.1 (For demo store follow 5.1)
In your browser go to: http://YOUREC2NAME.compute-1.amazonaws.com/magento/
b) Install Magento 1.4.1.1 DEMO Version
In your browser go to: http://YOUREC2NAME.compute-1.amazonaws.com/magento-demo/

1) Choose the simplest Instance Fedora Core 8 (AMI Id: ami-df1e35ab)
Minimal Fedora Core 8, 32-bit architecture, Apache 2.0, and Amazon EC2 AMI Tools.

2) Installing Remi Repository with Apache, MySQL and PHP

wget http://rpms.famillecollet.com/remi-release-8.rpm
rpm -Uvh remi-release-8.rpm
vi /etc/apt/sources.list.d/remi.list # Uncomment: repomd http://rpms.famillecollet.com/ fc$(VERSION).$(ARCH)

# Installing MySQL
#
yum --enablerepo=remi install mysql mysql-server mysql-devel

# Installing Http Server with PHP
#
yum --enablerepo=remi install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml

# Config MySQL
#
/usr/bin/mysqladmin -u root password '123456'

# Config Apache
#
# /etc/httpd/conf/httpd.con on Line 326 change
AllowOverride None
# to
AllowOverride All
# inside <Directory "/var/www/html"> ... </Directory>

# /etc/php.ini Activate this line to read <? tags
short_open_tag = On

#Try it out with the usual script in /var/www/html/test.php
&lt;?php
phpinfo();
?>

3) Installing Exim Mail Server

yum install exim
/etc/init.d/exim start
mail -s "testing" your@emailaddress.com
Testing purpose!
.
Cc:
# Your Mail Server should be running properly

4) SFtp Server Access

# Just using a SFtp Client Server Vicomsoft Ftp Client
#  configure a new connection without password and use
#  the option "Use SSH keyfile (SFTP only)" to add your
#  .pem file
#  Or just use
sshfs -i MYSECRETKEY.pem root@YOUREC2NAME.compute-1.amazonaws.com:/ /

5) Using ntsysv command choose the next services to start automatically
sendmail
httpd
mysqld

6) Optionally you can give NFS support to share files between images

#Server1
[root@server1]# vi /etc/exports
/var/www/html *(rw)

[root@server1]# /etc/init.d/rpcbind start

[root@server1]# /etc/init.d/nfs start
#Server2
[root@server2]# mount -o nolock ec2-79-xxx-xx-xxx.eu-west-1.compute.amazonaws.com:/var/www/html /mnt

7) Download and uncompress Magento versions in /var/www/html

CHANGELOG
File /etc/php.ini change short_open_tag = On

© 2010 unexpected[it]. All Rights Reserved.

This blog is powered by Wordpress and a modified version of Magatheme