Showing posts with label how to. Show all posts
Showing posts with label how to. Show all posts

Thursday, March 16, 2017

Step by Step Configuration of NTP Server on HP-UX Server

In this post, I would like to explain how we configure the NTP (network time protocol) server on HP-UX operating system server. In my recent post you can found the NTP configuration on Solaris and AIX platform. 

As you know NTP ( Network time Protocol) is one of the oldest internet protocol still in use and it allows the synchronization of computer clocks distributing UTC (Coordinated Universal Time) over the network. It is basaiclly used for time synchronization on Unix servers.

Step by Step Configuration of NTP Server on HP-UX:

1. In the first step we will check the configuration files of "xntpd" daemon. By default the configuration file for this daemon is "/etc/rc.config.d/netdaemons".

# vi /etc/rc.config.d/netdaemons

######################################
# xntp configuration.  See xntpd(1m) #
######################################
#
#  Time synchronization daemon
#
# NTPDATE_SERVER: name of trusted timeserver to synchronize with at boot
# (default is rootserver for diskess clients)
# XNTPD:        Set to 1 to start xntpd (0 to not run xntpd)
# XNTPD_ARGS:  command line arguments for xntpd
#
# Also, see the /etc/ntp.conf and /etc/ntp.keys file for additional
# configuration.
#
export NTPDATE_SERVER=
export XNTPD=0
export XNTPD_ARGS=

This is default configuration entry of this file so for xntpd daemon we need to change the variable which is defined.

export NTPDATE_SERVER='ntp.in.pool.org'
export XNTPD=1
export XNTPD_ARGS=

Note: You must change the NTPDATE server name.

2. For ntp config please set the correct timezone is setup in /etc/TIMEZONE file.

hpx:/> cat /etc/TIMEZONE
TZ=IST-5:30
export TZ

You can edit the file in vi editor and change the time zone as per your location.

3. Now, we need to make some changes in NTP configuration files. 

hpx29:/> cat /etc/ntp.conf
#Configuration NTP des serveurs
server ntp.in.org.com
server ntpin.in.org.com

You need to replace ntp server name accordingly. In my post I will use dummy server name.

4. After setting the NTP server name we need to restart the NTP service on HP-UX operating system and verify the ntp configuration.

hpx:/> /sbin/init.d/xntpd restart

hpx:/> ntpq -p

If it is showing you correct ntp server information now. You can match these information with the NTP server name which we use in above step.

Thursday, February 23, 2017

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.

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. 

Friday, February 10, 2017

How to setup NFS Server on CentOS 7 / RHEL 7

In this post, I would explain you , how to setup NFS server on CentOS 7 & RHEL 7. This step by step installation and configuration method of NFS server is work in Fedora 22 version also.

Network File System is used for to share files and folders between Linux / Unix systems. NFS enables you to mount a remote share locally as well as it allows to have updated files across the share.

Before starting the setup method , we need to understand which service and files are used for NFS setup.

Please find the below services which are used for NFS setup. its must be always runs on operating system.

rpcbind service: The rpcbind server is used to converts RPC program numbers into universal addresses.

nfs-server service:  Its enables the NFS clients to access NFS shares.

nfs-lock / rpc-statd service: these are the recovery services when an NFS server crashes and reboots.

nfs-idmap service: It translates user and group ids into names, and to translate user and group names
into ids.

The mail configuration file for NFS server and client is "/etc/exports". It controls which file systems are exported to remote hosts and specifies options.

Now, we will start the step by step process for setup of NFS server on CentOS 7 / RHEL 7.

NFS Server Setup:

1. First we need to install the NFS packages on the server where we want to setup of NFS server. We can install the required NFS packages using YUM.

#yum install nfs-utils libnfsidmap

It's installed all the required packages on NFS server.

2. Once the packages are installed we will enable and start all the above services which we explain in my post.

#systemctl enable rpcbind
#systemctl enable nfs-server
#systemctl start rpcbind
#systemctl start nfs-server
#systemctl start rpc-statd
#systemctl start nfs-idmapd

You can check the status of all these service by using this command "systemctl status service_name" to ensure all are working fine.

3. Now we will created the shared directory which we want to share for client.

#mkdir /backup
#chmod -R 777 /backup

We can change the permission of NFS folder as per your requirement. In my case I'll provide the read write permession to all NFS client on this shared folder, so they can easily copy and remove the files. Ideally for security purpose we never provide 777 permission.

4. In this step we will make an entry of shared folder and client information , what permission we give to client to access the folder and which client can access the NFS shared folder.

# vi /etc/exports

/backup 10.135.0.27(rw,sync,no_root_squash)

In above command output, you can see the "/backup" is shared NFS server folder and "10.135.0.27" user client have rights to access this shared folder.

Also in brackets if you see the permission parameter which is very important when we setup the NFS setup. Please find the small idea about these permission parameteres.

rw: Writable permission to shared folder

sync:  all changes to the according filesystem are immediately flushed to disk.

no_root_squash: By default, any file request made by user root on the client machine is treated as by user nobody on the server. If no_root_squash is selected, then root on the client machine will have the same level of access to the files on the system as root on the server

5. Now, we will export the shared directories using following command.

# exportfs -r

We can use other syntax as well for this, which is listed below.

exportfs -v : Displays a list of shares files and export options on a server
exportfs -a : Exports all directories listed in /etc/exports
exportfs -u : Unexport one or more directories
exportfs -r : Reexport all directories after modifying /etc/exports

6. Now in above step 5, we configured and installed the NFS server but if firewall is running on your machine then we need to add NFS services in firewall as well.

#firewall-cmd --permanent --zone public --add-service mountd
#firewall-cmd --permanent --zone public --add-service rpc-bind
#firewall-cmd --permanent --zone public --add-service nfs
#firewall-cmd --reload

NFS Client Steup:

1. Once we installed the NFS server, now we will mount the remote file system on NFS client machine. So for this , on client machine we will install the same NFS packages which we installed during NFS server setup.

#yum install nfs-utils libnfsidmap

It's installed all the required packages on NFS client. Once the packages is installed on NFS client machine we will start the "rpcbind" services on client machine.

#systemctl enable rpcbind
#systemctl start rpcbind

2. Now we will mount the NFS shared folder on client machine but before doing that we will check on client machine which NFS server is available.


client# showmount -e 10.135.0.27    (10.135.0.2 is myserver machine IP)

Export list for 10.135.0.27:
/backup      10.135.0.2

So you can able to see on client machine our NFS shared folder is available on 10.135.0.27 NFS server. 

3. In this step , now we will mount this NFS shared folder on NFS client machine, for this we will create a mount point on client machine where we mount the server shared folder.

client# mkdir /mnt/backup
client#mount 10.135.0.27:/backup /mnt/backup

So you can check the mount folder using "df -h" command.

4. To make a permanent entry on client machine so that once you take a reboot of client machine , the shared folder is not umount.

client# vi /etc/fstab
10.135.0.27:/backup/ /mnt/backup nfs rw,sync,hard,intr 0 0

Please make an entry permanent on client machine and save it and take a restart of machine , after reboot once you login you will see the shared folder still available on the client machine.

5. For testing of shared folder, you can create a one file on client machine then check on the server this newly created file is shown on the server folder also.

So, using all these steps you can easily setup the NFS server and client on your machine.

Monday, February 6, 2017

How to create local zone in Solaris 10

Hello Friends,

In this post, I will explain you how to create a new local zone on Sun Solaris operating system. Before describe the step by step installation and configuration method we need to understand what is zone and where it is used.

Basically Zone is a virtual operating system environment created within a single instance of the Solaris operating system. The mail goal of this technology is efficient resource utilization. We can create multiple zone on one Solaris operating system.
Solaris 10's zone partitioning technology can be used to create local zones that behave like virtual servers. All local zones are controlled from the system's global zone. Processes running in a zone are completely isolated from the rest of the system.


Note- That processes running in a local zone can be monitored from global zone but the processes running in a global zone or even in another local zone cannot be monitored from a local zone.

Global Zone: When we install the Solaris 10 operating system, a global zone gets installed automatically, and the core operating system runs under global zone as well as all the local zone are also runs on same global zone. Using "zoneadm" command we can check list of all configured zones which are running on Solaris operating system.


# zoneadm list -v

  ID NAME             STATUS         PATH
   0 global           running        /

Step by step method to create a Local Zone:

When we create a local Solaris zone on global zone , we have to complete some prerequisite before installing the zone.

Prerequisites:  A lot of disk space is required to installed the newly zone. It needs at least 3 GB space to copy the essentials files to the local zone. In my case I normally use 10 GB free disk space to installed the local zone. Also for configuration we required a dedicated IP for network connectivity.

1. First we will check the disk space and network configuration by using running below command.

[sun]# df -h /
 Filesystem             size   used  avail capacity  Mounted on
 /dev/dsk/c1t1d0s0       50G    22G   28G    46%    /

[sun] # ifconfig -a
 lo0: flags=2001000849 mtu 8232 index 1   
 inet 127.0.0.1 netmask ff000000  
 em0: flags=1000843 mtu 1500 index 2   
 inet 10.135.0.23 netmask fffffe00 broadcast 10.135.0.255

Here, if you see the "df -h" command output we can found that the disk "c1t1d0s0" is mounted on the root file system. Currently the total disk space size of root partition is approx 50 GB, as we required 10 GB free space for installation and configuration of local zone, so free space on root partition is sufficient for zone installation.

In "ifconfig" command output we can able to see the the ip address of global zone.

2. As we have sufficient space on the server so we can go ahead for local zone installation. First we need to create a directory where we want to install the zone. All the files is keep in this folder only.

[sun]# mkdir /zones

3. Next step is to define/create the zone root. This is the path to zone's root directory that is relative to the global zone's root directory. Zone root must be owned by root user with the mode 700. This will be used in setting the zonepath property, during the zone creation process.

[sun]# cd /zones[sun]# mkdir sun01[sun]# chmod -R 775 sun01[sun]# ls -l
 total 2
 drwx------   2 root     root         512 Feb 06 12:46 sun01

In a Sparse Root Zone, the directories /usr, /sbin, /lib and /platform will be mounted as loopback file systems. That is, although all those directories appear as normal directories under the sparse root zone, they will be mounted as read-only file systems. Any change to those directories in the global zone can be seen from the sparse root zone.


However if you need the ability to write into any of those directories listed above, you may need to configure a Whole Root Zone. For example, softwares like ClearCase need write permissions to /usr directory. In that case configuring a Whole Root Zone is the way to go. The steps for creating and configuring a new 'Whole Root' local zone are as follows:

4. In this step we will create & configure a new 'Sparse Root' local zone, with root privileges. For configuration of installed zone we will used "zonecfg" command. It is most widely used command for zone configuration.

[sun]# zonecfg -z sun01sun01: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:
sun01> create
zonecfg:
sun01> set zonepath=/zones/sun01
zonecfg:
sun01> set autoboot=true
zonecfg:
sun01> add net
zonecfg:
sun01:net> set physical=em0
zonecfg:
sun01:net> set address=10.135.0.24
zonecfg:
sun01:net> end
zonecfg:
sun01> add fs
zonecfg:
sun01:fs> set dir=/repo2
zonecfg:
sun01:fs> set special=/dev/dsk/c1t20d0s1
zonecfg:
sun01:fs> set raw=/dev/rdsk/c1t20d0s1
zonecfg:
sun01:fs> set type=ufs
zonecfg:
sun01:fs> set options noforcedirectio
zonecfg:
sun01:fs> end
zonecfg:
sun01> add inherit-pkg-dir
zonecfg:
sun01:inherit-pkg-dir> set dir=/opt/csw
zonecfg:
sun01:inherit-pkg-dir> end
zonecfg:
sun01> info
zonepath: /zones/
sun01
autoboot: true
pool:
inherit-pkg-dir:   dir: /lib
inherit-pkg-dir:   dir: /platform
inherit-pkg-dir:   dir: /sbin
inherit-pkg-dir:   dir: /usr
inherit-pkg-dir:   dir: /opt/csw
net: address: 
10.135.0.24
physical: 
em0
zonecfg:appserv> verify
zonecfg:appserv> commit
zonecfg:appserv> exit

4. Secondly we will create & configure a new 'Whole Root' local zone, with root privileges. In this again we will used the same zone name "sun01".

[sun]zonecfg -z sun01
sun01: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:
sun01> create
zonecfg:
sun01> set zonepath=/zones/sun01
zonecfg:
sun01> set autoboot=true
zonecfg:
sun01> add net
zonecfg:
sun01:net> set physical=em0
zonecfg:
sun01:net> set address=10.135.0.24
zonecfg:
sun01:net> end
zonecfg:
sun01> add inherit-pkg-dir
zonecfg:sun01:inherit-pkg-dir> set dir=/opt/csw
zonecfg:
sun01:inherit-pkg-dir> end
zonecfg:
sun01> remove inherit-pkg-dir dir=/usr
zonecfg:
sun01> remove inherit-pkg-dir dir=/sbin
zonecfg:
sun01> remove inherit-pkg-dir dir=/lib
zonecfg:
sun01> remove inherit-pkg-dir dir=/platform
zonecfg:
sun01> info
zonepath: /zones/
sun01
autoboot: true
pool:
inherit-pkg-dir:  dir: /opt/csw
net:  address: 
10.135.0.24
physical: 
em0
zonecfg:appserv> verify
zonecfg:appserv> commit
zonecfg:appserv> exit

Brief explanation of the properties that we added:

\* zonepath=/zones/sun01
Local zone's root directory, relative to global zone's root directory. ie., local zone will have all the bin, lib, usr, dev, net, etc, var, opt etc., directories physically under /zones/appserver directory

\* autoboot=true

boot this zone automatically when the global zone is booted

\* physical=em0

em0 card is used for the physical interface

\* address=10.135.0.24
10.135.0.24 is the IP address. It must have all necessary DNS entries

The whole add fs section adds the file system to the zone. In this example, the file system that is being exported to the zone is an existing UFS file system.

\* set dir=/repo2

/repo2 is the mount point in the local zone

\* set special=/dev/dsk/
c1t20d0s1 set raw=/dev/rdsk/c1t20d0s1

Grant access to the block (/dev/dsk/c1t20d0s1) and raw (/dev/rdsk/c1t20d0s1) devices so the file system can be mounted in the non-global zone. Make sure the block device is not mounted anywhere right before installing the non-global zone. Otherwise, the zone installation may fail with ERROR: file system check </usr/lib/fs/ufs/fsck> of </dev/rdsk/c2t40d1s6> failed: exit status <33>: run fsck manually. In that case, unmount the file system that is being exported, uninstall the partially installed zone (zoneadm -z <zone> uninstall) then install the zone from the scratch (no need to re-configure the zone, just do a re-install).

\* set type=ufs

The file system is of type UFS

\* set options noforcedirectio

Mount the file system with the option redirection.

\* dir=/opt/csw

Read-only path, will be lofs'd (loop back mounted) from global zone.

Note: it works for sparse root zone only -- whole root zone cannot have any shared file systems

Zonecfg commands verify and commit, verifies and commits the zone configuration for the zone, respectively. Note that it is not necessary to commit the zone configuration; it will be done automatically when we exit from zonecfg tool. info displays information about the current configuration

5. Now we will check the current state of the newly created/configured zone, for this we will use zoneadm command

[sun]# zoneadm list -cv
   ID NAME             STATUS         PATH
    0 global           running        /
    - sun01          configured     /zones/sun01

6. Next step is to install the configured zone "sun01". It takes a while to install the necessary packages
  
[sun]# zoneadm -z sun01 install 

The file contains a log of the zone installation. Once the zone installation is completed you can able to see the message on the installation window, all the required packages get installed during this installation.

7. Now verify the state of the sun01 zone

[sun]# zoneadm list -cv
   ID NAME             STATUS         PATH
    0 global           running        /
    - sun01          installed      /zones/sun01

8. In final step we will boot up the sun01 zone.

[sun]# zoneadm -z sun01 boot
zoneadm: zone 'sun01': WARNING: em0:1: no matching subnet found in netmasks(4) for 
10.135.0.24,using default of  255.0.0.0.

[sun]# zoneadm list -cv
   ID NAME             STATUS         PATH
    0 global           running        /
    1 sun01          running        /zones/sun01


9. Login to the Zone {console} and performing the internal zone configuration. zlogin utility can be used to login to a zone with -C option of zlogin can be used to log in to the Zone console.

[sun]# zlogin -C sun01

9.1. It is asking for some option when we run the above command. for language option you need to select the "English" option. Most probably it is "0" option in the menu.

9.2  After language option it is asking for locale. You need to set "English (c-7-bit ASCII) locale for Solaris 10 zone.

9.3  Enter the host name which identifies this system on the network.  The name must be unique within your domain; creating a duplicate host name will cause problems on the network after you install Solaris. A host name must have at least one character; it can contain letters, digits, and minus signs (-).

10. Now simply login to the newly created zone, just like connecting to any other system in the network.

Note: You can create another local zone using this same method. In this blog we get the idea how we will create the new zone on Solaris 10. The installation method on other Solaris operating system is different. This post is used for only zone creation on Solaris 10 only.