Pages

Friday 19 July 2013

Build your own private cloud with Ubuntu - II

Some rights reserved by ErinOfEarth


Continuing from...

Build your own private cloud with Ubuntu - I

  Create node for your MAAS server. You must have atleast 2 nodes before going ahead with juju setup. Go to the webpage for maas server and Click on Add nodes.
We left all the other information fields there blank except for the MAC-ADDRESS. You can get the mac address of your computer by ipconfig on windows and ifconfig on Ubuntu - Ubuntu users can do: 
ifconfig | grep hwadrs

Then we went to
http://maas.ubuntu.com/docs/juju-quick-start.html
Thereafter we created ~/.juju/environments.yaml
vim ~/.juju/environments.yaml
Added the following details to this file

juju: environments
environments:
  maas:
    type: maas
    maas-server: 'http://localhost:5240'
    maas-oauth: '${maas-api-key}'
    admin-secret: 'nothing'

Got an error default-series: missing

Added this line to the above file
    default-series: 'precise'
Error Gone

juju status
New error
Juju INFO Connecting to environment... Unhandled error in Deferred: Unhandled Error

Investigated, result:
Juju packages needs to be installed from ppa:juju/pkg

Went to
https://juju.ubuntu.com/docs/
removed existing juju
sudo apt-get update
            sudo apt-get install juju-core (error no package)


sudo add-apt-repository ppa:juju/devel
            sudo apt-get update && sudo apt-get install juju-core

Configuring Juju
juju generate-config -w   
previously written environment.yml was moved and the changes were added to the new yml file.

error: environment has no access-key or secret-key

changed default: amazon to default: maas
juju bootsrap
error:no tools
sudo juju -v sync-tools

roshan@ubuntu-cloud:~$ sudo juju bootstrap
error: cannot start bootstrap instance: cannot run instances: gomaasapi: got error back from server: 409 CONFLICT

CONFLICT from maas means that it doesn't have any nodes available for juju to acquire (juju bootstrap needs to boot a node).
It's not the best error unfortunately, juju needs fixing to show all the text. You need the server edition of 12.04

Nodes were disconnected for sometime...
Next article should have the addition of nodes...

Creating an exactly similar snapshot of your existing running EC2 ami instance

Some rights reserved by Martin Fisch


Everything was going pretty well on the existing EC2 instance, when the developers offshore came up with another version of the existing CMS, which needed to be tested along with the existing CMS. One way was to have another virtual host created for the new CMS but there were some existing resources that could not be shared between the two CMSs.

The only way out of this was to have another instance with the new CMS version. Installing the same applications in the new instance was surely time consuming, this would take another day for sure. So we came up with the idea of creating a snapshot of the existing instance.

Caution: If you only try to create a copy of the existing instance you will only get the Instance along with the OS not the applications along with it. To create the exact similar copy of the instance the steps are slightly different.

Steps to create an exact similar copy are as follows:

  1. Create an EBS volume using the web interface. You may use Amazon Documentation for this.
  2. Attach this volume to your existing instance. note down the volume and the device id. (Vol -123456, /dev/sdg) Documentation
  3. Next you would need is a file system to work on, on the attached volume. Log in to your instance, and use the commands below
    • mkfs.ext3 /dev/sdg
    • tune2fs -c 0 /dev/sdg
  4. Now mount this disk
    • mkdir /mnt/data
    • mount /dev/sdg /mnt/ebs
  5. Now you can copy all the data to your EBS volume but before you do that, shutdown the running services that may harm the data, I stopped MySQL Apache, ElasticSearch etc on my instance. To copy all data use rsync : This will sync all the data in your present volume to the new volume.
    • rsync -avx --exclude /mnt / /mnt/ebs //you may use --exclude <directory name> to exclude any directories
  6. This should take long time depending on how big the data is. Once the copying is done, Unmount the volume by:
    • umount /dev/sdg
    • You may want to check the volume space by df -h
  7. Detach the volume for the present instance from the console. Documentation
  8. Right click on the volume and click on create AMI image. When the image is created. Right click on it and click on Launch Instance.

You now have an exact copy of your old instance running.

Monday 8 July 2013

Local Drupal Setup

Some rights reserved by Gabor Hojtsy


Drupal is a CMS (Content Management System) written in PHP and is distributed under GNU public license. It is used as a backend for most of the websites world wide. Many organizations as well as individuals are switching there websites to a CMS based website for one reason: Easy management. The other important reasons follow thereafter.

So here's how to setup Drupal locally on your machine.

You would need two things to setup Drupal.

1. Drupal's  latest version from the Drupals website
2. A WAMP(Windows Apache MySQL PHP) server setup. Linux users (LAMP) from wamps website

Steps to install:
1. Install Wamp
This will be fairly simple, Once you execute the wampserver.exe all you do is press next until its successfully installed.
2. Unzip the Drupal's zip file downloaded to the wamp/www folder in your C: drive OR whichever drive has the wamp's www directory.
3. The directory name at present is Drupal-x.y(version number), Rename it to drupal.
4. If you have Skype installed and running note that skype uses the same port as that of WAMP so WAMP may give up problems. Close Skype and Run WAMP from the system tray start the service.
5. In your  browser, type localhost and press enter, You should see WAMPs page, Select PHPMYADMIN on the page.
6. Next we need to create a database for Drupal. In the create new database field enter you drupal db name and press create.
7. Drupal database is not created.
8. On you browser go to localhost/drupal this should prompt you for drupal install
Database type: mysql
Database name: <drupal_db_name>
Database username: root
Database password:blank
Save configuration.
9.  Create an account enter you details, you may get a mail error, ignore for now. Save it.
10. Click on home link and you should see your drupal home page.
11. Click on rebuild permissions on the home page if you see it. It should remove any errors in the permissions in file system.
12. From the tabs above find the configuration tab and if you see any errors it should be marked in red in the configuration page in the status report. The solution to any error is usually available in the same area. SO you are good to go in.

You now have a local copy of your Drupal Installation available and ready to use.

Setting up your own FTP server (Ubuntu)

Some rights reserved by Blake Patterson


Only after i did it i learnt, things aren't as difficult as they seem to be. I recently got a chance to set up my own FTP server. Not only that, i also made people use it. That was a real win.

So here's the thing, Due to some technical problems my company's FTP server was non-functional or i would say, it didn't give the results as per expectations. So i started looking for alternatives. Since the QA team tests mostly on a Windows machine i was looking for a Windows FTP server setup. I am not sure if any FTP server setup software is available for free, but after some research i only found some paid FTP server softwares for Windows which i didn't really want.

The project requirement was such that the, the application will be continuosly monitoring the FTP server. A cronjob will be setup which will look for some XML files in the FTP servers xyz directory. The found XMLs will be auto-ingested into the application by a POST and the Database will be updated accordingly.

So i needed an FTP. Obviously, i was looking for a free one. Ubuntu came for my rescue. I would rather say, i got another reason for why i prefer Linux over Windows.

vsftpd - Very Secure File Transfer Protocol Daemon

vsftpd is an ftp server for Linux and Unix machines distributed under GNU public license. It supports almost all Linux systems and it is fairly easy to install as well. You can customize a welcome message for people logging in to your server. And all the required changes just needs to be done in a configuration text file. That was awesome!!!

More about vsftpd can be read from Wikipedia

Steps to install and have your own vsftpd

I would say 4 simple steps (on Ubuntu Linux) and you have you FTP server started.

  1. sudo apt-get install vsftpd
  2. Open the configuration text file vsftpd.conf in your favorite editor  "vim /etc/vsftpd.conf"
  3. Make the required changes and save the file (Changes are discussed below)
  4. Start the vsftpd service by sudo service vsftpd start OR /etc/init.d/vsftpd start
You have your own FTP server setup.
 Important changes in the configuration file:

listen=YES
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=YES
# Uncomment this to allow local users to log in.
local_enable=YES
# Uncomment this to enable any form of FTP write command.
write_enable=YES
# Directory which you want to be the root FTP directory
local_root=/srv/ftp/
  # Activate directory messages - messages given to remote users when they
 # go into a certain directory.
 dirmessage_enable=YES
  # If enabled, vsftpd will display directory listings with the time
 # in  your  local  time  zone.  The default is to display GMT. The
 # times returned by the MDTM FTP command are also affected by this
 # option.
 use_localtime=YES
  # Activate logging of uploads/downloads.
 xferlog_enable=YES
  # Make sure PORT transfer connections originate from port 20 (ftp-data).
  connect_from_port_20=YES
 # You may fully customise the login banner string:
 ftpd_banner=Welcome to Roshan's FTP service.
 # This option should be the name of a directory which is empty.  Also, the
 # directory should not be writable by the ftp user. This directory is used
 # as a secure chroot() jail at times vsftpd does not require filesystem
 # access.
 secure_chroot_dir=/var/run/vsftpd/empty
 # This string is the name of the PAM service vsftpd will use.
 pam_service_name=vsftpd
 # This option specifies the location of the RSA certificate to use for SSL
 # encrypted connections.
 rsa_cert_file=/etc/ssl/private/vsftpd.pem

This is all you need to do to have a personal FTP.

To login to your ftp server you need to do the following in a Linux or Windows Terminal.

ftp <your_ip_addres>
Username: <for_ur_machine>
Password: <for_ur_machine>
 logged in

all the transfer operations can now be performed