Showing posts with label CENTOS. Show all posts
Showing posts with label CENTOS. Show all posts

Friday, October 18, 2013

CENTOS v 6.4, GIT v 1.7.1 and JENKINS v 1.535 CONTINOUS INTEGRATION

Having tuned our Agile process to release iteratively and often I decided it was time to spend some time looking at how we could introduce continuous integration into our PHP and Javascript BDD workflows. Given that Travis isn’t suitable for most of our work (your code must be open source), I chose Jenkins as our CI server and was able to get up and running fairly quickly. I  found a few resources that covered integrating Git with Jenkins but I ended up doing a bit of digging myself so thought I’d quickly share the steps I followed.

Install Jenkins and Git

I provisioned a fresh CENTOS v 6.4 box, which meant I was able to follow the official Jenkins docs without any problems. If you’re using anything other than Ubuntu/Debian or Redhat you may need to look elsewhere. The installation instructions outline simple Apache or Nginx vhost configurations that can be used to serve the Jenkins administration console. You’ll need to install git on the same box so that Jenkins can eventually pull down, or commit to, your git repositories. To install Git I simply ran $ sudo apt-get install git (debian) and $ yum install git (Centos).

Install the Git Plugin

Once you can access your Jenkins console,  goto `Manage Jenkins -> Manage Plugins` from the home screen.
Open the ‘Available’ tab and find the plugin entitled Git Plugin.There is a filter box but it didn’t work particularly well for me, I ended up using Find in Chrome.

Create ssh key pair

Part of the installation process will create the user `jenkins` which will envoke all Jenkins processes, including all git commands. Therefore you’ll need to provision a keypair for this user then add the public key to your git repo. There’s a bit of trick to doing the former which I’ll cover now:

  1. Login to your box and switch to the Jenkins user. The installation process doesn’t create a password so you’ll need to have root/sudo permissions to do this. Run the command sudo su - jenkins. The ‘-’ specifies a login shell, and will switch you to jenkins’ home directory (for me this was /var/lib/jenkins’).
  2. Create a .ssh directory in the jenkins home directory.
  3. Create the public private key pair. There are many tutorials which cover using the ssh-keygen command to do this. The most important thing is not to set a password, otherwise the jenkins user will not be able to connect to the git repo in an automated way.
  4. Add the public key to your Git repo. We use bitbucket so this was fairly straightforward for me and I imagine anyone reading this will have performed similar actions for all their devs keys in the past.
  5. Set a git user and email address. This is also mentioned in the git plugin documentation. Run:cd /srv/jenkins/jobs/project/workspacegit config user.email "some@email.com"git config user.name "jenkins".
Connect to the Git repo. This is a one time step which will dismiss that ‘Are you sure you want to connect’ ssh message, again jenkins won’t be able to deal with this. Just run ssh git@your_git_server_url info.

Create a new Job in Jenkins

The official docs provide a good level of detail on how to configure a basic Jenkins job, so I’d recommend following them here. The git-plugin docs also provide some useful info, so there’s not too much more for me to say other than list the steps I followed:

  1. Select Git in Source Code Management.
  2. Enter your git repository URL. This performs a asynchronous check and will give you an error if it can’t connect. Double check you followed the steps in #3 if you get an error.
  3. Select the branch to build. This is branch jenkins will pull from when a build is started so enter whatever is suitable. We are building from develop so I entered this here.

Run a test Build

Once you’ve saved the job it’s worth kicking off a build to check everything’s working OK. You can do this in the main dashboard. Have a look at the latest build, you should see the commit id that was pulled down. If you dig around in the docs you’ll find that the plugin will have fetched your branch (in my case develop) and pulled from the remote repo. The repo is checked out into the job’s `workspace` directory and during the build the Jenkins user is cd’d into this directory. By adding your makefiles and build scripts into your repository it’s then a straightforward case of configuring the Jenkins job to execute these upon build. Again, this is covered in good detail in the docs.

Post Receive Hook

Finally you’ll need to setup your Git repository to initialise a build each time you push to your repository. Github and bitbucket both have hooks ready to be used, but if you’re self hosted a good place to start is at the plugin documentation which specifies the HTTP endpoint which can be used to trigger the job.


Sunday, March 10, 2013

Installing CentOS 6.4 Step by Step

In this post, I will show step by step process of installing CentOS 6.4. At first, download the installation image to do the fresh install. Download Disk1 and Disk2 installation images. While the disks are being downloaded, take a look at release notes of CentOS 6.4.


  1. At first, insert the bootable media in the drive and start the machine. Then select Install or upgrade an existing system.
  2. Choose Skip to cancel the installation media check. But if you choose ok, this will check your installation media for any sort of missing installation files of the operating system.
  3. Now you can see the installation welcome screen. Here click next button.
  4. Now choose the language you prefer to install and click next button.
  5. Choose the appropriate keyboard layout from the option and click next button.
  6. Here choose Basic Storage Device and click next button.
  7. Click Yes, discard any data to continue option in storage device warning.
  8. Type unique host  name for this system and click Next button.
  9. Select time/zone and click next button.
  10. Enter strong root password and click next button.
  11. Choose the type of installation. Here I will choose replace existing Linux system(s). You can check review and modify partition layout to edit partitions. You can create new partitions from here. But I will not check this and click next button.
  12. Click write changes to disk.
  13. Choose Basic server and click next button.
  14. The installation now starts.
  15. Installation has successfully completed. Click restart to finish installation.
You can now configure IP address, GUI or other features as required.

Monday, April 30, 2012

Installing MySQL on Linux (centOS)


Following are steps to install MySQL on CenOS 5/6.

  1. Check the OS Versions and download respective installables from Oracle / Mysql Sites.
    1. cat /proc/version
    2. cat /etc/issue
    3. cat /etc/redhat-release
    4. lsb_release -a
  2. For my CentOS system download following to your Linux System:
    Output of $ lsb_release -a
    1. MySQL Cluster 7.3.4 RPM for Oracle Linux / RHEL 6 x86 (64bit) V43767-01 330M
    2. MySQL Cluster Manager 1.3.0+Cluster RPM for Oracle Linux/RHEL 5+6 x86 (64bit) V42979-01 140M
    3. or download: MySQL-Cluster-gpl-7.3.5-1.rhel5.x86_64.rpm-bundle.tar
  3. Important RPM Command for Installing RPM Package.
    1. Install: $ rpm -ivh mcm-1.3.0-cluster-7.3.3-linux-rhel5-x86-64bit.rpm
      1. -i : install a package
      2. -v : verbose for a nicer display
      3. -h : print hash mark as the package archive is unpacked.
    2. Check Signature: $ rpm --checksig mcm-1.3.0-cluster-7.3.3-linux-rhel5-x86-64bit.rpm
    3. Check dependency of rpm package before installing:[rpm -qPR *.rpm]
      1. -q: query a package
      2. -p: list capabilities this package provides
      3. -R: list capabilities on which this package depends
    4. Install a RPM package without dependencies: [rpm -ivh --nodeps *.rpm]
    5. Check an install rpm package: rpm -q mysql
    6. List (query list) all files of an installed rpm package: [ $ rpm -ql mysql]
    7. List recently installed rpm packages: [$ rpm -qa --last]
    8. List all installed rpm packages: [$ rpm -qa]
    9. Upgrade a rpm package: [rpm -Uvh *.rpm]
    10. Remove a package: [$ rpm -evv mysql]
    11. Remove a rpm package without dependencies: [$ rpm -ev --nodeps mysql]
    12. Query a file that belongs which rpm package: [$ rpm -qf /usr/bin/htpasswd]
    13. Query an info for installed rpm package: [ $ rpm -qi mysql]
    14. Get info of rpm package before installing: [ $ rpm -qip *mysql*.rpm] # query info package
    15. Query documentation of installed RPM Package: [ $ rpm -qdf /usr/bin/vmstat] (query document file)
    16. Verify a RPM package: (verify package) $ rpm -vP *mysql*.rpm
    17. Verify all RPM package: rpm -Va
    18. Import RPM GPG Key: $ rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CENTOS-6
    19. List all imported RPM GPG Key: ( $ rpm -qa gpg-pubkey*)
    20. Rebuild corrupted RPM database: Sometimes rpm database gets corrupted and stops all the functionality of RPM and other applications on the system, so at that time we need to rebuild the RPM Database and restore it with the help of following commands:
      1. cd /var/lib
      2. rm __db*
      3. rpm --rebuilddb
      4. rpmdb_verify Packages
  4. Installation Steps:
    1. Create required users / group on CentOS & unarchive file on all hosts:
      1. $ groupadd mysql
      2. $ useradd –g mysql mysql
      3. Artifacts.
        1. tar –zxvf  /usr/local/ mysql-cluster-gpl-7.3.2-linux-glibc2.5-x86_64.tar.gz or
        2. tar -zvf /usr/local/ MySQL-Cluster-gpl-7.3.5-1.rhel5.x86_64.rpm-bundle.tar [ wget http://cdn.mysql.com/Downloads/MySQL-Cluster-7.3/MySQL-Cluster-gpl-7.3.5-1.rhel5.x86_64.rpm-bundle.tar to download file]
      4. mv /usr/local/ mysql-cluster-gpl-7.3.2-linux-glibc2.5-x86_64 /opt/mysql_cluster
      5. chown mysql.mysql –R /opt/mysql_cluster
    2. We have list of following Servers:
      1. 10.253.92.154 - ndb(192.168.1.196) & mgm (192.168.1.144)
      2. 10.253.92.155 - ndb(192.168.1.197)
      3. 10.252.168.174 - mysql (192.168.1.152)
      4. 10.252.168.173 - mysql (192.168.1.193)
    3. On Server '10.253.92.154' & '10.253.92.155' create a new folder - Data Node.
      1. mkdir  /opt/mysql_cluster/ndbdata
      2. chown mysql.mysql –R /opt/mysql_cluster
    4.  MGM Node: (10.253.92.154) configuration:
      1.  cd /opt/mysql_cluster/ 
      2. vi config.ini
    5. Install and configure mysql on two mysqld node (10.252.168.173, 10.252.168.174)
      1. cd /opt/mysql_cluster/
      2. scripts/mysql_cluster_install --user=mysql --datadir=/opt/mysql_cluster/data --basedir=/opt/mysql_cluster/
      3. mv /opt/mysql_cluster/my.cnf /etc/my.cnf
      4. vi /etc/my.cnf 
      5. Modify the /opt/mysql_cluster/support-files/mysql.server, replace datadir and basedir
        1. datadir=/opt/mysql_cluster/data
        2. basedir=/opt/mysql_cluster/
    6. Start all cluster and mgm node:
      1. Startup data node(10.253.92.154, 10.253.92.155)
      2. [root@Node1]# /opt/mysql_cluster/bin/ndbd --defaults-file=/opt/mysql_cluster/my.cnf --initial
      3. 2013-10-02 13:17:36 [ndbd] INFO     -- Angel connected to '10.253.92.154:1186'
      4. 2013-10-02 13:17:36 [ndbd] INFO     -- Angel allocated nodeid: 11
      5. Startup mysqld node(10.252.168.173, 10.252.168.174)
      6. Startup the mgm node:
        1. /opt/mysql_cluster/bin/ndb_mgmd -f /opt/mysql_cluster/config.ini --configdir=/opt/mysql_cluster
    7. Check status: