Sunday, 17 August 2014

MongoDB: Installation on Ubuntu/Debian Machine


  • Before making an installation of Mongodb on ubuntu we need to add sources list to local repository.
  • First of all, we need to add MongoDB Public GPG Key
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

  • Next, we need to update source list /etc/apt/source.list.d/mongodb.list file using following command

echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list


  •  Now, we need to update the repository...
 sudo apt-get update

  •  Now , we are ready to install our MongoDB installation
 apt-get install mongodb-10gen=2.2.3

  •  Now we had installed MongoDB , we need to start the service

service mongodb start

  • To login into mongodb prompt, we give command 
 mongo

  • If you need mongodb help, use command

 db.help()

Sunday, 6 July 2014

Jenkins: Installation on Ubuntu/Debian Machine

Installing Jenkins on Ubuntu or Debian


* If you are installing Jenkins on Debian or Ubuntu, it is convenient to install the native binary package for these platforms. So. First of all, you need to add the key to your system as below:
      $ wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | apt-key add -

      $ sudo echo "deb http://pkg.jenkins-ci.org/debian binary/" > /etc/apt/sources.list.d/jenkins.list

* Now, we update the Debian package repository, to check whether key is set and package are easily extracted.
     $ sudo apt-get update -y

* Once this is done, you can install Jenkins using apt-get tool:
     $ sudo apt-get install -y jenkins
 
  This will install jenkins as a service, with a correclty configured script at /etc/init.d/jenkins and a        corresponding system user called "jenkins".

* By default, you will find the jenkins WAR file in the /usr/share/jenkins directory, and the Jenkins home directory in /var/lib/jenkins.

* Now, you can start the Jenkins service:
     $  sudo /etc/init.d/jenkins start
   or
     $  sudo service jenkins start
* You can see the Jenkins dashboard at http://localhost:8080/
    If you can see the dashboard that means you have correct installation on Debain/Ubuntu
 
This is way to install to Jenkins on Debian/Ubuntu Machine. Other Machines (REDHAT, CentOS) will     require some changes.

JAVA: How to install Java (JRE/JDK) on Ubuntu Machine


Installing default JRE/JDK
This is recommended and will install OpenJDK 6 on Ubuntu 12.04 and earlier and on 12.10+ it will install OpenJDK7.

* Installing java with apt-get is easy. First update the package
                 sudo apt-get update -y

* Then, check Java is installed or not
        java -version
   If it returns "The program java can be found in the following packages" then you need to install it. For that      you need to execute following command: 
        sudo apt-get install default-jre

  This install Java Runtime Environment(JRE)

* Now you will also need Java Development Kit (JDK) needed to compile Java applications(say Apache        Ant , Apache Maven, Eclipse).
   Execute the following command: 
        sudo apt-get install default-jdk

This is everything need to install Java on Ubuntu Machine.

Thursday, 3 July 2014

Chef solo: Chef Installation and create first cookbook

 Install curl for installing chef
           apt-get install curl*

Installing chef using curl
      curl -L https://www.opscode.com/chef/install.sh | bash
      You can choose the chef install link from according to your OS.
      http://www.getchef.com/chef/install/
 
Checking chef is installed or not or verifing the installation
        chef-solo -v

Now you need to get the file structure of chef in order to organise the various cookbooks
        wget http://github.com/opscode/chef-repo/tarball/master
        tar zxf master
        mv opscodee-chef-repo* chef-repo

Now to get to start writing cookbook for apache
        cd chef-repo
        mkdir .chef

We use knife cli tools to create cookbooks . First we need to tell knife where to fetch the cookbook
         echo "cookbook_path [  '/root/chef-repo/cookbooks'  ] "  >   .chef/knife.rb

Now we will create a phpapp cookbook
         knife cookbook create phpapp
         cd cookbooks

Now we download cookbook which acts a library for our cookbook
    Apache2
         knife cookbook site download apache2
         tar zxf  apache2*
 
    Apt - which ensure that chef-solo mkaes a apt-get update before we install any packages.
         knife cookbook site download apt
         tar zxf apt*
    Iptables

        knife cookbook site download iptables
        tar zxf iptables*
 
   Logrotate -
        knife cookbook site download logrotate
        tar zxf logrotate*
   Pacman
        knife cookbook site download pacman
        tar zxf pacman*

Now we configure these things
         cd phpapp/

Now we need to make changes in different configuration files
     open metadata.rb
     add line
     depends "apache2"

Open recipe/default.rb add lines
        include_recipe "apache2"
         apache_site "default" do
              enable true
         end

       cd ../..
    create a file solo.rb and add lines
    file_cache_path "/root/chef-solo"
    cookbook_path "/root/chef-repo/cookbooks"

Again create a file name web.json
    add lines
    {
         "run_list" :   ["recipe[apt]", "recipe[phpapp]"]
      }


Now finally execute below command to run the code
     chef-solo -c solo.rb -j web.json


 Note: using Ubuntu machine as OS in rackspace


Knife-solo: CLI tool for chef


knife-solo adds a handful of Knife commands that aim to make working with chef-solo as powerful as chef-server.
Usage: Having the gem installed will add knife chef subcommands.
Run knife solo with no arguments to know all the commands.
Knife-solo is a command-line tool that provides an interface between a  local chef-repo and chef-server.
It include 5 subcommands to knife tools:
*  knife solo init myapp: This will create a chef standard directory (i.e. kitchen) structure which will be used for build and store recipes. It's like initialising 
*  knife solo prepare: Installs chef on a given host. It auto detect the targeted OS. 
*  knife solo cook:   Uploads the kitchen to target host and run chef-solo.
*  knife solo bootstrap: combines the two previous ones.
*  knife solo clean: removes the uploaded kitchen from the target host.
This actually helps you create a directory structure of chef and also it integrates with Berkshelf and Libraian-Chef and bootstraps the process of the nodes.

Friday, 18 April 2014

Ruby On Rails Installation using RVM (Ubuntu)

For the installation of ruby on rails follow below steps

* Ruby Version Manager: Firstly, we need to install ruby version manager.

$ apt-get install curl
$ \curl -sSL https://get.rvm.io | bash -s stable
$ source ~/.rvm/scripts/rvm


* Ruby: Next, Once you are using RVM , we need to install ruby


$ rvm install 2.1

you can make the recently installed ruby version as default as there may be more than one ruby installed.

$ rvm use ruby --default


* Rubygems: The next step is to install rubygems with current version/

$ rvm rubygems current 

* Rails: Once everything is setup, it's time to install rails


$ gem install rails

This is how, the ruby on rails get installed on your ubuntu machine.

Sunday, 19 January 2014

SSH Keygen: Is RSA or DSA Better

Here are some of the points to be considered:


* DSA is faster for signature generation but slower for validation, slower when encrypting but faster when decrypting and security can be considered equivalent  compared to an RSA key of equal key length.
* The Security of the RSA algorithm is based on the fact that factorization of large integers is known to be "difficult" whereas DSA security is based on the discrete logarithm problem.
* Today, Fastest known algorithm for factoring large integers is the General Number Field Sieve, also fastest algorithm to solve the discrete logarithm problem in finite fields modulo a large prime p as specified for DSA
* In RSA, we don't ever need a secure random number generator to create signatures whereas, DSA needs a value that has to be random, secret/unpredictable and can never be used.
* RSA keys can go up to 4096 bits, where DSA has to be exactly 1024 bits (although OpenSSL allows for more)

Things in favor of DSA

1.  DSA can only be used with SSH protocol 2 while RSA can be used with protocols 1 and 2 (See “SSH    2″ Versus “OpenSSL and OpenSSH Release 2”). Protocol 1 has some significant design flaws  and  has been replaced by Protocol version 2. I see this as a reason to slightly favor using DSA keys, a sort of built in protection from using the older obsolete protocol.

Things in favor of RSA
1. A bad random number generator will leak DSA key bits
2. The openssh.org web site appears to be mute on the subject of which is better, but the newer versions of        ssh-keygen create an RSA key if you do not specify the type
3. There seem to be more (and newer) RFCs referencing RSA keys than DSA keys.