getting started with fit2cloud

47
Getting Started with Fit2Cloud 1. What is Fit2Cloud? 1.1 Introduction 1.2 How It Works? 1.3 Concepts 1.3.1 What is Environment? 1.3.2 What is Cluster? 1.3.3 What is Cluster Type? 1.3.4 What is VM Role? 1.3.5 What is Cluster Role? 1.3.6 What is Internal EventHandler? 1.3.7 What is External EventHandler? 2. Walkthrough: Learn Fit2Cloud by Creating a Wordpress Cluster and Manage it Automatically 3. Log in Fi2Cloud Webconsole Step 1: Open Fit2Cloud Homepage Step 2: Click “SignIn in with Github” Step 3: Login with Github account Step 4: Grant Fit2Cloud Access to Github account 4. Create Wordpress Cluster Step 1: Add IaaS Cloud Provider Account 1) Fetch AWS Account Number, Access Key, Secret Key 4.1.2 For new AWS Account created before Dec,2013 2) Enable IAM access in AWS 3) Add AWS Account Credential Go to Setttings > Credentials Add > Fill In AWS Credential Info > Save Step 2: Create Enviornment 1) Go to Settings > Environments 2) Click “Add” Button 3) Fill in Environment info and Save Step 3: Create Cluster Type 1) Settings > Cluster Type 2) Click Add Button Step 4: Create Cluster 1) Go to Clusters > Create 2) Fill in Cluster Info and Save 5. Create MySQL Cluster Role in Cluster Step 1 : Create MySQL VM Role 1) Go to “VM Roles” 2) Add MySQL VM Role Step 2: Configure MySQL VM Role Install’s EventHandler 1) Go to VM Roles > wordPressmysql > Action > EventHandlers 2) Select Internal EventHandlers > Install and Fill In MySQL Install Script 3) Click Save Step 3: Create MySQL Cluster Role for WordPress Cluster 1

Upload: fit2cloud

Post on 31-Aug-2014

198 views

Category:

Technology


0 download

DESCRIPTION

Fit2Cloud User Guide: Cloud DevOps Platform for AWS.

TRANSCRIPT

Page 1: Getting Started with Fit2Cloud

Getting Started with Fit2Cloud

1. What is Fit2Cloud?1.1 Introduction1.2 How It Works?1.3 Concepts

1.3.1 What is Environment?1.3.2 What is Cluster?1.3.3 What is Cluster Type?1.3.4 What is VM Role?1.3.5 What is Cluster Role?1.3.6 What is Internal EventHandler?1.3.7 What is External EventHandler?

2. Walkthrough: Learn Fit2Cloud by Creating a Wordpress Cluster and Manage it Automatically3. Log in Fi2Cloud Webconsole

Step 1: Open Fit2Cloud HomepageStep 2: Click “SignIn in with Github”Step 3: Login with Github accountStep 4: Grant Fit2Cloud Access to Github account

4. Create Wordpress ClusterStep 1: Add IaaS Cloud Provider Account

1) Fetch AWS Account Number, Access Key, Secret Key4.1.2 For new AWS Account created before Dec,20132) Enable IAM access in AWS3) Add AWS Account Credential

Go to Setttings ­> CredentialsAdd ­> Fill In AWS Credential Info ­> Save

Step 2: Create Enviornment1) Go to Settings ­> Environments2) Click “Add” Button3) Fill in Environment info and Save

Step 3: Create Cluster Type1) Settings ­ > Cluster Type2) Click Add Button

Step 4: Create Cluster1) Go to Clusters ­> Create2) Fill in Cluster Info and Save

5. Create MySQL Cluster Role in ClusterStep 1 : Create MySQL VM Role

1) Go to “VM Roles”2) Add MySQL VM Role

Step 2: Configure MySQL VM Role Install’s EventHandler1) Go to VM Roles ­> wordPress­mysql ­> Action ­> EventHandlers2) Select Internal EventHandlers ­> Install and Fill In MySQL Install Script3) Click Save

Step 3: Create MySQL Cluster Role for WordPress Cluster

1

Page 2: Getting Started with Fit2Cloud

1) Go to Clusters ­> WordPressDevToyko1 ­> 0 Roles2) Click “Add” and Select Cluster Role Info and Save

6. Launch WordPress Cluster7. Validate Wordpress Cluster

7.1 Validate MySQL is running in wordpress­mysql Cluster Role’s VM8. Create Wordpress­web Cluster Role in Cluster

Step 1 : Create Wordpress­web VM RoleStep 2 : Configure Wordpress­web VM Role Install Action

1) Go to VM Roles ­> WordPress­web ­> Action ­> EventHandlers2) Select Internal EventHandlers ­> Install and Fill In Install Script

Step 3 : Create Wordpress­web Cluster Role for WordPress Cluster1) Go to “Clusters” ­> Select WordpressDevToyko1 ­> Launch

9. Register DNS10. Open 80 Port of Wordpress­web VM

1) Go to “VM Roles” ­> Select wordpress­web ­> “Actions” ­> Security Rules2) Click “Add” ­> Fill in port info ­> Save

11. Verify Wordpress Service12. checkHealth Wordpress Web in Cluster

1) Go to “VM Roles” ­> wordpress­web ­> Actions ­> Event Handlers2) Go to “Internal EventHandlers” ­> checkHealth ­> Fill in Script below and Save

*3) Go to “Tools‘ ­> Fire Event4) Select FireEvent’s Event Name “checkHealth”, Target Cluster, Cluster Role and VM and Click“FireEvent”

13. upgrade Wordpress Service in Cluster1) Go to “VM Roles” ­> wordpress­web ­> Actions ­> Event Handlers2) Go to “Internal EventHandlers” ­> upgrade ­> Fill in Script below and Save

*3) Go to “Tools‘ ­> Fire Event4) Select FireEvent’s Event Name “upgrade”, Target Cluster, Cluster Role and VM and Click“FireEvent”5) View output of the upgrade event handler

14. backup Wordpress Service data in Cluster1) Go to “VM Roles” ­> wordpress­web ­> Actions ­> Event Handlers2) Go to “Internal EventHandlers” ­> backup ­> Fill in Script below and Save

*3) Go to “Tools‘ ­> Fire Event4) Select FireEvent’s Event Name, Target Cluster, Cluster Role and VM and Click “FireEvent”5) View Output of the Backup Event Handler

2

Page 3: Getting Started with Fit2Cloud

1. What is Fit2Cloud?

1.1 Introduction

Fit2Cloud is an Event­Driven Programmable Cloud DevOps Platform for AWS. This platform aims tohelp organizations to continuous deliver complex Cloud­Native App ontop of AWS Infra. It enablesdevelopers & Ops to achieve full­stack automation by writing event handlers.

It is very convenient, helpful, friendly for Developer, QA, Operator to install Apps and Services to virtualmachines in cloud and then run it and manage it, automates the monitoring, fail over, repair and scale,especially for the app that is large scale, distributed and complicated composed of lots of components anddeployed in lots of VMs.

1.2 How It Works?

Fit2Cloud manges system by cluster, group VMs to a cluster, when VM is launched by AWS:

1) EventAgent will be installed in each VM in the cluster.

EventAgent is a backend service that installed and running in each VM managed by Fit2Cloud upon theVM is launched by Cloud Provider such as AWS, then Fit2Cloud manages the runtimes and componentsof all the VMs by EventAgent.

2) For each VM, the VM’s BehaviorEvent initialize, install, start and StatusEvent such as beforeInitialize,afterInitialize, beforeInstall, afterInstall will be fired to EventAgent@Each VM in the cluster in sequence by aStateMachine after the VM is up in AWS.

The sequence is below:

beforeInitialize ­> initialize ­> afterInitialize­> preInstall ­> install ­> afterInstall­> preStart ­> start ­> postStart

3) When EventAgent@VM receive the Self’s BehaviorEvent, it will execute BehaviorEvent’s handler toinitialize, install and start component in the VM.

4) If there are a VM#1 listening on a EventVM#2 ’s StatusEvent, such as beforeInitialize, afterInitialize,beforeInstall, afterInstall, then StateEngine will fires the EventVM#2’s event to EventAgent@VM#1, thenEventAgent@VM#1 execute the corresponding listening event handler.

For example:

3

Page 4: Getting Started with Fit2Cloud

There is a wordpress cluster, there are two VMs, One is MySQL Role VM, the other is Wordpress­webRole VM.

We write 2 Event Handlers:1. MySQL’s BehaviorEvent install’s EventHandler

2. MySQL’s StatusEvent postInstall’s Wordpress­web EventHandlerWhen MySQL’s StatusEvent postInstall fires, the listening Wordpress­web EventHandler will be executedon Wordpress­web VMs.

Work Flow:1) MySQL Role VM launched

2) MySQL VM BehaviorEvents will happen in sequence ready ­> initialize ­> install ­> start

3) When MySQL VM install BehaviorEvent happens, eventAgent@MySQL VM will execute theinitialize BehaviorEvent’s eventhandler, the eventhandler will install and start mysql on the VM.

4) After 3), MySQL VM’s StatusEvent postInstall will happen, as MySQL’s StatusEvent postInstall’sWordpress­web Handler listening on the MySQL VM’s StatusEvent postInstall, the Wordpress­webHandler will be executed by EvnetAgent@Wordpress­web, the Wordpress­web Handler will get themysql’s IP and configure it to Wordpress­web’s db config file and restart.

5) Then Wordpress service is up in the Cluster.

Take Install Wordpress to a group of vms for example:

1. Create WordpressDev Cluster2. Add Wordpress­mysql Cluster Role and Wordpress­web Cluster Role3. Write Wordpress­mysql VM Role’s Events’ EventHandlers4. Write Wordpress­web VM Role’s Events’ EventHandlers5. Launch WordpressDev Cluster6. Verify Installation by Accessing the Wordpress Web

After Wordpress­mysql VM#1 up, EventAgent on the VM#1 will execute the Install Event’s EventHandler toinstall mysql on the VM.

4

Page 5: Getting Started with Fit2Cloud

1.3 Concepts

1.3.1 What is Environment?

Environment is a group of Clusters, All clusters in a Environment, share the same IaaS credential, use thesame IaaS account’s creating resources in IaaS Cloud Provider, such as AWS.

you can name the environment by your cluster types, such as you can name such as the Project, by TeamGroup, by usage or by region etc, for example:

Create environment CrazyBird_Demo_Env for demo project CrazyBird.Create environment Wordpress_Demo_Env for demo project Wordpress.Create environment CrazyBird_DevTeam_Env for dev team use.Create environment CrazyBird_CommonServiceTeam_Env for common service team use.Create environment CrazyBird_QA_Env for QA team use.Create environment CrazyBird_Steven_Env for team member Steven’s self dev use.Create environment CrazyBird_AWS_US_Env for group the clusters in USCreate environment CrazyBird_AWS_BJ_Env for group the clusters in BJCreate environment CrazyBird_AWS_Env for group the clusters in AWSCreate environment CrazyBird_CLOUDSTACK_Env for group the clusters in AWS

1.3.2 What is Cluster?

Cluster :

5

Page 6: Getting Started with Fit2Cloud

is a group of VMs, it belongs to an Environement, the VMs are all belongs to cloud account registed inEnvironment, all the VMs’ Bill are paid by the cloud account registed in Environment.

Example 1:

We want to run a wordpress for publishing self blogs, we can create a WordpressSelfBlog Cluster first,we put 3 VMs in, 1 nginx VM, 1 Web VM, 1 MySQL VM, then deploy Nginx, Web, MySQL to each VM.

Example 2:We are developing an app CrazyBird, we require 4 Envs for development, QA, Staging, production use.Then we can create a Dev CrazyBird Cluster for development use, create a QA CrazyBird Cluster for QAuse, create a Staging CrazyBird Cluster for staing use, create a production CrazyBird Cluster forproduction use.

In different cluster, it has differnt scale vms, such as1) for Dev Cluster, has 3 VMs2) for QA Cluster has 5 VMs3) for Staging Cluster has 10 VMs4) for Production Cluster has 100 VMs.

1.3.3 What is Cluster Type?

Cluster Type :

is a Cluster’s Type, it is composed of VM Roles, a physical divsion of a Cluster, you can think it asCluster Template, as VM Role is VM Template.

For example, for a Wordpress cluster, it will have 3 different type VM, MySQL, Web and Nginx.Then we define a WordpressClusterType, it contains 3 VM Roles1) MySQL VM Role2) Web VM Role3) Nginx VM Role

Each wordpress cluster is an instance of Cluster’s Type.

1.3.4 What is VM Role?

VM Role is a VM’s Type, it defined by its Behaviors when VM’s BehaviorEvent fires to the VM.

such as1) if a VM going to use as MySQL type server, when the VM BehaviorEvent install happens, it will beinstalled with MySQL, then the VM’s Role is MySQL VM Role.2) If a VM going to use as Webconsole server, install with Wordpress build, then the VM’s Role isWordpress­web VM Role.3) If a VM going to be deployed with all Wordpress required MySQL, Wordpress build, then the VM’s Role isWordpress­AllInOne VM Role.

6

Page 7: Getting Started with Fit2Cloud

This VM Role is defined by this Role’s VM’s behaviors after launched, we define Role’s VM’s behaviors bywriting event handler of the VM Role’s BehaviorEvent, such as for a VM, after launched and up,StateMachine will fire initialize, install, start BehaviorEvent in sequence, we can define when install event,install a component, for exmaple:

When Wordpress­web VM receive initialize BehaviorEvent, we execute the initialize’s EventHandler, theEventHandler will install the runtimes required, such as php, php­mysql, wget, then VM receive installBehaviorEvent, then install’s EventHandler will download the wordpress build and deploy the build to/var/www/wordpress, then VM receive start BehaviorEvent, the start’s EventHandler will start the web.

We can write the EventHandlers in Fit2Cloud Web to define the VM’s behaviors upon each status.

1.3.5 What is Cluster Role?

After a VM Role added to a Cluster, a Cluster Role is created, in Cluster role, you can control how many therole vms to launch and EBS mount and auto scalr settings.

1.3.6 What is Internal EventHandler?

Internal EventHandler is executed inside EventVM when EventVM receives BehaviorEvent,

In another word, an VM’s Event’s Internal Event Handler is to be executed only in this VM when VM’s eventfires.

VM’s BehaviorEvents includes initialize, install, start, reboot, postReboot, upgrade, backup, checkHealth.

For example, in a wordpress cluster, it includes 2 VMs, 1 wordpress­mysql vm, 1 wordpress­web vm, wedefines an install EventHandler for wordpress­mysql server role’s install event, then whenwordpress­mysql’s install event fires, the install EventHandler will be and only be executed on thewordpress­mysql VM, it will not be executed in wordpress­web VM.

We can implement auto deploy, configure, start a component on a wordpress­mysql VM role’s VM bydefining install event handler of Wordpress­mysql VM role.

1.3.7 What is External EventHandler?

External EventHandler is executed outside EventVM in other external VMs when External VM receivesEventVM’s StatusEvent.

In another word, an VM’s Event’s External Event Handler is to be executed in other VMs outside this VMwhen this VM’s event fires.

2. Walkthrough: Learn Fit2Cloud by Creating a Wordpress Cluster and Manage it Automatically

7

Page 8: Getting Started with Fit2Cloud

In this session, we are going to address you the magic that how Fit2Cloud helps the works, and make thework conveniently.

In this session, we will show you the basic features, concepts by implementing the task that setup aWordpress cluster in AWS step by step.

Our Goal:1. Create a Workpress cluster that has 3 VMsone MySQL VM, one Wordpress Web VM and 1 Nginx VM2. Can use the wordpress to publish blog after setup.3. Can upgrade wordpress4. Can check health wordpress5. Can scale wordpress web

Below are the overview of steps:

1) Login Fit2Cloud 2) Create Cluster 3) Create Wordpress­mysql Cluster Role 4) Launch Cluster 5) Verify Wordpress mysql running 6) Create Wordpress­web Cluster Role 7) Verify Wordpress running

3. Log in Fi2Cloud Webconsole

Step 1: Open Fit2Cloud Homepageopen www.fit2cloud.com in web browser

8

Page 9: Getting Started with Fit2Cloud

Step 2: Click “SignIn in with Github”

Step 3: Login with Github account

Step 4: Grant Fit2Cloud Access to Github accountClick the Allow access Button in below page

9

Page 10: Getting Started with Fit2Cloud

4. Create Wordpress Cluster

Step 1: Add IaaS Cloud Provider AccountTake add AWS account for example

1) Fetch AWS Account Number, Access Key, Secret Key

For old AWS Account created before Dec,2013You can find your AWS credentials by clicking here or selecting ‘Security Credentials’ from the ‘MyAccount/Console’ menu:

10

Page 11: Getting Started with Fit2Cloud

After logging in, you can find your Account Number in the top right of the page, just under your username:

This is optional, but is needed for some advanced features such as sharing an EC2 AMI or EBS snapshotwith other users.

Your Access Key and Secret Access Key can be found on the same page, under access credentials:

This is required in order for us to use AWS’ Rest APIs to launch vm from fit2cloud.

11

Page 12: Getting Started with Fit2Cloud

4.1.2 For new AWS Account created before Dec,20131) Login AWS

2) Go to IAM

3) Create Group with Power User Policy

12

Page 13: Getting Started with Fit2Cloud

4) Create User and Get Access Key ID and Secret Access KeyStep 1 : Request Create New User

13

Page 14: Getting Started with Fit2Cloud

Step 2 : Click “Show User Security Credentials”

14

Page 15: Getting Started with Fit2Cloud

2) Enable IAM access in AWS

Log in to your AWS account and then go here.

Scroll down to the IAM user access section and make sure both the ‘Account Activity Page’ and ‘UsageReports Page’ checkboxes are ticked and then click Activate Now.

3) Add AWS Account Credential

Go to Setttings ­> Credentials

Add ­> Fill In AWS Credential Info ­> Save Click “Add” Button, then fill in the form and save. Add name such as “AWS­OTOM” Select Cloud Provider : choose “aws” Fill in Access Key ID (Get from AWS account info above) Fill Secret Access Key (Get from AWS account info)

15

Page 16: Getting Started with Fit2Cloud

Step 2: Create Enviornment

1) Go to Settings ­> Environments

2) Click “Add” ButtonThe create env form is prompted.

16

Page 17: Getting Started with Fit2Cloud

3) Fill in Environment info and Save Fill in Env name (WordpressDevTeamEnv) Select type from developement, test, staging, production (test) Select Credential just created (AWS­OTOM) Select Cloud Provider (aws) Save

Step 3: Create Cluster Type

1) Settings ­ > Cluster Type

17

Page 18: Getting Started with Fit2Cloud

2) Click Add ButtonFill in Category name “WordPress­Cluster”

3) Fill In Cluster Type Name and Save

Step 4: Create Cluster

1) Go to Clusters ­> Create

2) Fill in Cluster Info and SaveFill in name “WordpressDevToyko1”Select Enviornment, select “WordpressDevTeamEnv”Select ClusterType, select “WordPress­Cluster”

18

Page 19: Getting Started with Fit2Cloud

After Save, you can see the added cluster below:

19

Page 20: Getting Started with Fit2Cloud

5. Create MySQL Cluster Role in Cluster

Step 1 : Create MySQL VM Role

1) Go to “VM Roles”

2) Add MySQL VM Role

Go to VM Roles ­> Add Fill in MySQL VM Role Name “wordPress­mysql” Select “WordPress­Cluster” just created as Cluster Type

means this role is belong to WordPress system Cluster. Select Image Group “ubuntu_12.04_64” Save

20

Page 21: Getting Started with Fit2Cloud

Step 2: Configure MySQL VM Role Install’s EventHandler

1) Go to VM Roles ­> wordPress­mysql ­> Action ­> EventHandlers

2) Select Internal EventHandlers ­> Install and Fill In MySQL Install Script

#!/bin/bashsudo su ­apt­get updateapt­get ­y dist­upgradedebconf­set­selections <<< 'mysql­server­5.5.34 mysql­server/root_password password fit2cloud'debconf­set­selections <<< 'mysql­server­5.5.34 mysql­server/root_password_again password fit2cloud'apt­get install ­y mysql­server mysql­client#download create database sql#execute sqlsed ­i "s/bind­address/#bind­address/g" /etc/mysql/my.cnfmysql ­u root ­pfit2cloud ­e "create database wordpress"mysql ­u root ­pfit2cloud ­e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'fit2cloud'WITH GRANT OPTION;flush privileges;"service mysql restart

21

Page 22: Getting Started with Fit2Cloud

3) Click Save

Step 3: Create MySQL Cluster Role for WordPress Cluster

1) Go to Clusters ­> WordPressDevToyko1 ­> 0 Roles

2) Click “Add” and Select Cluster Role Info and SaveVM Role: select WordPress­mysqlRegion: select ap­northeast­1Zone: select ap­northeast­1aInstance Type: select t1.microImage: select Tokyo_region_ami

22

Page 23: Getting Started with Fit2Cloud

After save:

6. Launch WordPress Cluster

After launch, the VM Status became to PENDING, Fit2Cloud Status became to WAITING

23

Page 24: Getting Started with Fit2Cloud

After the VM launched, the VM Status became to RUNNING, Fit2Cloud Status became topostStartResponse

7. Validate Wordpress Cluster

7.1 Validate MySQL is running in wordpress­mysql Cluster Role’s VMAfter MySQL VM Role vm launched, you can logon to the server by SSH Console Web.

Logon to the VM to verify the mysql is install and started successfully.

24

Page 25: Getting Started with Fit2Cloud

8. Create Wordpress­web Cluster Role in Cluster

Note:

If the Wordpress­web VM role already created, then Step 1 is not needed.

This case happens after you already create 1 cluster, when you create the second cluster, you do notneed to create the Wordpress­web VM role.

Step 1 : Create Wordpress­web VM Role1) Go to “VM Roles”2) Add Wordpress­web VM Role

Fill in Name (wordpress­web) Cluster Type (Wordpress­Cluster) Image Group (Amazon_linux_64_201309) Save

25

Page 26: Getting Started with Fit2Cloud

Step 2 : Configure Wordpress­web VM Role Install Action

1) Go to VM Roles ­> WordPress­web ­> Action ­> EventHandlers

2) Select Internal EventHandlers ­> Install and Fill In Install Script

#!/bin/bashsudo su ­apt­get updateapt­get ­y dist­upgradeapt­get ­y install php5 libapache2­mod­php5 libapache2­mod­auth­mysql php5­mysqlapt­get ­y install apache2apt­get ­y install mysql­client

#!/bin/bashsudo su ­mkdir /var/wwwchown www­data:www­data /var/wwwcd /var/wwwwget http://wordpress.org/latest.tar.gztar ­xzvf latest.tar.gzchown ­R www­data:www­data wordpresschmod ­R 777 wordpress

#configure apache2 file for wordpresscat << EOF > /etc/apache2/sites­available/wordpress

26

Page 27: Getting Started with Fit2Cloud

<VirtualHost *:80> ServerName wordpress.fit2cloud.net DocumentRoot /var/www/wordpress DirectoryIndex index.php <Directory /var/www/wordpress/> AllowOverride All Order Deny,Allow Allow from all </Directory></VirtualHost>EOFa2ensite wordpressservice apache2 restart

cp /var/www/wordpress/wp­config­sample.php /var/www/wordpress/wp­config.phpsed ­i "s/database_name_here/wordpress/g" /var/www/wordpress/wp­config.phpsed ­i "s/username_here/root/g" /var/www/wordpress/wp­config.phpsed ­i "s/password_here/fit2cloud/g" /var/www/wordpress/wp­config.php

#get mysql role server ip address and set it to wp­config.phpwaitOutput=`f2cadmin waitUntilServerUp wordpress­mysql 120`output=`echo $waitOutput | grep "vm is up"`if [ $#output ­gt 0 ] ; then getIPoutput=`f2cadmin get clusterrole_servers_info wordpress­mysql localIP | head ­1`

checkErrorOutput=`echo $getIPoutput | grep "does not exist"` if [ $#checkErrorOutput ­gt 0 ] ; then echo "exceptions happens when get role server ip" echo $output else echo $getIPoutput mysqlInternalIP=$getIPoutput sed ­i "s/localhost/$mysqlInternalIP/g" /var/www/wordpress/wp­config.php fielse echo exceptions happens when wait until mysql server up, can not get mysql ip, can not configurewp­config.php echo $waitOutputfi

27

Page 28: Getting Started with Fit2Cloud

3) Click Save

Step 3 : Create Wordpress­web Cluster Role for WordPress Cluster

Go to Clusters ­> WordPressDevToyko1 -> “1 Roles”

28

Page 29: Getting Started with Fit2Cloud

Save and can see below

8. Launch Wordpress Cluster

1) Go to “Clusters” ­> Select WordpressDevToyko1 ­> Launch

29

Page 30: Getting Started with Fit2Cloud

After request Launch, can see the Status of WordpressDevToyko1 status change to RNNING

Then, after a while, VMs of WordpressDevToyko1 because 2 VMs, then select “2 VMs”

Then, can see 2 VMs, and their info such as IP address, we can see that wordpress­web cluster role VM’sIP is 54.199.68.94

30

Page 31: Getting Started with Fit2Cloud

9. Register DNS

You can register it to your DNS Server orcall DNS API to register in Wordpress­web VM Role’s install event handler

Here, we simply implement this by register it to /etc/hosts

echo “54.199.68.94 wordpress.fit2cloud.net” > /etc/hosts

wordpress.fit2cloud.net is set in Wordpress­web VM Role’s install event handler.

10. Open 80 Port of Wordpress­web VM

1) Go to “VM Roles” ­> Select wordpress­web ­> “Actions” ­> Security Rules

2) Click “Add” ­> Fill in port info ­> Save

As currently we did not register the DNS yet, so we temporarily change local PC’s /etc/hosts to make it.echo “54.199.68.94 wordpress.fit2cloud.net” >> /etc/hosts

11. Verify Wordpress ServiceIn web browser, open http://wordpress.fit2cloud.net

31

Page 32: Getting Started with Fit2Cloud

12. checkHealth Wordpress Web in Cluster

32

Page 33: Getting Started with Fit2Cloud

1) Go to “VM Roles” ­> wordpress­web ­> Actions ­> Event Handlers

2) Go to “Internal EventHandlers” ­> checkHealth ­> Fill in Script below and Save

#!/bin/bash

#check apache serviceecho "Checking apache service"status=`service apache2 status | grep running`if [ $#output ­gt 0 ] ; then echo "apache service is running" echo $statusfi

#check build deploymentecho "checking wordpress build deployment..."echo "wordpress build deployment is ok"

#check db configurationecho "check wordpress web's db configuration..."echo "wordpress web's db configuration is ok"

33

Page 34: Getting Started with Fit2Cloud

3) Go to “Tools‘ ­> Fire Event

34

Page 35: Getting Started with Fit2Cloud

4) Select FireEvent’s Event Name “checkHealth”, Target Cluster, Cluster Role and VM and Click“FireEvent”

35

Page 36: Getting Started with Fit2Cloud

5) View output of the checkHealth event handler

36

Page 37: Getting Started with Fit2Cloud

13. upgrade Wordpress Service in Cluster

37

Page 38: Getting Started with Fit2Cloud

1) Go to “VM Roles” ­> wordpress­web ­> Actions ­> Event Handlers

2) Go to “Internal EventHandlers” ­> upgrade ­> Fill in Script below and Save

#!/bin/bash

#Upgrade#install absolute privacy pluginscd /var/www/html/wordpress/wp­content/pluginsrm ­rf absolute­privacyrm ­rf absolute­privacy.2.1.zip*wget http://downloads.wordpress.org/plugin/absolute­privacy.2.1.zipunzip absolute­privacy.2.1.zip

rm ­rf better­wp­securityrm ­rf better­wp­security.3.6.3.zip*wget http://downloads.wordpress.org/plugin/better­wp­security.3.6.3.zipunzip better­wp­security.3.6.3.zip

38

Page 39: Getting Started with Fit2Cloud

3) Go to “Tools‘ ­> Fire Event

39

Page 40: Getting Started with Fit2Cloud

4) Select FireEvent’s Event Name “upgrade”, Target Cluster, Cluster Role and VM and Click“FireEvent”

40

Page 41: Getting Started with Fit2Cloud

5) View output of the upgrade event handler

41

Page 42: Getting Started with Fit2Cloud

output=Archive: absolute-privacy.2.1.zipabsolute-privacy.2.1 packaged: Wed, 11 Sep 2013 06:09:03 +0000creating: absolute-privacy/inflating: absolute-privacy/screenshot-3.jpginflating: absolute-privacy/screenshot-2.jpg… ...

14. backup Wordpress Service data in Cluster

42

Page 43: Getting Started with Fit2Cloud

1) Go to “VM Roles” ­> wordpress­web ­> Actions ­> Event Handlers

2) Go to “Internal EventHandlers” ­> backup ­> Fill in Script below and Save

#!/bin/bashecho "Backuping Wordpress data"echo "Locking Wordpress DB"echo "Wordpress DB Locked"echo "Dumping Wordpress DB"

getIPoutput=`f2cadmin get clusterrole_servers_info wordpress­mysql localIP | head ­1`checkErrorOutput=`echo $getIPoutput | grep "does not exist"`if [ $#checkErrorOutput ­gt 0 ] ; then echo "exceptions happens when get role server ip" echo $outputelse echo $getIPoutput mysqlInternalIP=$getIPoutput mysqldump ­h$mysqlInternalIP ­uroot ­pfit2cloud wordpress > db.backup.sql.20140124fi

echo "Dump Wordpress DB Done."echo "Uploading db backup file to S3"

echo "Upload db backup file to S3 Done"

echo "Backuping Wordpress data"echo "Locking Wordpress DB"echo "Wordpress DB Locked"echo "Dumping Wordpress DB"mysqldump ­uroot ­pfit2cloud wordpress > db.backup.sql.20140124echo "Dump Wordpress DB Done."echo "Uploading db backup file to S3"

echo "Upload db backup file to S3 Done"

43

Page 44: Getting Started with Fit2Cloud

3) Go to “Tools‘ ­> Fire Event

44

Page 45: Getting Started with Fit2Cloud

4) Select FireEvent’s Event Name, Target Cluster, Cluster Role and VM and Click “FireEvent”

5) View Output of the Backup Event Handler

45

Page 46: Getting Started with Fit2Cloud

46

Page 47: Getting Started with Fit2Cloud

14. Advanced Topics

Fit2Cloud is very powerful and it has lots of useful features to help build industrial service, such as

1) Implement Continuous Deployment by Integrating it with Jenkins, GitHub, IDE etc to manages yourcluster in Cloud2) Make event handlers version controlled3) f2cadmin client usage4) Implement MySQL HA by event handlers5) Create Customized Image6) Fire customized event in EventHandler7) Sync waiting for an event in EventHandler8) Add Customized Behavior Event9) Register DNS automatically in initialize EventHandler10) Auto scale11) Implement DTAP12) Integrate Chef in Event Handler to implement NoOps13) Integrate Puppet in Event Handler to implement NoOps14) Set Cluster Variables just like OS Env variables

For details please refer to series of advanced topics HERE.

47