Sunday, February 26, 2017

zone: error: net0: failed to create VNIC: operation not supported

In this post, I will discuss with you one of the most interesting error which I am facing when I boot the local zone on Solaris 11.3. The description of this interesting issue as describe below.

Description of error:

sun# zoneadm -z sun01 boot

zone 'sun01': error: net0: failed to create VNIC: operation not supported

zoneadm: zone sun01: call to zoneadmd(1M) failed: zoneadmd(1M

I have try to create and configure the  VNIC on Solaris 11.3 operating server but it get failed with the same error.

sun#dladm create-vnic -l net0 vnic01

dladm: vnic creation failed: operation not supported

If you are also facing a such error while booting the local zone on solaris 11 server, then please use the below solution to resolve such issues.

Solution of error:

1. This error "failed to create VNIC: operation not supported" would normally come when there are not enough mac addresses to assign to the zone. So now we need to add alternate mac addresses to the network interface.So before adding the new mac address we will stop LDM.

sun#ldm list-domain

NAME            STATE     FLAGS  CONS   VCPU MEMORY  UTIL NORM UPTIME

primary         active    -n-cv- UART   8    8G      2.0% 2.0% 41d 20h 14m

0004fb0000060000ff1d3d8336112f6f active    -n---- 5001   50   64G     0.1% 0.1% 18h 23m

2. Now log in to the Solaris global zone and check if net0 have additional MAC addresses or not. Please use the below command to check the status.

sun# dladm show-phys -m

LINK               SLOT    ADDRESS           INUSE CLIENT

net0               primary 0:21:f6:d6:d3:e5  yes  net0

                   1       0:14:4f:f9:6d:8d  no   --

                   2       0:14:4f:fb:10:2b  no   --

                   3       0:14:4f:f9:41:d6  no   --

                   4       0:14:4f:f8:dd:c8  no   --

net1               primary 0:21:f6:51:be:4d  yes  net1

3. Now zone will start without any issue, as we have assigned the new mac address to this zone.

sun# zoneadm -z sun01 start

Hope, your issue related to this has been resolved after reading my post. Please let me know if you are facing any issue regarding this error.

How to create whole root zone on Solaris 11

In this post we will see how to install  zone on Solaris 11. In my last post regarding the zone creation you see the zone creation steps about Solaris 10.

Before going to main installation part we need to understand the basic installation methods difference between Solaris 10 & Solaris 11. 

In Solaris 10, we can’t install it without configuring repo on Solaris while in Solaris 11 ,first we need to create a  Solaris 11 repo , then we can install Solaris local zone. In Solaris 11, all the local zones by default uses exclusive ip address. You can’t set the IP address while configuring the zone. After the installation of zone, you can able to configure the IP from the local zone itself.

On my Solaris 11 machine I have already installed one local zone which is used for my R&D work so for this post work I need to install second local zone. So I will clone it from the first local zone.

Step by step method to create a zone on Solaris 11:-

1. In the first step we will create a new local zone. For the zone creation we will used "zonecfg" command and configure the zones as whole root zone without any options supplied.

#zonecfg -z sun02
sun02: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:sun> create
zonecfg:sun> info
zonename: sun02
zonepath:
brand: native
autoboot: false
bootargs:
pool:
limitpriv:
scheduling-class:
ip-type: shared
hostid:
zonecfg:sun> set zonepath=/zones/sun02
zonecfg:sun > add anet
zonecfg:sun:anet> set linkname=net0
zonecfg:sun:anet> end
zonecfg:sun > verfiy
zonecfg:sun > commit
zonecfg:sun > exit

In the above step, we will create a zne and set the zonepath. In my case my new solaris zone path is "/zones/sun02" in your case you can change your installation zone path. Here, I assign the network interface "net0" for this newly zone.

2. After successfully zone creation in above step 1, we will go for start the Solaris zone installation in this step. As I explained you for solaris 11 local zone installation we required solaris 11 repo which is used for installation part.

sun#zoneadm -z sun02 install
The following ZFS file system(s) have been created:
    rpool/zones/sun02
Progress being logged to /var/log/zones/zoneadm.30220110Z233232Z.sun02.install
       Image: Preparing at /zones/sun02/root.
 AI Manifest: /tmp/manifest.xml.F_ayqq
  SC Profile: /usr/share/auto_install/sc_profiles/enable_sci.xml
    Zonename: sun02
Installation: Starting ...
              Creating IPS image
Startup linked: 1/1 done
        Installing packages from:
solaris  origin:  http://localhost:1008/solaris/ce43f14c4791b5320596e2023cde1ec08709a3af/

DOWNLOAD                                PKGS         FILES    XFER (MB)   SPEED
Completed                            183/183   33556/33556  222.2/222.2  139k/s

PHASE                                          ITEMS
Installing new actions                   46825/46825
Updating package state database               Done
Updating image state                          Done
Creating fast lookup database                 Done
Installation: Succeeded

Note:Man pages can be obtained by installing pkg:/system/manual done. Done: Installation completed in 2392.837 seconds.

Now our newly zone "sun02" has been installed successfully. All the configuration files are keep in /zones/sun02/root directory.

3. In this step we will boot the newly installed zone "sun02".

sun#zoneadm -z sun02 boot

You can check the status of zone that it is running or not after boot.

sun#zoneadm list -icv
ID NAME      STATUS     PATH          BRAND    IP
   0 global   running    /            solaris  shared
   1 sun01    running    /zones/sun01 solaris  excl
   3 sun02    running    /zones/sun02 solaris  excl

if you see the above output newly zone "sun02" is running working fine on the solaris 11 operating system.

4. Now in the next step, we will login on the local zone console to complete the configuration process.

sun# zlogin -C sun02
[Connected to zone 'sun02' console]

You can press enter when you will get this message. Now it is asking for some configuration step we need to give a details one by one.

Time Zone: Regions
select the region that contains your time zone.
Regions
UTC/GMT
Africa
Americas
Antarctica
Arctic Ocean
Asia
Atlantic Ocean
Australia
Europe
Indian Ocean
Pacific Ocean
F2_Continue  F3_Back  F6_Help  F9_Quit

Time Zone: Locations
Select the location that contains your time zone.
Locations
x Afghanistan
x Armenia
x Azerbaijan
x Bahrain
x Bangladesh
x Bhutan
x Brunei
x Cambodia
x China
x Cyprus
x East Timor
x Georgia
x Hong Kong
v India
F2_Continue  F3_Back  F6_Help  F9_Quit

Time Zone
Select your time zone.
Time Zones
Asia/Kolkata

F2_Continue  F3_Back  F6_Help  F9_Quit

System Configuration Summary
Review the settings below before continuing. Go back (F3) to make changes.

Time Zone: Asia/Kolkata
Language: *The following can be changed when logging in.
Default language: C/POSIX
Terminal type: vt100

Users:
No user account

Network:
Computer name: sun02
Network Configuration: Automatic

Support configuration:
Not generating a Support profile as OCM and ASR services are not installed.
Hostname: sun02

So now your zone is fully configured ans installed successfully. You can login in zone very easily. So in next step we will see the post configuration settings which is required on local solaris zone.

5. In the final step you need login to local zone sun02 and configured the ip address on the zone sun02.

sun#zlogin -z sun02

You can successfully login in your newly created solaris 11 zone. Please leave a comment if you have any doubt ,i will get back to you as soon as possible.

How to Create VNIC and Assign a IP Address on Solaris 11

Hello Friends,

In my old post, I described that how we will create a new local solaris zone on global zone. As you know every zone has their own networking but how it is works and configured we need to understand, So in this post, I will explain to you how to create a virtual network on Solaris 11 before zone creation.

For creating Virtual NIC and assigning fix static IP address in Solaris 11 we need to understand the basic difference between older version of Solaris and Solaris 11.

In Solaris 10, according to the NIC manufacturer,physical network interfaces are named as (Ex:bge,e1000g,nxge).But in Solaris 11 onwards,the names are hidden from the view and all the interfaces will be named as net0,net1…netx.

Before forward to main work we need to know that using which command we can check which interface has been mapped to physical interface. Using below command you can check all the network interface details.

sun01# dladm show-phys
LINK              MEDIA                STATE      SPEED  DUPLEX    DEVICE
net0              Ethernet             up         1000   full      bge001
net1              Ethernet             up         1000   full      bge002

If you want to show all dladm level devices,including VNIC’s & aggregation links,use the below command-

sun01# dladm show-link
LINK                CLASS     MTU    STATE    OVER
net0                phys      1500   up       --
net1                phys      1500   up       --

In Solaris 11,you can give a meaning full description(net1/oracle_VIP) to all the IP address on the system unlike Solaris 10. (e1000g1:2)

How to assigning new IP address to NIC:-

1. We can see how we assigned IP address to the physical interface, so in the first step we will check all the physical interface using below command.

sun01# dladm show-phys
LINK              MEDIA                STATE      SPEED  DUPLEX    DEVICE
net0              Ethernet             up         1000   full      bge001
net1              Ethernet             up         1000   full      bge002

2. In this step we would know how we will create a new interface so you can use the below command for this.

sun01# ipadm create-ip net1

3. This is the main step to assign the static ip address to the newly created interface net1. You can use below command or syntax to assign the fixed IP.

sun01#ipadm create-addr -T static -a local=10.135.0.2/24 net1

You can change your IP address accordingly. 

4. Now we will Verify whether IP address is configured or not which we assigned on above step.

sun01# ifconfig  net1
net1: flags=1000843 mtu 1500 index 7
        inet 10.135.0.2 netmask ffffff00 broadcast 10.135.0.255
        ether 0a:cB:12:8e:15:e2

If you see the above output, the new IP address is shown on net1 interface successfully. Using above all 4 steps you can know how we will assinged the static ip address to the sun solaris 11 operating system.

Now we will go for Virtual Network Interface creation steps.I can create N number of VNIC’s using single physical interface.These VNIC are treated as actual physical interface and possible to assign to local zones with  full access to it.

How to create a new VNIC using interface net2:-

1. In the initial steps I will run the same command to check out the all physical interface which is available on the Solaris 11 Server.

sun01# dladm show-phys
LINK              MEDIA                STATE      SPEED  DUPLEX    DEVICE
net0              Ethernet             up         1000   full      bge001
net1              Ethernet             up         1000   full      bge002
net2              Ethernet             unknown    1000   full      bge003

If you see the above command output network interface "net2" is in unknow state, So in the next step I will create a new VNIC using net2.

2. In this step we will create a new VNIC using net2. In my case i will suppose VNIC name “vnic01”, so for creating the new VNIC we will run the below command which describe below.

sun01#dladm create-vnic  -l net2 vnic01

3.Now, We will plumb the virtual interface and create a default IP to new VNIC.

sun01# dladm create-vnic  -l net2 vnic01
sun01# ipadm create-ip vnic01
sun01# ifconfig vnic01
vnic01: flags=1000842 mtu 1500 index 8
        inet 0.0.0.0 netmask 0
        ether 2c:18:10:Ce:1a:12

4. Now we will assign the new IP address to VNIC and verfif that new IP for vnic01 is configured or not.

sun01# ipadm create-addr -T static -a local=10.135.0.3/24 vnic01
sun01# ifconfig vnic01
vnic01: flags=1000843 mtu 1500 index 8
        inet 10.135.0.3 netmask ffffff00 broadcast 10.135.0.255
        ether 2c:18:10:Ce:1a:12

5. In the final step we will try to run snoop on VNIC which we have create now. You can verify through snooping is that VNIC01 is working fine or not.

sun01# snoop -d vnic01

The same way you can create a multiple VNIC and assign a new IP address to it. Hope you got some idea about Solaris 11 networking part after reading this post. Please let me know if you have any doubt regarding this post.

Thursday, February 23, 2017

Sun Solaris File System Management

If you are working on Sun Solaris operating system and wants to more grow up on this operating system, you definitely like my post because in this post I will explain you the most important thing file system management.

I will describe all the file systems command in this post which is generally used on all Solaris version operating system. Using these command you are more familiar about the file system management on Solaris server.

How to create a new file system on Solaris Server:-

We are using two type of file system (UFS & ZFS) on Solaris operating system. In this example we are taking UFS file system as for ZFS file system creation information you can found in my older post.

  • Create a new file system-
          sun01#newfs /dev/rdsk/c0d0s1
  • View minfree value-
          sun01#fstyp -v /dev/rdsk/c0d0s1 | head
  • Set minfree value for a new file system-
          sun01#newfs -m 2 /dev/dsk/c0d0s1
  • Change minfree value on an existing file system-
          sun01#tunefs -m 1 /dev/rdsk/c0d0s1

In the above my example, my hard disk name is c0d0s1.

How to Monitoring File System Usage on Solaris Server:-

In Sun Solaris Server , you must be aware about the capacity of file system. You can check file system usage using several commands.
  • Display the capacity of file systems in readable format-
          sun01#df -h
  • Display the disk allocation size in Kbytes-
         sun01#df -k
  • Display the available space on a device or disk-
         sun01#df -k /dev/dsk/c0d0s1
  • Display the disk usage in readable format-
          sun01#du -h /home
  • Display the disk usage including files-
          sun01#du -ak /home
  • Display the disk usage in summary format-
          sun01#du -sk /home

How to Checking or repair the File System on Solaris Server:-

We can repair and check the file system on Sun Solaris server. You can use the "fsck" command for this one but make sure you never run the fsck command on a mounted file system. You need umount file system first then run repair or check the Solaris file system.

  • Check or repair an unmounted filesystem-
           sun01#fsck /dev/rdsk/c0d0s1
  • Check or repair using the mount point directory-
          sun01#fsck /export/home 
  • To use a backup superblock number on Solaris server-
          sun01#fsck -o b=32 /dev/rdsk/c0d0s1 
  • To use an alternative superblock number-
          sun01#fsck -o b=518432 /dev/rdsk/c0d0s1

Hope, you are like my this post. Please comment on the post if you are facing any issue. I will try to resolve your issue as soon as possible.

How to change a disk in SVM Solaris volume manager

Hope you are doing well at your end. This post documentation explain how to change a disk in SVM ( Solaris volume manager).It means that we have mirrored the disk (RAID1) using SVM. Solaris Volume manager is basically used for creating, modifying & partitioning the different RAID partition.

In this post, I will take my sparc server machine. My Sun Sparc server consist 2 hard disk, let us assume the server has 2 hard disk: c0t0d0 and c0t1d0. We will assume c0t0d0 failed and need to be replaced.

Step by Step Method as described below:

1. In the initial step, we will find that which hard disk is down or faulty. To check this we will used "format" command.

sun01# format
       0. c0t0d0 <__drive type unknown__>
          /pci@0,600000/pci@0/pci@8/pci@0/scsi@1/sd@0,0
       1. c0t1d0 <SUN146G cyl 14087 alt 2 hd 24 sec 848>
          /pci@0,600000/pci@0/pci@8/pci@0/scsi@1/sd@1,0

If you see the "format" command output, we have two disk "c0t0d0,c0t1d0". Disk "c0t0d0" is in faulty state and it's down, You can see the drive type is in unknown state.

2. If you are running the "metastat" command you can see the status of hard disk which is show status in "need maintenance".

sun01# metastat    # will show status in "need maintenance"

        flags           first blk       block count
     a        u         16              8192            /dev/dsk/c0t0d0s7
     a        u         8208            8192            /dev/dsk/c0t0d0s7
     a    p  luo        16              8192            /dev/dsk/c0t1d0s7
     a    p  luo        8208            8192            /dev/dsk/c0t1d0s7

sun01# metadb -d c0t0d0s7
sun01# metadb

Using above command we delete metadb on failing disk and check that metadb on the other disk.

4. Now, we will unconfigure the corresponding disk which is down right now. This is the main step of this post so you can more careful while running the command which is given below.

sun01# cfgadm -al
sun01# cfgadm -f -c unconfigure c0::dsk/c0t0d0
sun01# cfgadm -al

Using cfgadm command we will unconfigure the c0t0d0 faulty hard disk so that we will replace the down hard disk in next step.

5. Now you can change the faulty disk to new one and reconfigure it again with same name.

sun01# cfgadm -c configure c0::dsk/c0t0d0
sun01# cfgadm -al

6. In this steo we will duplicate partitionning schema of first disk to the second and create metadb.

sun01# prtvtoc /dev/rdsk/c0t1d0s2 | fmthard -s - /dev/rdsk/c0t0d0s2
sun01# metadb -a -f -c2 /dev/dsk/c0t0d0s7

7. In second last step you will run all the below command for replacement of the failinf SVM partition.

sun01# metastat
sun01# metareplace -ef d4 c0t0d0s4
sun01# metareplace -ef d3 c0t0d0s3
sun01# metareplace -ef d1 c0t0d0s1
sun01# metareplace -ef d0 c0t0d0s0
sun01# metareplace -ef d5 c0t0d0s5
sun01# metareplace -ef d6 c0t0d0s6
sun01# metasync d0
sun01# metasync d1
sun01# metasync d3
sun01# metasync d4
sun01# metasync d5
sun01# metasync d6
sun01# metasync d7

8. In final step you need to make the disk bootable so that operating system will be boot on the mirror disk.

sun01# installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0t0d0s0

Using this step you can make a disk bootable. I hope this post is useful for you. You are requested to please comment on the post if you have any issue, I will try to back you with my answer.

How to Remove a Non-Global Zone from Solaris Server

In this post, I will explain to you how to remove a Non-Global Zone from Solaris Server.

As you aware that Non-Global zone are hosted on Global zone on Solaris Operating system. You can check the Non-Global zone list using "zoneadm" command. It will show you are running and installed zones on Global zones.

Step by Step Method of removal a Non-Global Zone:

First of all you need to check the Non-Global Zone list to ensure which zone is running on the server.

global# zoneadm list -iv

You will see a display that is similar to the following:

ID  NAME     STATUS       PATH                           BRAND      IP
 0    global       running         /                                   solaris    shared
 1    sun01       running         /zones/sun01                solaris    shared

In the above command output you can see the Non-Global Zone "sun01" is running, which we need to remove or delete from Solaris Server.

Now, we need to shutdown the required zone which we need to delete. We can shutdown the Non-Global zone using below commands.
--------------------------------------------
global#zoneadm -z sun01 halt
or
global#zoneadm -z sun01 shutdown
or
global#zlogin sun01 shutdown
-------------------------------------------
In next step when your Non-Global zone shutdown you need to uninstall the local zone. You can used the below method to uninstall the Non-Global Zone.

global#zoneadm -z sun01 uninstall

Using above command Non-Global zone "sun01" has been uninstall successfully.

In the last step you need to remove or delete all dataset and configuration files of Non-Global zone "sun01" from Global zone.

global#zonecfg -z sun01 delete

Using above command all the configuration files related to this Non-Global zone has been deleted successfully. Now you can remove the folder related to this zone.

So using above method we can remove or delete the Non-Global zone from global zone or Solaris Operating system. Please let me know if you are facing any issue during using this process.

Monday, February 20, 2017

How to Reset Root Password in HP-UX Operating System

In this article, We will learn how to recover or reset the root password in HP-UX operating system.

If you lost the root password on system running on HP-UX operating system, Please follow the below procedure step by step.

1. In the first step, please power on the HP-UX machine and boot the server into single user mode.

To boot the server in single user mode their is several way. Please find the simple way as described below.

Selecting a system to boot. To stop selection process, press and hold the ESCAPE key

Auto boot from primary boot path enabled. To override, press any key within 10 seconds.

Type boot pri isl at the prompt:
boot pri

At the ISL> prompt:, type
hpux -is /stand/vmunix

OR

hpux -is

Here, In above example, the -i option is used to make the system come up in run-level s, for single user mode of operation.

2. In second step while system booting into single user mode you need to interrrupt while booting the server. Once you interrupt the server you will get the HP-UX prompt so you can boot it in single user mode.

hpx:/>boot -is

3. In this step , you need to mount the "/usr" file system on HP-UX operating system server.

hpx:/>mount /usr

4. If it is trusted system on HP-UX operating platform then you need to run the below command on trusted system.

hpx:/>/usr/lbin/tsconvert -r


5. Now, in this step we will reset the root password. For this process we have two method to reset the root password on HP-UX operating system.

Method 1:

hpx:/>passwd root
using above command we can normally reset the root password and set the new password.

Method 2:

hpx:/> vi /etc/passwd

null the password field for root user, so root password will be reset.

6. If root user is locked then unlock using below command.

hpx:/>/usr/lbin/modprpw -k root

7. Once server is up in runlevel 3 again u need to convert as trusted systems.

hpx:/>/usr/lbin/tsconvert

So using above method you can reset the root password on HP-UX operating system server. Please comment on the post if you are facing any issue related to this post.

How To Reset Root Password In AIX Operating System

When you will forget the root password on AIX operatings system then it is difficult to us to recover the root password again. So in this post I will explain step by step to you how to reset the root password in AIX.

Their are several ways using which we can reset the root password on AIX, here I will provide you step by step method to reset root password.

1. In the first step , You need to insert the operating system same version media disk on cd/dvd rom and power on the AIX machine.

2. When the screen of icons appears, or you hear a double beep sound from hardware of AIX, please press the F1 key repeatedly until the System Management Services menu appears.

3. Select Multiboot option from the SMS (System Management Services) menu

4. Select Install From option from multiboot screen.

5. Select the device (CD rom) that keep the AIX operating system image and then select Install.

6. Select the AIX version icon from the screen menu.

7. Please describe your current system as the system console by pressing the F1 key and then press Enter.

8. In this step you need to select the number of your preferred language and press Enter. In my case I use global language "English".

9. Once you select the language in this step you need to select Start Maintenance Mode for System Recovery by typing 3 and press Enter.

10. In the second last step you can ingnore the messages like that "select Access a Root Volume Group". 

A message displays explaining that you will not be able to return to the Installation menus without rebooting if you change the root volume group at this point.

11. Please Type 0 and press Enter.

Type the number of the appropriate volume group from the list and press Enter.

Select Access this Volume Group and start a shell by typing 1 and press Enter.

At the # (number sign) prompt, type the passwd command at the command line prompt to reset the root password.

# passwd
Changing password for "root"
root's New password: 
Enter the new password again:

12. In the final step , you need to write everything from the buffer to the hard disk and reboot the system.

sync;sync;sync;reboot

When the login screen appears, the password you set in above step 11 should now permit access to root privileges.

Hope, you like this post , using this post we can easily reset the root password in AIX operating system. If you are facing any issue please comment on this post.

How to Increase or extend the size of a Linux LVM by adding a new hard disk

Hello Friends,

This post will cover how to increase the disk space for a VMware virtual machine running Linux that is using logical volume manager (LVM). Firstly we will add a new disk to the virtual machine and then extend the original LVM over this additional space.

As there are a number of different ways to increase disk space but I have also posted simple and step by step method. Using this method I am sure you will increase the space easily.

1. First of all before adding any hard disk please run the below command to check the how much space is currently left on the VG group.

#vgdisplay 









If you see above image you can found the volume group name, in my case it is "rootvg".

2. Now run the below command to see the existing LVM disk is currently used in LVM.

#fdisk -l














You can see the above output, the /dev/sda2 hard disk is in used for existing LVM. Now you can add new hard disk on the server.

3. Once you added the new hard disk on the server to increase the size on Linux LVM, lets assume the new hard disk labelled is /dev/sdb. In this step we will need to partition the new hard disk so we can use it.

#fdisk /dev/sdb

It should show us below message to us for next selection.

root@localhost:~# fdisk /dev/sdb
Command (m for help): n

Please select the "n" for adding a new partition. Once we will select the "n" for new partition it is show to us below screen.

Command action
   e   extended
   p   primary partition (1-4)p

We will select the "p" for primary partition so we will add new had disk /dev/sdb as a primary partition.
----------------------------------------------------------------------------------------
Partition number (1-4): 1

First cylinder (1-2610, default 1): "enter"
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): "enter"
Using default value 2610
----------------------------------------------------------------------------------------
In above screen, we will select 1 for primary partition and make a default settings.

‘t’ is selected to change to a partitions system ID, in this case we change to ’1′ automatically as this is currently our only partition.
----------------------------------------------------------------------------------------
Command (m for help): t
Selected partition 1
----------------------------------------------------------------------------------------
The hex code ’8e’ was entered as this is the code for a Linux LVM which is what we want this partition to be, as we will be joining it with the original Linux LVM which is currently using /dev/sda4.
----------------------------------------------------------------------------------------
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
----------------------------------------------------------------------------------------
‘w’ is used to write the table to disk and exit, all changes that have been done will be saved and then you will be exited from fdisk.
----------------------------------------------------------------------------------------
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
----------------------------------------------------------------------------------------

By using “fdisk -l” now you will be able to see that /dev/sdb1 is listed, this is the new partition created on our newly added /dev/sdb disk.

4. Now we will create a physical volume with this newly added hard disk /dev/sdb1. For physical volume creation we will use "pvcreate" command.

#pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.

In above command output, you can see the /dev/sdb1 physical volume group has been created.

5. Now the most important steps of this post is using physical volume you can extend or create a new volume group.

If you want to extend the logical volume size of existing Volume group then please use the below command and method. 

#vgextend test /dev/sdb1

In my case my VG name is "test" so I will extend the space in existing VG "test".

If you want to create the new logical voume and want to add physical volume in new VG, please use the below command and method.

#vgcreate rootvg /dev/sdb1

In this case my new VG name is "rootvg".

So, as per my this post, you can add new hard disk in to existing volume group or newly created volume group. Using this volume group you can create or extend the Linux LVM size.

How to check Operating Systems Version is 64-bit or 32-Bit

Hello Friends,

In this post, you can see how we will check the operating system is 32 bit or 64 bit. Normally when we download any software on Unix platform they have dependency regarding the operating system version. So after following my this post you can easily get the information about the operating system version information.
When you work on Unix operating system then you must know the version of operating system. Because without getting exact version of OS, you can not install the packages on the Linux system.

Here, I mentioned the command and their output using these commands you can easily found the version of operating system. It is 32 bit or 64 bit.

Linux Operating System:

#uname –a
Linux vibhor 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

#uname  -m
x86_64

If the output has "x86_64",the environment is 64 bit.

Solaris Operating System:

#isainfo options

-v         Prints detailed information about the other options
-b         Prints the number of bits in the address space of the native instruction set.
-n         Prints the name of the native instruction set used by portable applications supported by the current version of the OS.
-k         Prints the name of the instruction set or sets that are used by the OS kernel components such as device drivers and STREAMS modules.

[vibhor]# isainfo -v

64-bit sparcv9 applications
        ima fmaf vis2 vis popc
32-bit sparc applications
        ima fmaf vis2 vis popc v8plus div32 mul32

[vibhor]# isainfo -b
64

[vibhor]#isainfo
sparcv9 sparc

The output for the above command should be sparcv9 sparc for a 64-bit operating System.

AIX Operating System:

vibhor:/> getconf -a | grep KERN
KERNEL_BITMODE:                         64

vibhor:/> bootinfo -y
64

The output of the above command should be 64 for a 64-bit hardware. The command must be executed as root.

Note: on AIX, the -y option will specify if the hardware is 32- or 64-bit mode while bootinfo -k will specify if the kernel is 32- or 64-bit (this command must be run as root).

HP-UX Operating system:
         
 hpx:/> getconf KERNEL_BITS
 64
         
The output of the above command should be 64 for a 64-bit operating system.

Friday, February 17, 2017

SQL command for MySQL database on Linux operating system

In this post, i will explain you how we will create, import, export & backup of MySQL database.

Please find the below points which is very useful to database admin on Linux operating system.

How to create new database:

CREATE DATABASE <DATABASENAME>;

e.g. CREATE DATABASE VIBHOR;

In this example I have created the "vibhor" named database, you can replace database name according to your choice.

How to create mater user with all level access to all available databases:

GRANT ALL ON *.* TO <USERNAME> IDENTIFIED BY '<PASSWORD>';
e.g. GRANT ALL ON *.* TO TESTDBUSER IDENTIFIED BY 'TESTDBUSER';

In this example I used "testdbuser" MySQL user on the server. 

How to take backup (dump) of a database:

For this command you need not to login into the database. Once you login on the database please run the below command to take a dump of server.

mysqldump --lock-all-tables -u <USERNAME> -p -h <DATABASESERVERNAME/IP ADDRESS> <DATABASENAME> > <NEWDUMPFILENAME>.sql

e.g. mysqldump --lock-all-tables -u ABC -p -h MACHINE1 VIBHOR > VIBHOR_16022017.sql

After this command you have to provide DB password only and dump will be done in the folder in which u are working currently.

How to take backup (dump) of a table's:

For this command you need not to login into the database.

mysqldump -u <USERNAME> -p <DATABASENAME> <TABLENAME> > <NEWDUMPFILENAME>.sql

e.g. mysqldump -u testdbuser -p testdb test_book > test.sql

After this command you have to provide DB password only and dump will be done in the folder in which u are working currently. for dumping multiple table use space between the table names.

How to run a database dump to another machine:

Go to the folder in which sql dump file is placed and then connect with your Database in which you want to run dump and then run below command.

source <FILENAME>.sql;

e.g source VIBHOR_16022017.sql;

How to take dump only triggers and procedure from database:

mysqldump --routines --no-create-info --no-data --no-create-db --skip-opt -u <USERNAME> -p <DATABASENAME> > <NEWDUMPFILENAME>.sql

e.g. mysqldump --routines --no-create-info --no-data --no-create-db --skip-opt -u TESTDBSUER -p VIBHOR > VIBHOR_16022017.sql

After this command you have to provide DB password only and dump will be done in the folder in which u are working currently.

How to show procedure/function code:

SHOW CREATE PROCEDURE <STORED PROCEDURE/FUNCTION NAME>\G

e.g. SHOW CREATE PROCEDURE FLIGHT_INVOICETOSAP\G;

How to increase filed width of a table attribute:

ALTER TABLE <TABLENAME> CHANGE <EXISTING_FIELD_NAME> <NEW_FIELD_NAME> <DATATYPE>(<NEW_FIELD_WIDTH>);

e.g. ALTER TABLE TRILOK CHANGE PASSENGER_NO PASSENGER_NUMBER VARCHAR(30);

field name and data type change is not recommended.

How to display all existing databases:

SHOW DATABASES;

Using this command you can show all the created database list on the Linux server.

How to display all existing tables:

SHOW TABLES; 
SHOW TABLES LIKE '<CHARACTERS>%';

Using this command you can check all the tables which is created on the database. 

How to recover a MySQL root password:

This is one of the best way to recover the MySQL root password if you forget. I always used below method to reset the root password.
  • Stop the MySQL server process.

# /etc/init.d/mysql stop
  • Start again with no grant tables.

# mysqld_safe --skip-grant-tables &
  • Login to MySQL as root. Set new password.

# mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("newrootpassword") where User='root';
mysql> flush privileges;
mysql> quit
  • Exit MySQL and restart MySQL server.

# /etc/init.d/mysql stop
# /etc/init.d/mysql start
  • Set a root password if there is on root password.

# mysqladmin -u root password newpassword
  • Update a root password.

# mysqladmin -u root -p oldpassword newpassword

How to grant privileges to a user:

If we need to provide the privileges to user we will use below two method. I will describe the step by step method for this one.

METHOD 1

Allow the user "bob" to connect to the server from localhost using the password "passwd". Login as root. Switch to the MySQL db. Give privs. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql> grant usage on *.* to bob@localhost identified by 'passwd';
mysql> flush privileges;

Give user privileges for a db. Login as root. Switch to the MySQL db. Grant privs. Update privs.

# mysql -u root -p
mysql> use mysql;
mysql>INSERT INTO user (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES ('%','databasename','username','Y','Y','Y','Y','Y','N');
mysql> flush privileges;

METHOD 2

mysql> grant all privileges on databasename.* to username@localhost;
mysql> flush privileges;

To update info already in a table.

Load a CSV file into a table:

mysql> LOAD DATA INFILE '/tmp/filename.csv' replace INTO TABLE [table name] FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (field1,field2,field3);

Dump all databases for backup:

Backup file is SQL commands to recreate all databases.

# [mysql dir]/bin/mysqldump -u root -ppassword --opt >/tmp/alldatabases.sql
Dump one database for backup.

# [mysql dir]/bin/mysqldump -u username -p password --databases databasename >/tmp/databasename.sql
Dump a table from a database.

# [mysql dir]/bin/mysqldump -c -u username -p password databasename tablename > /tmp/databasename.tablename.sql
Restore database (or database table) from backup.

# [mysql dir]/bin/mysql -u username -p password databasename < /tmp/databasename.sql
Create Table Example 1.

Using above method we can take database back very fast. I hope through this post you can easily able to create MySQL database, MySQL dump, table creation etc work.

Wednesday, February 15, 2017

How to boot AIX to Single User Mode in order to perform maintenance

In this post, I will explain to you, how do we boot AIX server to single user mode in order to perform maintenance. AIX is IPM operating system which is widely used today.

In AIX operating system we do not need to use single user mode very much, because many problems or issues require having the root file systems unmounted for repairs. 

In my post you can found the list of some issues when it's good to use single-user.

  • System boot hangs due to NFS configuration issues
  • Debug problems with entries in /etc/inittab
  • If you want to work on the system without users login to attempt.
  • If you want to work without applications starting up
Normally when we repair any file system if it is get crashed then we use "fsck" utility and their command but for this repair process the good condition is you need to unmount /tmp & /var file system.

If the system boots fine from the root volume group, then booting into single-user to repair or perform work has advantages. These advantages of this as listed below.
  • Its boots faster than Maintenance Mode.
  • It allows you to run all commands you would normally have access to in multi user.
  • Unlike maintenance mode, there is no possibility that hdisks will be renamed.

Procedure to boot AIX operating system to Single User mode: 

I will explain you two way to boot the system in single user mode which is describe below.

Standalone System (no HMC):
  • First boot system with no media in the CD/DVD drive on AIX operating system.
  • Wait until you see the options of choosing another boot list, and hear beeps on the console
  • Press 6 to start diagnostics
System using an HMC:
  • Select the LPAR in the HMC GUI
  • Select Operations -> Activate
  • In the Activate window, click the button that says "Advanced"
  • Change "Boot mode" to "Diagnostic with stored boot list"
  • Click "OK" to save that change, then "OK" again to activate.
After above steps you will get the below screen on the AIX operating system monitor. If these below message you get that's means your operating system boot process is already start.

IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM
IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM IBM

1 = SMS Menu 5 = Default Boot List
8 = Open Firmware Prompt 6 = Stored Boot List

You will see the normal AIX boot header, since you are booting from your system hard disk:

------------------------------------------------------------------------------------------------
                                Welcome to AIX.
                       boot image timestamp: 11:55 02/15
                 The current time and date: 15:35:02 02/15/2017
               number of processors: 2    size of memory: 4096MB
          boot device: /vdevice/v-scsi@70000007/disk@2300000000000000
                     kernel size: 15034876; 64 bit kernel
-----------------------------------------------------------------------------------------------

Now you will get the diagnostic license information page and their message on the screen which are describe as below. Several keys are used to control the diagnostics:
  • The Enter key continues the procedure or performs an action.
  • The Backspace key allows keying errors to be corrected.
  • The cursor keys are used to select an option.
Now, please press Enter. The next screen will show you Diagnostic Functions you can perform. On newer versions of firmware you will see Option 5 to start Single User Mode.

On older firmware you will have to go to, 3. Task selection and scroll way down and select 'Start Shell' or 'Single User Mode'

Function Selection:

1. Diagnostic Routines: This selection will test the machine hardware. Wrap plugs and other advanced functions will not be used.
2. Advanced Diagnostic Routines: This selection will test the machine hardware. Wrap plugs and other advanced functions will be used.
3. Task Selection(Diagnostics, Advanced Diagnostics, Service Aids, etc.): This selection will list the tasks supported by these procedures. Once a task is selected, a resource menu may be presented showing all resources supported by the task.
4. Resource Selection: This selection will list the resources in the system that are supported by the diagnostic programs. Once a resource is selected, a task menu will be presented showing all tasks that can be run on the resource(s).
5. Single User Mode: The system will enter single-user mode for software maintenance.

To make a selection, type the number and press Enter [1]: 5

Once you select the 5, you can find the below message on screen.

The system will now continue the boot process.  Please wait...
Saving Base Customize Data to boot disk
Starting the sync daemon
Starting the error daemon
System initialization completed.

It is asking for password , you may enter the password and login on single user mode, after login please check the mounted file system using "df" command.

If you want to exit single user mode and boot into multi user mode then you need to run the 
To exit single-user mode and boot into multiuser in RunLevel 2 use:

aix:/>telinit 2

Once you will press this command you can logout from single user mode to multi user mode. I hope you like my post and all the information which i have mention it. 

Step by Step NFS Server and Client Configuration in HP-UX

In this post, I will explain step by step method of NFS server and client configuration on HP-UX operating system. Network File System is a distriubted file system which allows a client computer to access a file system that shared on another computer’s or server's.

NFS server is configured on the server locally on attached physically disk. On my HP-UX server i will configured the NFS server and for client you can use same HP-UX operating machine or other linux machine.

We can used the below NFS server IP and client IP on my own HP-UX machine and Linux machine.

NFS Server : 10.135.0.27 and share folder /backup
NFS Client : 10.135.0.2 and mount point /home/backup

Steps involved to configure the NFS Server:

1. First we will make sure both NFS server(10.135.0.27) and client(10.135.0.2) are accessible. After that we will make an entry in /etc/hosts or Configure it in DNS to resolve the IP if you use server name instead of IP address. But in our case we will use IP address instead of name.

hpx:/>vi /etc/hosts

10.135.0.27 hpxnfsserver
10.135.0.2 hpxnfsclient

The /etc/hosts entry would we same on both server and client machine so it can be accessible to each other.


2. In second step we will identify the folder to be export from server to the client. On my HP-UX server machine, I am going to export the folder /backup.

3. Now we will change the shared folder permission, normally we don't provide the read/write access to shared folder but in my case for testing purpose i will provide the (777) permission so that NFS client user can read/write the data on shared folder.

hpx:/>#chmod 777 /backup

4. In this step we change the NFS_SERVER=1 to enable your server to act as a NFS Server in the configuration file /etc/rc.config.d/nfsconf

hpx:/>vi /etc/rc.config.d/nfsconf
Change the NFS_SERVER parameter as follow.
NFS_SERVER=1
PCNFS_SERVER=0
START_NFSLOGD=0
START_MOUNTD=1
MOUNTD_OPTIONS=""
Save and exit the file.

5. In final step we will add an entry of our shared folder in the export file /etc/dfs/dfstab with proper permission.

#vi /etc/dfs/dfstab
/usr/sbin/share -F nfs -o rw -d “Test directory” /backup

Save and exit the file.

If you see the above line "/backup is shared folder and we will provide the "rw" read/write access to this folder.

6. Now please restart the nfs service on NFS server and make it permanent so after reboot of HP-UX server the shared folder is not umount.

hpx:/>/sbin/init.d/nfs.server stop
hpx:/>/sbin/init.d/nfs.server start

7. Using below command we can check the NFS folder is shared or not and also we can ensure which client can access this machine.

hpx:/>/usr/sbin/exportfs -av

shareall -F nfs

Steps involved to access the NFS shared folder to the NFS clients:

1. Now for NFS client configuration i will login on my Linux machine.In my case i will use my Centos machine as a client, You can select your NFS client machine as per your requirement.

2. On client machine, please select the mount point to where we have to mount the NFS shared folder /backup which we exported from NFS Server 10.135.0.27. On my Linux machine, I will mount it on /home/backup.

3. In this step we will verify the list of shares available on client machine. Please use the below "showmount" command to check which NFS shared folder is accessible.

hpx:/>showmount -e 10.135.0.27
export list for 10.135.0.27
/backup

If we get the output, server side export configuration doesnt have any problem between nfs server and client.

3. In next step we will mount the nfs share locally on our desintation mount point folder.

hpx:/>mount 10.135.0.27:/backup /home/backup

4. In final step, you can check the NFS mount folder using "bdf" command. It is show you the mount folder where all existing data is store. For testing purpose you can create any file on /home/backup.

Hope, you will like my this post, it is cover all the installation and configuration part step by step. Please let me know if you encouter any issue during NFS configuration on HP-UX machine.

Friday, February 10, 2017

How to Create Local YUM Repository on CentOS 7 / RHEL 7

In this post, I describes how to setup a local Yum repository on CentOS 7 & RHEL 7 server operating system.

The local YUM repository is the most significant way to perform any type of package installation without any internet connection. If you have to install software, security updates and fixes often in multiple systems in your local network, then having a local repository is an efficient way. 

All required packages are downloaded over the fast LAN connection from your local server, so that it will save your Internet bandwidth and reduces your annual cost of Internet.

Now, please find the step by step method to create a YUM repository on RHEL 7 & CentOS 7.

Mount the Local Media:

In this step we mount our CentOS 7 / RHEL 7 installation DVD. For example, let us mount the installation media on /mnt directory.

#mount -o loop /dev/cdrom /mnt

In my Linux machine i will insert the ISO on cdrom and mount it on /mnt directory.

Copy or Extract the Media:

In this step, we will extract or copy iso files to local machine. For this work we will create a one mount point directory and copy all the packages files from /mnt.

#mkdir /centos
#cp -rvf /mnt/* /centos

So all the packages are copied on the "/centos" directory.

Install repository packages:

In this step, we will create repository but before this we need to install the "createrepo" rpm on the YUM server.

For createrepo, you need to install some dependency rpm which are listed in "Packages" folder.

#rpm -ivh libxml2-python-2.9.1-5.el7_0.1.x86_64.rpm
#rpm -ivh python-deltarpm-3.6-3.el7.x86_64.rpm
#rpm -ivh deltarpm-3.6-3.el7.x86_64.rpm
#rpm -ivh createrepo-0.9.9-23.el7.noarch.rpm

Once these required packages is installed we create the repo using createrepo command.

#createrepo -v /centos/Packages

Remove the Online Repository:

Please remove the old repository from /etc/yum.repos.d directory. In this directory all the default local centOS / RHEL repository are exist.

#rm -rf /etc/yum.repos.d/*

Create Local Repository:

In this step we will create the local repostiory which is always kept as a local. Using this local repo we can install all the packages and their dependency.

#vi /etc/yum.repos.d/local.repo

[Packages]
baseurl=file:///centos/Packages
gpgcheck=0
enable=1

After save the file your local.repo repository has been created. In next step we will enable it.

Enable Local Repository:

After successfully creation of YUM repository we will enable it.

#yum clean all
#yum repolist all

Using this repolist command you can check the newly created and existing repository on the server. After that you can easily install the pacakges using YUM in RHEL 7 & CentOS 7.