Wednesday, March 26, 2014

Buy One, Get One Free on all of #Packt’s 2000 eBooks!

I do love such a campaign because we don't have to pay double when we are thinking of buying several books and we don't have to carry books if we buy e-books!

"Packt Publishing is launching a campaign to coincide with the release of our 2000th title. The campaign begins on 18th Mar and will continue up until 26th Mar. Packt is giving its reader a chance to dive into their comprehensive catalog and Buy One, Get One Free across their entire range of eBooks."

I had a mind to read the books below with this opportunity even if they are recently released or not.

Tuesday, March 25, 2014

Monitoring tool for hyblid cloud and automating - installing Hyclops for Zabbix (updated)

I used to write about how to install zabbix+hyclops to automatically register zabbix hosts on AWS EC2 instance before. Recently, I tried installing the latest version of zabbix-2.2.2 and hyclops-0.2.
In fact, it's not working as expected so far because it seems that hyclops.connector.ec2 (ec2.py) python script is not working correctly. I will update this article when finishing to fix the problem (asking the engineers who created hyclops to debug the issue currently).
After uninstalling apache-libcloud from 0.14.1 to 0.13.2, the issue has been resolved.
Ikeda-san, thanks for your quick feedback and support!

OS, Middle ware, Libraries
  • AMI ID (AWS EC2 Instance): ami-31e86030
  • OS: CentOS 6.5(x86_64)
  • Kernel: 2.6.32-358.6.1.el6.x86_64
  • Apache: 2.2.15
  • MySQL: 5.6.16
  • PHP: 5.3.3
  • Zabbix: 2.2.2
  • Hyclops: 0.2.0
  • ZeroMQ: 3.2.2
  • GateOne: 1.1.1
  • Python: 2.7.5
  • Python Modules
    • apache-libcloud (0.14.1) (0.13.2)
    • boto (2.27.0)
    • configobj (5.0.2)
    • distribute (0.6.35)
    • hyclops (0.2.1)
    • ipython (1.2.1)
    • lockfile (0.9.1)
    • pip (1.5.4)
    • psphere (0.5.2)
    • python-daemon (1.6)
    • PyYAML (3.10)
    • pyzmq (14.1.1)
    • setuptools (0.6c11)
    • six (1.5.2)
    • suds (0.4)
    • tornado (2.4.1)
    • wsgiref (0.1.2)
    • zabbix-api (1.0)

Upgrade to CentOS-6.5 from 6.4
MySQL-5.6

Apache-2.2
PHP-5.3
Libraries for Zabbix
Zabbix 2.2
ZeroMQ
Createing Zabbix schema
Python-2.7, Python packages
Python modules
Python module (apache-libcloud)
Make sure that apache-libcloud-0.13.2 should be compiled and installed from tar ball because it failed to install apache-libcloud-0.13.2 with python-2.7 via pip.
Gateone
Replacing some Zabbix dashboard files
I changed the python script for get_aws_charges.py and push_message.py scripts are changed.
Importing Zabbix templates,scripts and globalmacro data
After creating value mappings and creating zabbix hosts on zaxbbix dashboard, I got the error message below in fact. I need to dive into the logging...
This issue has been solved by downgrading apache-libcloud from 0.14.1 to 0.13.2.
See zabbix_server.log to confirm the both python scripts are working to get aws charges and push messages.
See hyclops_server.log to confirm that polling and creating zabbix hosts have been successful.
* You need to change "log_level = DEBUG" on /opt/hyclops/hyclops.conf to debug.

Wednesday, March 12, 2014

AWS EBS snapshots with IAM Cross-Account Access

I recently released a document about how to take EBS snapshots with IAM Cross-Account acccess on slideshare. The summary of its feature is as follows:

  • Cross-account access by using IAM roles allows to take EBS snapshots of other AWS accounts.
  • Use the AWS STS (Security Token Service) to request limited-privilege credentials for AWS IAM role.
  • Possible to centralize the environment to take EBS snapshots for each AWS accounts.

There are ways to take EBS snapshots, such as via Console Management, AWS CLI, and AWS SDKs and it is also possible to regularly and automatically take snapshots by using cron and AWS CLI or writing scripts with AWS SDKs. 
I believe that those who have several AWS accounts such as Management Service Provider, System Integrator, or Enterprise Company especially need to create the environment to take snapshots for each AWS accounts or maybe they can install the environment on each EC2 instances itself. 
The problem is that the environment (EC2 Instances) to take EBS snapshots are increasing as they have more AWS Accounts they have to manage. EBS snapshots with IAM Cross-Account acccess will be one of the solution to centralize the environment to lower cost.

Finally, I prepared a CloudFormation template to deploy a stack with the environment to install and run the script. Please try it and give me a feedback if you have any on it.



Monday, March 10, 2014

Book review of Getting Started with Phalcon by Packt Publishing

I decided to study Phalcon PHP Framework by reading Getting Started with Phalcon because I was very beginner about PHP Framework itself.

Getting Started with PhalconGetting Started with Phalcon by Stephan A Miller

My rating: 4 of 5 stars


I had known nothing about the Phalcon PHP framework before reading "Getting Started with Phalcon", but I learned the basic step by step with the following chapters:
* Chapter 1: Installing Phalcon
* Chapter 2: Setting Up a Phalcon Project
* Chapter 3: Using Phalcon Models, Views, and Controllers
* Chapter 4: Handling Data in Phalcon
* Chapter 5: Using Phalcon's Features

I think that I did take the first step of the Phalcon PHP framework with "Getting Started with Phalcon", but I believe that the very beginners should read the official documentation section to understand the basic, http://docs.phalconphp.com/en/latest/... because the book mainly focuses on their function, not the reason why Phalcon PHP Framework is needed, the principles of PHP Framework itself, and Framework Benchmarks.

The sample codes and the comments at each section help us understand how they work and what they do at each chapter to follow the instructions and create the sample project. The author also provides the sample codes in the book at their github, http://eristoddle.github.io/phalconBlog/, so we can quickly and easily try them.

Lastly, I think that there's some instructions that have been not correct about installing process because some commands or URL have been updated. I just revised some of the commands on my blog here. http://hashnao.blogspot.jp/2014/03/qu...

View all my reviews


Lastly, there are some instructions which needed to be revised when creating a working environment with Amazon Linux AMI on AWS.

P11 Installing Phalcon on Linux
sudo yum install php-develphp-mysqlnd ccc libtool
sudo yum install php-mysqlnd gcc libtool

P12 Installing Phalcon on Linux
git clone git://github.com/phalcon/phalcon.git
git clone git://github.com/phalcon/cphalcon.git

This is just beginning of studying Phalcon PHP Framework, so I need to create sample application with the framework later.

Thursday, March 6, 2014

AWS CLI memorandum - Delete Available EBS Volumes

We sometimes need to delete or remove unnecessary resources which we forgot to do so when we are creating some resources on AWS, don't we? I'm making a note mainly with AWS CLI for those situations.

Today, we are deleting all of the available EBS volumes!

* Describe EBS Volumes
$ aws ec2 describe-volumes| jq '.Volumes[0]'
{
  "Size": 10,
  "AvailabilityZone": "ap-northeast-1a",
  "Attachments": [
    {
      "Device": "/dev/sda",
      "DeleteOnTermination": true,
      "State": "attached",
      "VolumeId": "vol-xxxxxxxx",
      "InstanceId": "i-xxxxxxxx",
      "AttachTime": "2013-09-30T02:16:37.000Z"
    }
  ],
  "VolumeType": "standard",
  "VolumeId": "vol-xxxxxxxx",
  "State": "in-use",
  "SnapshotId": "snap-xxxxxxxx",
  "CreateTime": "2013-09-30T02:16:37.000Z"
}

* Extract available EBS Volumes
$ aws ec2 describe-volumes| jq '.Volumes[] | select(.State == "available") | {VolumeId,State}'
{
  "State": "available",
  "VolumeId": "vol-xxxxxxxx"
}
...
{
  "State": "available",
  "VolumeId": "vol-xxxxxxxx"
}
$ aws ec2 describe-volumes| jq '.Volumes[] | select(.State == "available")' | jq '.VolumeId' | sed -e 's/"//g'
vol-xxxxxxxx
...
vol-xxxxxxxx

* Delete available EBS Volumes in dry-run mode
$ for i in `aws ec2 describe-volumes| jq '.Volumes[] | select(.State == "available")' | jq '.VolumeId' | sed -e 's/"//g'`
  do aws ec2 delete-volume --volume-id $i --dry-run
done
A client error (DryRunOperation) occurred: Request would have succeeded, but DryRun flag is set.

* Delete available EBS Volumes
$ for i in `aws ec2 describe-volumes| jq '.Volumes[] | select(.State == "available")' | jq '.VolumeId' | sed -e 's/"//g'`
  do aws ec2 delete-volume --volume-id $i
done
{
    "return": "true"
}
...
{
    "return": "true"
}

* Confirm available EBS Volumes deleted
$ aws ec2 describe-volumes| jq '.Volumes[] | select(.State == "available") | {VolumeId,State}'

Make sure that unnecessary resources have been released to save cost!

Sunday, March 2, 2014

AWS CoudFormation stack with VPC, Internet Gateway, ELB, EC2 Instnaces, EBS

I created AWS CloudFormation template to save time to deploy stack with a set of AWS resources, VPC, EC2 Instance, ELB, EBS and some packages including Apache, PHP, MySQL. The templates are single pattern with EC2 Instances for WEB and DB server in the same AZ and redundant pattern with Multi-AZ.
As the official says, it is essentially important for every developers or system administrators to deploy stack on AWS. I am one of the them who recognized its importance as I learned CloudFormation in the past months.

 "AWS CloudFormation gives developers and systems administrators an easy way to create and manage a collection of related AWS resources, provisioning and updating them in an orderly and predictable fashion." http://aws.amazon.com/cloudformation/

I was considering to install LAMP packages and provisioning MySQL replication configuration on EC2 Instance with UserData property of AWS::EC2::Instance and Cloud-init (AWS::CloudFormation::Init) at first, but I recognized that it would make it hard to maintain the templates in the future because the templates would be more complicated to achieve it by using those functions.

I'm thinking of trying OpsWorks to progress deployment and provisioning at the next step.