Sunday, 30 August 2015

Create Local Repository - Solaris 11.2

Image packaging system(IPS) and important concept from Solaris 11 onwards. I would like to create local repository on the local system by downloading the files from the Oracle website using oracle's automated script.

Download below files and copy to your local Solaris server.
Below are the files copied on my local Solaris server. 

root@solnode1:/var/share/pkg# pwd
/var/share/pkg
root@solnode1:/var/share/pkg# ls -l
total 14373953
-rwx------   1 root     root        5594 Aug 29 20:52 install-repo.ksh
drwxr-xr-x   3 pkg5srv  pkg5srv        7 Aug 30 08:42 repositories
-rw-r--r--   1 root     root     1771800121 Aug 29 15:32 sol-11_2-repo-1of4.zip
-rw-r--r--   1 root     root     1889867782 Aug 29 15:35 sol-11_2-repo-2of4.zip
-rw-r--r--   1 root     root     1902167161 Aug 29 16:46 sol-11_2-repo-3of4.zip
-rw-r--r--   1 root     root     1790358735 Aug 29 16:44 sol-11_2-repo-4of4.zip
-rw-r--r--   1 root     root         227 Aug 29 16:14 sol-11_2-repo-md5sums.txt
root@solnode1:/var/share/pkg#

root@solnode1:/var/share/pkg#./install-repo.ksh -d /var/share/pkg/repositories/ -v -c

The script would compare the checksums of the downloaded files, uncompress and would initiate the repository creation. 

your current publisher would be pointing to "pkg.oracle.com" and it needs to be changed to your local repository. 

root@solnode1:~# pkg publisher
PUBLISHER                   TYPE     STATUS P LOCATION
solaris                     origin   online F http://pkg.oracle.com/solaris/release/
root@solnode1:~#

root@solnode1:~# pkg set-publisher -G '*' -M '*' -g file:///var/share/pkg/repositories solaris
root@solnode1:~#

root@solnode1:~# pkg publisher
PUBLISHER                   TYPE     STATUS P LOCATION
solaris                     origin   online F file:///var/share/pkg/repositories/
root@solnode1:~#

To enable clients to access the local repository via HTTP, enable the application/pkg/server Service Management Facility (SMF) service.

root@solnode1:~# svccfg -s application/pkg/server setprop pkg/inst_root=/var/share/pkg/repositories
root@solnode1:~# 

check does repos work
root@solnode1:~# svcprop -p pkg/inst_root application/pkg/server
/var/share/pkg/repositories
root@solnode1:~#

Reload the pkg.depotd repository service.

root@solnode1:~# svcadm refresh application/pkg/server
root@solnode1:~#

we had successfully created solaris 11.2 local repository.

Saturday, 8 August 2015

Contiguous space re-partition - Linux

To recap, root FS has run out of space and data contained on it couldn't be removed or compressed to free up the space. Since there was swap space, so I planned to reclaim from the swap partition without losing the data and would extend the space for root file system. 

Host : susenode2
OS   : SuSE 11 / CentOS / Redhat 
Disk : sda

It could have been easy we could have extended volume using LVM, since our disks are not under LVM, we are here trying to re-create the entire partition without losing data.

Current scenario :

Disk (sda) is been into 3 partitons, of which sda1, sda2 are my data partitions & sda3 swap partition. I would recreate the swap partition and would extend the root file system. It could also be seen that the sector are contiguous between sda2 and sda3 hence I could destroy those two partitions and re-create.

df & fdisk & swap output :

susenode2:~ # df -hT
Filesystem     Type   Size  Used Avail Use% Mounted on
/dev/sda2      ext3    13G   12G  570M  96% /
udev           tmpfs  369M  128K  369M   1% /dev
tmpfs          tmpfs  369M     0  369M   0% /dev/shm
/dev/sda1      ext3   1.1G 1015M   18M  99% /application/logs
susenode2:~ #

susenode2:~ # fdisk -l /dev/sda

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cc8af

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048     2265087     1131520   83  Linux
/dev/sda2   *     2265088    31625215    14680064   83  Linux                  <<===  root fs
/dev/sda3        31625216    41943039     5158912   82  Linux swap / Solaris   <<===  swap 
susenode2:~ #

susenode2:~ # swapon -s
Filename                                Type            Size    Used    Priority
/dev/sda3                               partition       5158908 0       -1
susenode2:~ #

Since we are resizing the root file system, we need to get into rescue environment to do so. 
I am using an SuSE DVD or you could also use knoppix and would get into rescue environment and make necessary changes to the partition table. 


I would delete the partition sda2 and sda3 and would recreate the sda2 from the sector which was at the start i..e 2265088 and would end for my required size say 18G which I would add to this file system.

I would later create a new partition for the swap for remaining space. 

snaps are as below :


Once partition are created we need to change the type of the partition to swap for sda3 and since sda2 was bootable, make sure you would toggle boot flag on the partition.


Make sure you now has enough space in the disk where you could resize your root file system and make the swap partition. 


Rescue:~ # mkswap /dev/sda3
Rescue:~ # reboot

After reboot, check your root file system space. It would have been increased and swap space decreased. 

Snap after increasing file system :

susenode2:~ # df -hT
Filesystem     Type   Size  Used Avail Use% Mounted on
/dev/sda2      ext3    18G   12G  5.3G  69% /
udev           tmpfs  369M  128K  369M   1% /dev
tmpfs          tmpfs  369M     0  369M   0% /dev/shm
/dev/sda1      ext3   1.1G 1015M   18M  99% /application/logs
susenode2:~ #

susenode2:~ # fdisk -l /dev/sda

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cc8af

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048     2265087     1131520   83  Linux
/dev/sda2   *     2265088    40013823    18874368   83  Linux
/dev/sda3        40013824    41943039      964608   82  Linux swap / Solaris
susenode2:~ #

susenode2:~ # swapon -s
Filename                                Type            Size    Used    Priority
/dev/sda3                               partition       964604  0       -1
susenode2:~ #

Thanks

Sunday, 26 July 2015

speedtest mini : check your internet speed locally - CentOS 7

speedtest.net is one of the most popular internet speed tests. It is very helpful if you want to determine your Internet download and upload speed similarly speedtest-mini can be performed on local server. 

Install your apache, PHP,  start httpd service and make sure 'httpd' service is allowed by your firewall. 

#yum install -y httpd php php-mysql php-gd php-mcrypt
#systemctl start httpd
#firewall-cmd --add-service=http 

Download "speedtest mini" from speedtest.net from their official site : 
#cd /var/www/html

Register to speedtest.net and download the latest version of mini. 
#unzip mini.zip

Make sure your apache doccument root is in /var/www/html
# grep -i "^documentroot" /etc/httpd/conf/httpd.conf
DocumentRoot "/var/www/html"
#cd /var/www/html/mini
#mv index-php.html index.html

point your browser to http://<ipaddress>/mini and start testing your speed on the local servers. 

Thanks

Wednesday, 8 July 2015

Configure Network Teaming - RHEL 7

Network teaming is method for linking NIC's together logically to allow for failover or higher throughput. 

RHEL 7 implements network teaming with a small kernel driver and a user space daemon, teamd. The kernel handles network packets efficiently and teamd handles logic and interface processing. Software, called runners, implement load balancing and active-backup logic, such as roundrobin. The following runners are available to teamd:

- broadcast : a simple runner transmits each packet from all ports

- roundrobin : simple runner which transmits packets in a rounf-robin fashion from each port

- activebackup : failover runner which watches for link changes and selects an active port for data transfers

- loadbalance : this runner monitors traffic and uses a hash function to try to reach a perfect balance when selecting ports for packet transmission.

- lacp : implements the 802.3ad Link aggregation control protocol. can use the same transmit port selection possibilities as the loadbalance runner.

Steps:

- Create team interface 
- Assigning the IPv4 or IPv6 attributes of the team interface
- Assign the port interfaces
- Bring the team and port interfaces up/down

Current existing network interfaces are beow, "eno33554984" and "eno50332208" will be the interfaces that will be the ports for the teamed interface.

# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:14:ef:0e brd ff:ff:ff:ff:ff:ff
3: eno33554984: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:14:ef:18 brd ff:ff:ff:ff:ff:ff
4: eno50332208: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:14:ef:22 brd ff:ff:ff:ff:ff:ff
#

- Create team interface:
# nmcli connection add type team con-name team0 ifname team0 config '{"runner": {"name": "activebackup"}}'
Connection 'team0' (b781d554-6d28-4baa-9af8-5f3331acd427) successfully added.
#

'{"runner": {"name": "activebackup"}}' - In this setup i'm using method 'activebackup' 

- Assign IPv4 attributes to team interface.
# nmcli connection modify team0 ipv4.addresses '192.168.229.181/24'
# nmcli connection modify team0 ipv4.method manual

- assign the port interfaces
# nmcli connection add type team-slave con-name team0-port1 ifname eno33554984 master team0
Connection 'team0-port1' (d7ae4a56-4872-4264-8f2f-215742deae92) successfully added.
# nmcli connection add type team-slave con-name team0-port2 ifname eno50332208 master team0
Connection 'team0-port2' (c6755f4b-8071-4294-b3d5-691da53cf264) successfully added.
#

- check the current state of teamed interfaces. 
# ip a show team0
7: team0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
    link/ether 00:0c:29:14:ef:18 brd ff:ff:ff:ff:ff:ff
    inet 192.168.229.181/24 brd 192.168.229.255 scope global team0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe14:ef18/64 scope link
       valid_lft forever preferred_lft forever
#

# teamdctl team0 state
setup:
  runner: activebackup
ports:
  eno33554984
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
  eno50332208
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
runner:
  active port: eno33554984
#

Ping from your network gateway through the 'team0' interface, and when the 'eno33554984' || 'eno50332208' have been disconnected, you still have no interruptions in the PING. 

how to disconnect one of the interface:
#nmcli device disconnect eno33554984
#teamdctl team0 state
#nmcli device connect eno33554984

- Display team ports of the team0 interface
# teamnl team0 ports

- Display the active port
# teamnl team0 getoption activeport

Thanks

Thursday, 2 July 2015

Install and configure Git - CentOS 7

In this article i'll try to explain how to install, configure and use Git.

Environment: CentOS 7
Git version: 1.8.3.1

Git is a distribute version control system used by developers, but since it can also store .files(files with '.') system admin's can use to store their customized configurations files like .bashrc, .vimrc or other important scripts ..etc

Git takes a snapshot of how the files look at that instant in time and will store a reference to it. It wouldn't matter to Git what data you insert as it will check-sum it using SHA1 algorithm and create 40-character hex key. Git is based on key-value data system.

- Install Git by using 'yum' 

#yum install git -y

# git --version
git version 1.8.3.1
#

I already have a Git account registered if you don't have, signup to http://www.github.com and complete your registration. create your first repository by '+' 
NOTE: repository name you choose or the directory name which you create should be the alike. Git usually sync the directory or the files from your laptop or desktop to the one having the same name as in the GitHub.

 


setup your name and e-mail (similar email ID that you used to create GitHub account) on your local laptop or desktop which must be run very first time inorder to setup Git.

sunilka@centos7]$ git config --global user.name "sunilka"
sunilka@centos7]$ git config --global user.email "sunilka@gmail.com"
sunilka@centos7]$ git config --list

Create a directory and initialize Git by running git init, after that you have .git created with few files and directory under it. According to Git it's now been the working tree. now, everything under it can be uploaded to GitHub.

sunilka@centos7]$ mkdir configs
sunilka@centos7]$ cd configs; git init
sunilka@centos7]$ ls -ld .git

few files were been created and added into the directory, the moment we added the files into Git it creates a hash checksum and refers it by checksum.

sunilka@centos7 configs]$ git ls-files --stage
100755 af7ec7a5b7b361c10dcbf3db7286f97ef7df57d6 0       ks.cfg
100755 3e84972fcf7f688f98999d1bd5c38eaf250efcc9 0       ks_centos7.cfg
sunilka@centos7 configs]$

Now, lest pust to Gitgub which is our remote repository. first check you have remote repository already existing there
sunilka@centos7 configs]$ git remote -v
sunilka@centos7 configs]$ 

add the remote repository, URL which you had while creating the repository.
sunilka@centos7 configs]$ git remote add origin https://github.com/sunilka/configs.git

sunilka@centos7 configs]$  git remote -v
sunilka@centos7 configs]$ 

where, 
      git remote add - add remote directory to Git
              origin - default name of the remote location

Push the file to GitHub using, use the same username and password which you use to create and access your GitHub account.
sunilka@centos7 configs]$ git push origin master

any changes made to the files, must be committed before Git push. 

sunilka@centos7 configs]$ git commit -m "CentOS 7 kickstart file" ks_centos7.cfg
[master 08632bb] CentOS 7 kickstart file
 1 file changed, 1 deletion(-)
sunilka@centos7 configs]$ git commit -m "CentOS 6 kickstart file" ks.cfg
[master 498a0ca] CentOS 6 kickstart file
 1 file changed, 2 deletions(-)
sunilka@centos7 configs]$ 

sunilka@centos7 configs]$ git push origin master
.
.
Counting objects: 9, done.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 591 bytes | 0 bytes/s, done.
Total 6 (delta 2), reused 0 (delta 0)
   57a7eb3..498a0ca  master -> master
sunilka@centos7 configs]$ 

Take a look at your GitHub page, it should have been uploaded. 











you can make a localcopy from your GitHub account using the clone feature

sunilka@centos7 configs]$ mkdir gitclones
sunilka@centos7 configs]$ cd gitclones/
sunilka@centos7 gitclones]$ git clone https://github.com/sunilka/configs.git
Cloning into 'configs'...
remote: Counting objects: 10, done.
remote: Total 10 (delta 0), reused 0 (delta 0), pack-reused 10
Unpacking objects: 100% (10/10), done.
sunilka@centos7 gitclones]$ ls
configs
sunilka@centos7 gitclones]$ ls configs/
ks_centos7.cfg  ks.cfg
sunilka@centos7 gitclones]$

you have same files are in your GitHub repository. 

Thursday, 11 June 2015

Kernel up-gradation on OpenSUSE(13.2) to latest kernel (4.1)

OpenSUSE 13.2 had it's kernel version 3.16.6-2, I have upgraded the latest kernel version 4.1.0-rc7-1. 

Below are the steps involved :

1. Make sure you retain multiple kernel configurations in /etc/zypp/zypp.conf which includes the oldest. 
2. Add kernel HEAD repository and perform distribution upgrade from kernel HEAD repository.
3. Reboot the system.

# tail -2 /etc/zypp/zypp.conf
multiversion = provides:multiversion(kernel)
multiversion.kernels = latest,latest-1,running,oldest
#

Adding repository 'kernel-repo' ..................................................................................................................................[done]
Repository 'kernel-repo' successfully added
Enabled: Yes
Autorefresh: Yes
GPG check: Yes
#

# zypper lr kernel-repo
Alias          : kernel-repo
Name           : kernel-repo
Enabled        : Yes
Priority       : 99
Auto-refresh   : On
Keep Packages  : Off
Type           : NONE
GPG Check      : On
GPG Key URI    :
Path Prefix    :
Parent Service :
Repo Info Path : /etc/zypp/repos.d/kernel-repo.repo
MD Cache Path  : /var/cache/zypp/raw/kernel-repo
#

# zypper dist-upgrade -r kernel-repo
Retrieving repository 'kernel-repo' metadata ------------------------------------------------------------------------------------------------------------------------[\]

New repository or package signing key received:

  Repository:       kernel-repo
  Key Name:         Kernel OBS Project <Kernel@build.opensuse.org>
  Key Fingerprint:  4529410A B52F94C4 03BAB484 ECEEF210 03579C1D
  Key Created:      Wed Apr 22 17:55:51 2015
  Key Expires:      Fri Jun 30 17:55:51 2017
  Rpm Name:         gpg-pubkey-03579c1d-5537934f


Do you want to reject the key, trust temporarily, or trust always? [r/t/a/? shows all options] (r): a
Retrieving repository 'kernel-repo' metadata .....................................................................................................................[done]
Building repository 'kernel-repo' cache ..........................................................................................................................[done]
Loading repository data...
Reading installed packages...
Computing distribution upgrade...

The following NEW package is going to be installed:
  kernel-desktop-4.1.rc7-1.1.gabe587d

1 new package to install.
Overall download size: 48.1 MiB. Already cached: 0 B  After the operation, additional 221.3 MiB will be used.
Continue? [y/n/? shows all options] (y): y
Retrieving package kernel-desktop-4.1.rc7-1.1.gabe587d.x86_64                                                                      (1/1),  48.1 MiB (221.3 MiB unpacked)
Retrieving: kernel-desktop-4.1.rc7-1.1.gabe587d.x86_64.rpm .........................................................................................[done (365.2 KiB/s)]
Checking for file conflicts: .....................................................................................................................................[done]
(1/1) Installing: kernel-desktop-4.1.rc7-1.1.gabe587d ............................................................................................................[done]
Additional rpm output:
Creating initrd: /boot/initrd-4.1.0-rc7-1.gabe587d-desktop
Executing: /usr/bin/dracut --logfile /var/log/YaST2/mkinitrd.log --force /boot/initrd-4.1.0-rc7-1.gabe587d-desktop 4.1.0-rc7-1.gabe587d-desktop
*** Including module: bash ***
*** Including module: warpclock ***
*** Including module: i18n ***
*** Including module: ifcfg ***
*** Including module: drm ***
*** Including module: plymouth ***
*** Including module: btrfs ***
*** Including module: kernel-modules ***
Omitting driver i2o_scsi
*** Including module: resume ***
*** Including module: rootfs-block ***
*** Including module: terminfo ***
*** Including module: udev-rules ***
Skipping udev rule: 91-permissions.rules
Skipping udev rule: 80-drivers-modprobe.rules
*** Including module: systemd ***
*** Including module: usrmount ***
*** Including module: base ***
*** Including module: fs-lib ***
*** Including module: shutdown ***
*** Including module: suse ***
*** Including modules done ***
*** Installing kernel module dependencies and firmware ***
*** Installing kernel module dependencies and firmware done ***
*** Resolving executable dependencies ***
*** Resolving executable dependencies done***
*** Hardlinking files ***
*** Hardlinking files done ***
*** Stripping files ***
*** Stripping files done ***
*** Generating early-microcode cpio image ***
*** Store current command line parameters ***
Stored kernel commandline:
 resume=UUID=963537e9-1bf1-49de-b90c-6227ade69572
root=UUID=940ff654-d7da-43f3-a4c6-ed18ecbb231f rootflags=rw,relatime,space_cache rootfstype=btrfs
*** Creating image file ***
*** Creating image file done ***
Update bootloader...
#
- Finally, reboot is required and you would boot up in the latest Linux Kernel 4.1.
# uname -r
4.1.0-rc7-1.gabe587d-desktop
#

Wednesday, 10 June 2015

Glances - Max information in Minimum space #CentOS 7

Glances is a cross-platform curses-based system monitoring tool which aims to present a maximum of information in a minimum of space.It can adapt dynamically the displayed information depending on the terminal size.

Glances is written in Python and uses the psutil library to get information from your system.

Environment : CentOS 7
Installation 
Actually, package exists for CentOS in EPEL repository and install using your favorite package managers. 

#yum install epel-release
#yum install -y glances.noarch

I found this utility very useful as I don't have to type multiple commands to monitor the system, instead all data would be displayed in one single screen, 

CPU information (user, system, and idle programs )
Memory & Swap information 
CPU load for 1min, 5min, 15mins
Total number of process currently running 
Network download/uploads of network connections
Disk read/write speed
Disk usages
Date and time at the right bottom


You can press 'h' hot keys for fine tuning. 


If any one are more interested to know on this utility  here it is, http://glances.readthedocs.org/en/latest/

Simple utility to capture all the data in one screen.