Elastic Distributed Database

2017-01-13 10:48:20来源:网络收集作者:三线码农人点击

This project aims to develop an elastic distributed database using MySQL replication to guarantee high availability and dynamic scalability and use it to serve as the backend for a multi-tier web application running TPC-W benchmark.

Configuration on single ec2
Config on AWS and install necessary tools on ec2(master node). password for mysql is : TigerBit!2016(default)
sudo apt-get update
sudo apt-get install -y openjdk-7-jdk ant gcc links git make
sudo apt-get install mysql-server
sudo apt-get install tomcat7

on slave nodes and candidate node, only mysql and java needs to be installed.

Clone repository
git clone https://github.com/jopereira/java-tpcw.git
git clone https://github.com/peterbittiger/elasticDB.git
Initialize Database
mysql -uroot -p < /home/ubuntu/elasticDB/tpcw/mysql.sql
cd java-tpcw
patch -p1 < /home/ubuntu/elasticDB/tpcw/tpcw.patch//apply patch
ant dist
sudo rm -rf /var/lib/tomcat7/webapps/tpcw*//not necessary for the first time
sudo cp /home/ubuntu/java-tpcw/dist/tpcw.war /var/lib/tomcat7/webapps
ant gendb //populate database
sudo ant genimg //presentation tier
Log in the web page
Configuration on multiple ec2

Use our own laptop as client emulator, which is respond for sending different request.

Set root password to: 0307
sudo su
Change config to allow access from outside
vi /etc/ssh/sshd_config

change PermitRootLoginPermitRootLogin to yes and PasswordAuthenticationPasswordAuthentication to yes and then restart ssh service.

service ssh restart
Copy key-pairs between machines
sudo su
cd ~
ssh-keygen -t rsa
ssh-copy-id root@

my computer copy to 4 ec2 instances, master copy to 4 ec2 instances(including itself), slaves should copy to the other 3 ec2 instances. Copying key of aa to cc means that cc grants access to aa

Clone repo
git clone https://github.com/peterbittiger/elasticDB.git

change the ip address in set_env.sh and run testConnection.sh to test communications

MySQL Replication Test

Run prepareMasterSlaves.sh and then log in to master node and run mysql

mysql -uroot -p
#pwd: TigerBit!2016

inside mysql enter the following commands:

mysql> use canvasjs_db;
mysql> select * from datapoints;

download related dependency for this project:

mvn dependency:resolve
mvn eclipse:eclipse

and then change ipaddress in tpcw.properties in our project:

writeQueue =
readQueue = ,,
candidateQueur =

Before we run the project, we must re-run the prepareMasterSlaves.sh, which would take approximately 5 minutes. Next, run enableMonitors.sh, and we will see new tabs showing performance.