Pages

Monday, November 11, 2013

how-to-install-oracle-java-7-update-45-on-ubuntu-12-10-linux

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" http://download.oracle.com/otn-pub/java/jdk/7u45-b18/jdk-7u45-linux-x64.tar.gz
tar -xvzf jdk-7u45-linux-x64.tar.gz  -C /usr/lib/jvm
cd /usr/lib/jvm
ls -ltr
update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0_45/bin/javac" 1
update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0_45/bin/java" 1
update-alternatives --set "javac" "/usr/lib/jvm/jdk1.7.0_45/bin/javac"
update-alternatives --set "java" "/usr/lib/jvm/jdk1.7.0_45/bin/java"
java -version
javac -version


Source :

http://hendrelouw73.wordpress.com/2013/10/16/how-to-install-oracle-java-7-update-45-on-ubuntu-12-10-linux/

Wget JDK

Download Oracle Java JRE & JDK using a script

Oracle has recently disallowed direct downloads of java from their servers (without going through the browser and agreeing to their terms, which you can look at here: http://www.oracle.com/technetwork/java/javase/terms/license/index.html). So, if you try:
wget "http://download.oracle.com/otn-pub/java/jdk/7u4-b20/jdk-7u4-linux-x64.tar.gz"
you will receive a page with "In order to download products from Oracle Technology Network you must agree to the OTN license terms" error message.
This can be rather troublesome for setting up servers with automated scripts.
Luckily, it seems that a single cookie is all that is needed to bypass this (you still have to agree to the terms to install):
Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F
So, if you want to download jdk7u4 for 64-bit Linux (e.g., Ubuntu) using wget, you can use:
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" "http://download.oracle.com/otn-pub/java/jdk/7u4-b20/jdk-7u4-linux-x64.tar.gz"


source : https://ivan-site.com/2012/05/download-oracle-java-jre-jdk-using-a-script/

Friday, November 8, 2013

Installing salt master and salt minion (agent) on CentOS 6

h3. Installing salt master and salt minion (agent) on CentOS 6

{color:#313131}Beginning with version 0.9.4, Salt has been available in{color}{color:#313131} {color}[EPEL|http://fedoraproject.org/wiki/EPEL]{color:#313131}. It is installable using yum. Salt should work properly with all mainstream derivatives of RHEL, including CentOS.{color}

Salt and all dependencies have been accepted into the yum repositories for EPEL5 and EPEL6. The latest salt version can be found in epel-testing, while an older but more tested version can be found in regular epel.

h5. Salt (master) dependencies:

* PyYAML
* libyaml
* m2crypto
* openpgm
* sshpass
* python-babel
* python-crypto
* python-jinja2
* python-msgpack
* python-zmq
* zeromq3


Now installing salt-master.

{code}
[root@tiber07vm2 ~]# yum install salt-master

[root@tiber07vm2 ~]# salt --version
salt 0.16.4
{code}

Install python pip to install python additional modules
{code}
[root@tiber07vm2 ~]# yum install python-setuptools

[root@tiber07vm2 ~]# easy_install pip
{code}

Upgrade salt which is supported version salt-ssh (first resolved the dependancies for it)
{code}
[root@tiber07vm2 ~]# pip install markupsafe

[root@tiber07vm2 ~]# pip install --upgrade salt

[root@tiber07vm2 ~]# salt --version
salt 0.17.1

[root@tiber07vm2 ~]# salt-ssh --version
salt-ssh 0.17.1
{code}


h5. Basically salt-stack comes with two environment

* Stack master (Server) \-> stack minion (Agent)

* Stack master (SSH) \-> Master connects to agent using ssh, so no additional salt agent is required.

h5. Managed Node Requirements


h5. 1) Salt (minion) dependencies:

On the managed nodes, you only need Python 2.4 or later,
* m2crypto
* openpgm
* python-babel
* python-crypto
* python-jinja2
* python-msgpack
* python-yaml  
* python-zmq    
* zeromq3           

Now installing salt-minion.

{code}
[root@tiber07vm2 ~]# yum install salt-minion

[root@tiber07vm2 ~]# salt-minion --version
salt-minion 0.16.4
{code}

h5. Inventory of manged hosts:

Edit the /etc/salt/minion file on salt-minion server and add entry for salt-master server

{code}
[root@tiber07vm4 ~]# cat /etc/salt/minion
master: tiber07vm2.glam.colo
{code}

Start the master and minion services on salt master and client server
{code}
[root@tiber07vm2 ~]# /etc/init.d/salt-master start
Starting salt-master daemon:                               [  OK  ]

[root@tiber07vm2 ~]# /etc/init.d/salt-minion start
Starting salt-minion daemon:                               [  OK  ]

[root@tiber07vm4 ~]# /etc/init.d/salt-minion start
Starting salt-minion daemon:                               [  OK  ]
{code}

Check discovery for new minion and view the certificate requests on master:
{code}
[root@tiber07vm2 ~]# salt-key -L
Accepted Keys:
Unaccepted Keys:
tiber07vm2
tiber07vm4
Rejected Keys:
{code}

Looks perfect now\!\!

Accept the certificate requests on master:
{code}
[root@tiber07vm2 ~]# salt-key -A
The following keys are going to be accepted:
Unaccepted Keys:
tiber07vm2
tiber07vm4
Proceed? [n/Y] Y
Key for minion tiber07vm2 accepted.
Key for minion tiber07vm4 accepted.
{code}

Verify to see keys are accepted
{code}
[root@tiber07vm2 ~]# salt-key -L
Accepted Keys:
tiber07vm2
tiber07vm4
Unaccepted Keys:
Rejected Keys:
{code}


h5. Test the connection with the children:

Great you have done so far, now it is time to test


{code}
[root@tiber07vm2 ~]# salt 'tiber07vm4' test.ping
tiber07vm4:
    True

[root@tiber07vm2 ~]#  salt '*' test.ping
tiber07vm4:
    True
tiber07vm2:
    True
{code}


h5. 2) Salt (ssh) dependencies:

On the managed nodes, you only need Python 2.4 or later.



h5. SSH trust : since you want pass wordless authentication from your master machine ,its advisable to establish a trust

{code}
ssh-copy-id tiber07vm2

ssh-copy-id tiber07vm4
{code}

Inventory of manged hosts will be at /etc/salt/roster, this example configuration contains host without password (shared auth_key) and with password host entries.
{code}
[root@tiber07vm2 ~]# cat /etc/salt/roster
tiber07vm2:
  host: tiber07vm2
  user: root
tiber07vm4:
  host: tiber07vm4
  user: root
  passwd: myrootpassword
{code}

h5. Test the connection with the children:

Great you have done all, now it is time to test

{code}
[root@tiber07vm2 ~]# salt-ssh '*' test.ping
tiber07vm2:
    True
tiber07vm4:
    True
{code}

h5. Sample run :

{code}
[root@tiber07vm2 ~]# salt-ssh  'tiber07vm4'  -r  'uptime'
tiber07vm4:
     02:38:11 up 20 days, 14:16,  1 user,  load average: 0.09, 0.08, 0.02

[root@tiber07vm2 ~]# salt-ssh  '*'  -r  'uptime'
tiber07vm2:
     02:38:22 up 20 days, 14:16,  1 user,  load average: 0.08, 0.08, 0.02
tiber07vm4:
     02:38:23 up 20 days, 14:16,  1 user,  load average: 0.08, 0.08, 0.02
{code}


h5. Known Errors and fixes:

{code}[root@tiber07vm2 ~]# salt-ssh  'tiber07vm2'  -r  'uptime'
OSError: [Errno 38] Function not implemented
{code}

Ohh LXC\!\!, You will get python OSError because of not to write /dev/shm (tmpfs), so to enable it  update your /dev/shm mount options (rw, noexec) and remount /dev/shm.


{code}
[root@tiber07vm2 ~]# cat /etc/fstab
/dev/root               /                       rootfs   defaults        0 0
none                    /dev/shm                tmpfs    rw,nosuid,nodev,noexec    0 0
#none                    /dev/shm                tmpfs    nosuid,nodev    0 0

[root@tiber07vm2 ~]# mount /dev/shm
{code}

Thursday, October 31, 2013

Installing ansible on Centos 6

h3. Installing ansible on Centos 6

h5. ansible  dependencies

* python-babel
* PyYAML    
* python-crypto      
* python-jinja2      
* python-paramiko
* python-simplejson.x86_64 - on all nodes ( if python is lower version than 2.5 )

{code}
[root@tiber07vm1 ansible]# ansible --version
ansible 1.1
{code}


h5. Control Machine (master ) Requirements :

Currently Ansible can be from any machine with Python 2.6 installed

[root@tiber07vm1 download]# python -V
Python 2.6.6


h5. Managed Node Requirements
On the managed nodes, you only need Python 2.4 or later, but if you are are running less than Python 2.5 on the remotes, you will also need:

h5. Inventory of manged hosts:

Inventory of manged hosts will be at /etc/ansible/hosts

{code}
[root@tiber07vm1 ansible]# cat /etc/ansible/hosts
[local]
tiber07vm1

[remote]
tiber07vm3

[all:children]
local
remote

{code}

h5. First run :

{code}
[root@tiber07vm1 ansible]# ansible remote1  -a "uptime" --ask-pass
SSH password:
tiber07vm4 | success | rc=0 >>
 23:27:18 up 20 days, 11:05,  0 users,  load average: 0.00, 0.00, 0.00

{code}

h5. SSH trust : since you want pass wordless authentication from your master machine ,its advisable to establish a trust

{code}

ssh-copy-id tiber07vm1

ssh-copy-id tiber07vm3

{code}

h5. Sample run :

{code}

[root@tiber07vm1 ansible]# ansible local -a "uptime"
tiber07vm1 | success | rc=0 >>
 23:32:56 up 20 days, 11:10,  1 user,  load average: 0.04, 0.02, 0.00

[root@tiber07vm1 ansible]# ansible remote  -a "uptime"
tiber07vm3 | success | rc=0 >>
 23:33:01 up 20 days, 11:10,  0 users,  load average: 0.04, 0.02, 0.00

[root@tiber07vm1 ansible]# ansible all -a "uptime"
tiber07vm1 | success | rc=0 >>
 23:33:06 up 20 days, 11:11,  1 user,  load average: 0.03, 0.02, 0.00

tiber07vm3 | success | rc=0 >>
 23:33:07 up 20 days, 11:11,  0 users,  load average: 0.03, 0.02, 0.00


{code}

Tuesday, October 29, 2013

Bash serial execution of commands and exit on critical

If you want  to executue the shell commands serially in bash script but also want to keep checking and exit if  any of the command fails

set this at the top of your script

set -e
set -o pipefail

Tuesday, October 8, 2013

Yum custom variables

While defining the your local yum repository you can use YUM's in built and custom variable, most commonly used are


$releasever
This is replaced with the package's version, as listed in distroverpkg. This defaults to the version of the redhat-release package. ( this is defined in /etc/yum.conf)
e.g rpm -q --queryformat '%{VERSION}' centos-release-5-9.el5.centos.1

$arch
This is replaced with your system's architecture, as listed by os.uname() in Python.
$basearch
This is replaced with your base architecture. For example, if $arch=i686 then $basearch=i386.
$YUM0-9
This is replaced with the value of the shell environment variable of the same name. If the shell environment variable does not exist, then the configuration file variable will not be replaced.


IF you are using Centos6 (rhel 6) you can define a custom variable or  override the value of an existing one, using file with the same name as the variable (without the “$” sign) in the /etc/yum/vars/ directory, and add the desired value on its first line.

e.g. 

[root@myhost~]# cat /etc/yum/vars/releasever
6.4




Also have multilib_policy defined in your yum.conf to download the required architecure rpms only (32 bit /64 bit)

multilib_policy=best


Thursday, September 5, 2013

Updating glibc on Ubuntu 10.10

Recently I was struggling to update the glibc on Ubuntu 10.10 from EGLIBC 2.12.  to 2.15

Here are the steps I have taken to perform these tasks

cd /usr/local/src/
         wget http://archive.ubuntu.com/ubuntu/pool/main/e/eglibc/eglibc_2.15.orig.tar.gz
tar tvzf eglibc_2.15.orig.tar.gz
apt-get install alien
alien --to-deb eglibc_2.15.orig.tar.gz
dpkg -i nscd_2.15-0ubuntu10_amd64.deb libc6_2.15-0ubuntu10_amd64.deb libc6_2.15-0ubuntu10.4_amd64.deb libc-bin_2.15-0ubuntu10.4_amd64.deb

and finally reboot :)

And this is how you can confirm


root@:~# aptitude show libc6 | grep Version
Version: 2.15-0ubuntu10.4
root@:~# aptitude show libc-bin | grep Version
Version: 2.15-0ubuntu10.4
root@:~# aptitude show nscd | grep Version
Version: 2.15-0ubuntu10
root@:~# ldd --version | head -n1
ldd (Ubuntu EGLIBC 2.15-0ubuntu10.4) 2.15