Monday, December 21, 2015

Basic NFS Configuration

1. Basic NFS Configuration

1.1. NFS Server configuration

Run the below commands to begin the NFS Server installation:
[nfs-server ]# yum install nfs-utils rpcbind

Next we export some arbitrary directory called /opt/nfs. Create /opt/nfs directory:

[nfs-server ]# mkdir -p /opt/nfs

and edit /etc/exports NFS exports file to add the below line while replacing the IP address with the IP address of your client:
/opt/nfs NFS_client_IP(no_root_squash,rw,sync)

Next make sure to enable 2049 port on your firewall to allow clients requests:
[nfs-server ]# firewall-cmd --zone=public --add-port=2049/tcp --permanent
[nfs-server ]# firewall-cmd --reload

Start rpcbind daemon and NFS server in this order:
[nfs-server ]# service rpcbind start; service nfs start

Check the NFS server status:
[nfs-server ]# service nfs status 
 

1.2. NFS Client configuration

To be able to mount NFS exported directories on your client the following packages needs to be installed. Depending on your client's Linux distribution the installation procedure may be different. On Redhat 7 Linux the installation steps are as follows:

[nfs-client ]# yum install nfs-utils rpcbind
[nfs-client ]# service rpcbind start
 
What remains is to create a mount point directory eg. /mnt/nfs and mount previously NFS exported /opt/nfs directory:
[nfs-client ]# mkdir -p /mnt/nfs
[nfs-client ]# mount NFS-Server_IP:/opt/nfs /mnt/nfs/
 
Test correctness of our setup between NFS Server and NFS client. Create an arbitrary file within NFS mounted directory on the client side:
[nfs-client ]# cd /mnt/nfs/
[nfs-client ]# touch NFS.test
[nfs-client ]# ls -l
total 0
-rw-r--r--. 1 root root 0 Dec 11 08:13 NFS.test
 
Move the the server side and check whether our newly NFS.test file exists:
[nfs-server ]# cd /opt/nfs/
[nfs-server ]# ls -l
total 0
-rw-r--r--. 1 root root 0 Dec 11 08:13 NFS.test

2. Configuring permanent NFS mount

In order to have our NFS exports permanently available after the NFS server system reboot we need to make sure that nfs service starts after reboot:

[nfs-server ]# systemctl enable nfs-server
ln -s '/usr/lib/systemd/system/nfs-server.service' '/etc/systemd/system/nfs.target.wants/nfs-server.service'

To allow client to mount NFS exported directory permanently after reboot we need to define a mount procedure within /etc/fstab config file. Open /etc/fstab file and add the following line:

NFS-Server_IP:/opt/nfs /mnt/nfs nfs defaults   0 0

Sunday, December 20, 2015

RHEL 7: Install and setup samba server


RHEL 7 : Install and setup samba server ( file sharing)

Operating System : RHEL7/CentOS 7
Arch : x86_64
Samba Version : Samba 4.1.1 (Default from CentOS repo)
Kernel Versio : 3.10.0-123.el7.x86_64
IP Address : 192.168.56.102
Network Subnet : 192.168.56.0/24 or can be written also as 192.168.56.0/255.255.255.0
NOTE: CentOS 7 is installed with minimal packages (minimal installed)

Samba Server port numbers

137/tcp
137/udp
138/tcp
138/udp
139/udp
139/udp
445/tcp
445/udp

Daemon used in Samba server

Samba services are implemented as two daemons:
1. smbd, It provides the file and printer sharing services.
2. nmbd It provides the NetBIOS-to-IP-address name service. NetBIOS over TCP/IP requires some method for mapping NetBIOS computer names to the IP addresses of a TCP/IP network.

How to install and configure samba server

Step 1 : Use yum command to install samba packages
(a) policycoreutils-python = For semanage command
(b) samba-client : For smbpasswd
(c) cups-libs : For printer service
(d) samba and samba-commons : For Samba server
 
yum install -y samba samba-commons cups-libs policycoreutils-python samba-client
 
Step 2: create a directory
Create a directory called sharedrepo in / (main root) . This directory will be shared with clients.
 
mkdir /home/smbshare

Step 3: Add a new group or can use existing group
To provide access on shared directory,Here we are adding new group called staff.
 
groupadd smb

Step 4: Change the group and permission of sharing folder
Here we are using /sharedrepo in samba server, hence group and permission are changing for this directory.
 
chgrp -R smb /sharedrepo
chmod -R 777 /sharedrepo

Step 5: Change the selinux security context
Change the selinux security context on sharing directory and set the selinux boolean value for samba.
You can skip this step in case you disable selinux on system.
 
# semanage fcontext -a -t samba_share_t /home/smbshare/
# restorecon -Rv /home/smbshare/
# setsebool -P samba_enable_home_dirs on

Step 6: create user, add into group and set samba password
create user and add them in group called staff. And set the samba password for this user.
 
# useradd smbuser
# usermod -aG smb smbuser
# smbpasswd -a smbuser
New SMB password:
Retype new SMB password:
Added user smbuser.

Step 7: Edit /etc/samba/smb.conf file
First take backup of /etc/samba/smb.conf file then edit the smb.conf file.
 
cd /etc/samba/
cp -p smb.conf smb.conf.orig

And add the below given contents in last line of /etc/samba/smb.conf file.
 
vi /etc/samba/smb.conf
[smbshare]
comment = shared-directory
path = /home/smbshare
public = no
valid users = sbmuser, @smb
writable = yes
browseable = yes
create mask = 0765


Step 8: Now start the smb and nmb services.
 
systemctl start smb.service
systemctl start nmb.service

Step 9 : Enable smb and nmb service at booting of system
 
systemctl enable smb.service
systemctl enable nmb.service


Step 10 : Add firewalld rule to allow samba

# firewall-cmd --add-service=samba --permanent

Now reload firewalld
# firewall-cmd --reload 

Note: firewalld service must be runnig for above procedure. To start firewalld use systemd command i.e systemctl start firewalld.service

How to connect to Samba Server

1. Windows :
In Windows Operatig System, open the run by pressing in combination of Start key + r. Then type in this format \\ip-address-of-samba-server\shared-

Direcory-name
 
\\192.168.56.102\sharedrepo

Give username and password when it will ask.

2. Linux :
smbclient must be installed on system .

(A) List the shared files or directory available in samba server
 
smbclient -L \\192.168.56.102 -U smbuser 

In above command,
-L = For listing shared objects.
Samba Server IP Address = 192.168.56.102
User Name =smbuser

Below given is sample output
 
sharad@linuxworld:~$ smbclient -L \\192.168.56.102 -U smbuser
Enter test's password: 
Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]

 Sharename       Type      Comment
 ---------       ----      -------
 IPC$            IPC       IPC Service (Samba Server Version 4.1.1)
 sharedrepo      Disk      shared-directory
 test            Disk      Home Directories
Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]

 Server               Comment
 ---------            -------
 LOCALHOST            Samba Server Version 4.1.1

 Workgroup            Master
 ---------            -------
 MYGROUP              LOCALHOST
sharad@linuxworld:~$

(B) Access using smb console
 
smbclient //192.168.56.102/sharedrepo -U smbuser

After login, you will get smb console. You can use get and put command for getting/putting the file. There are other commands you can use also.
Sample output
 
sharad@linuxworld:~$ smbclient //192.168.56.102/sharedrepo -U smbuser
Enter test's password: 
Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]
smb: \> 
smb: \> help
?              allinfo        altname        archive        backup         
blocksize      cancel         case_sensitive cd             chmod          
chown          close          del            dir            du             
echo           exit           get            getfacl        geteas         
hardlink       help           history        iosize         lcd            
link           lock           lowercase      ls             l              
mask           md             mget           mkdir          more           
mput           newer          notify         open           posix          
posix_encrypt  posix_open     posix_mkdir    posix_rmdir    posix_unlink   
print          prompt         put            pwd            q              
queue          quit           readlink       rd             recurse        
reget          rename         reput          rm             rmdir          
showacls       setea          setmode        stat           symlink        
tar            tarmode        timeout        translate      unlock         
volume         vuid           wdel           logon          listconnect    
showconnect    tcon           tdis           tid            logoff         
..             !              
smb: \> 

(C) Mount the samba shared directory
Mount the samba shared directory in machine , your system must support cifs file system
mount -t cifs //192.168.56.102/sharedrepo -o username=test /mnt/

In Ubuntu, Click on dash home and simply access the samba server
 
smb://192.168.56.102/

See the sample screenshot of dash home.
dash home ubuntu

Tuesday, December 15, 2015

Dynamically detecting new SAN disks in Linux

When you have new LUNs created on the SAN fabric, zoned & mapped it to the server; how can you detect the luns on the linux server online, without rebooting it?.
When you dynamically add new disks to a Linux VM running on ESX server, how do you detect that disks on the Linux virtual machine?.
Here are the steps to do that :
  1. Install sg3_utils and lsscsi package. [root@fedora01 ~]# # yum install –y sg3_utils lsscsi
  2. The “lsscsi” command will list the disks attached to it. If you have just attached a disk, you will not be able to see it. You can also list this using “fdisk –l”
    [root@fedora01 ~]# lsscsi
    [0:0:0:0]    disk    VMware   Virtual disk     1.0   /dev/sda
    [root@fedora01 ~]#
    As you can see above, I currently have one disk connected to the system. To scan for a new device I just added, we should run rescan-scsi-bus.sh from the host.
  3. Run the command “/usr/bin/rescan-scsi-bus.sh” , to dynamically detect and activate the new disk.
  4.  
  5. [root@fedora01 ~]# /usr/bin/rescan-scsi-bus.sh -l
    Host adapter 0 (mptspi) found.
    Scanning SCSI subsystem for new devices
    Scanning host 0 for  SCSI target IDs  0 1 2 3 4 5 6 7, LUNs  0 1 2 3 4 5 6 7
    Scanning for device 0 0 0 0 …
    OLD: Host: scsi0 Channel: 00 Id: 00 Lun: 00
          Vendor: VMware   Model: Virtual disk   Rev: 1.0
          Type:   Direct-Access                  ANSI SCSI revision: 02
    Scanning for device 0 0 1 0 …
    NEW: Host: scsi0 Channel: 00 Id: 01 Lun: 00
          Vendor: VMware   Model: Virtual disk   Rev: 1.0
          Type:   Direct-Access                  ANSI SCSI revision: 02
    1 new device(s) found.
    0 device(s) removed.
    [root@fedora01 ~]#

    [root@fedora01 ~]# lsscsi
    [0:0:0:0]    disk    VMware   Virtual disk     1.0   /dev/sda
    [0:0:1:0]    disk    VMware   Virtual disk     1.0   /dev/sdb
    [root@fedora01 ~]#

    You see the new disk is visible. Now you can create a partition or filesystem on it.
After running those commands, check dmesg and /var/log/messages to see if there are any device detections. You can also do “fdisk -l” or “cat /proc/scsi/scsi” to see the attached LUNs. This works fine in RHEL5/6, SuSE 10, CentOS5, OEL5.

Thursday, December 10, 2015

Upgrade TSM from V6.3 to V7.1.3


Preparing the system

To prepare the system for the upgrade from V6.2 or V6.3 to V7.1, you must gather information about each DB2® instance. Then, back up the server database, save key configuration files, cancel sessions, and stop the server.

Procedure

1> Log on to the computer where Tivoli® Storage Manager is installed.
[user@SERVER ~]$ sudo su - tsminst1

2> Obtain a list of DB2 instances. Issue the following system command:
[tsminst1@TSM_SERVER ~]$ /opt/tivoli/tsm/db2/instance/db2ilist
tsminst1
[tsminst1@TSM_SERVER ~]$

3>For each DB2 instance, note the default database path, actual database path, database name, database alias, and any DB2 variables that are configured for the instance. Keep the record for future reference. This information is required to restore the V6 database.

  1. Obtain the default database path of the DB2 instance by issuing the following system command:
[tsminst1@TSM_SERVER ~]$ . ~/sqllib/db2profile; LC_ALL=C db2 get dbm cfg | grep DFTDBPATH
Default database path (DFTDBPATH) = /home/tsminst1/tsminst1
[tsminst1@TSM_SERVER ~]$

b. Obtain information about the DB2 instance databases by issuing the following system command:

[tsminst1@TSM_SERVER ~]$ . ~/sqllib/db2profile; LC_ALL=C db2 list database directory

System Database Directory
Number of entries in the directory = 2
Database 1 entry:

Database alias = TSMAL001
Database name = TSMDB1
Node name = TSMNODE1
Database release level = d.00
Comment = TSM SERVER DATABASE VIA TCPIP
Directory entry type = Remote
Catalog database partition number = -1
Alternate server hostname =
Alternate server port number =

Database 2 entry:

Database alias = TSMDB1
Database name = TSMDB1
Local database directory = /home/tsminst1/tsminst1
Database release level = d.00
Comment = TSM SERVER DATABASE
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =

c. Obtain the DB2 instance variables by issuing the following system command:

[tsminst1@TSM_SERVER ~]$
[tsminst1@TSM_SERVER ~]$ . ~/sqllib/db2profile; LC_ALL=C db2set -all
[i] DB2_PMODEL_SETTINGS=MAX_BACKGROUND_SYSAPPS:500
[i] DB2_SKIPINSERTED=ON
[i] DB2_OPTPROFILE=YES
[i] DB2_KEEPTABLELOCK=OFF
[i] DB2_EVALUNCOMMITTED=ON
[i] DB2_SKIPDELETED=ON
[i] DB2MAXFSCRSEARCH=5
[i] DB2COMM=TCPIP
[i] DB2CODEPAGE=819
[i] DB2_PARALLEL_IO=*
[g] DB2FCMCOMM=TCPIP4
[g] DB2SYSTEM=TSM_SERVER.caa.isops.ibm.com
[g] DB2INSTDEF=tsminst1
[tsminst1@TSM_SERVER ~]$

d. Obtain more DB2 instance information by saving the following files:

cp
~/sqllib/userprofile  ~/sqllib/userprofile.Nov13.2015
  cp
~/sqllib/usercshrc ~/sqllib/usercshrc.Nov13.2015

Backup the TSM database and shut it down

5 > Connect to the Tivoli Storage Manager server by using an administrative user ID ( tsmadmin )
6> Back up the Tivoli Storage Manager database.
 tsm>
backup db devc=dbsnapshot typ=dbs wait=yes 
tsm: TSM_SERVER>

tsm: TSM_SERVER>backup db devc=dbsnapshot typ=dbs wait=yes

ANR0984I Process 3 for Database Backup started in the FOREGROUND at 08:07:48 AM.
ANR4559I Backup DB is in progress.

ANR2287I Snapshot database backup started as process 3.
ANR4626I Database backup will use 1 streams for processing with the number originally requested 1.
ANR4558I Snapshot database backup (process 3) completed.
ANR0985I Process 3 for Database Backup running in the FOREGROUND completed with completion state SUCCESS at 08:15:02 AM.

tsm:
TSM_SERVER>
7> Back up the device configuration information to another directory:

 tsm> backup devconfig
filenames=/home/tsminst1/devconfig.backup
Tip: If you decide to restore the V6 database, this file is required.

8> Back up the volume history file to another directory.
 tsm>
backup volhistory filenames=/home/tsminst1/volhistory.backup

tsm: TSM_SERVER>backup volhistory filenames=/home/tsminst1/volhistory.backup

Do you wish to proceed? (Yes (Y)/No (N)) yes

ANR2462I BACKUP VOLHISTORY: Server sequential volume history information was written to /home/tsminst1/volhistory.backup.

tsm: TSM_SERVER>

Tip: If you decide to restore the V6 database, this file is required.

9> Save a copy of the server options file, which is typically named dsmserv.opt.
# cp /home/tsminst1/tsminst1/dsmserv.opt /home/tsminst1/tsminst1/dsmserv.opt.`date +%F`

[tsminst1@TSM_SERVER ~]$ cp /home/tsminst1/tsminst1/dsmserv.opt /home/tsminst1/tsminst1/dsmserv.opt.`date +%F`
[tsminst1@TSM_SERVER ~]$ ls -l /home/tsminst1/tsminst1/dsmserv.opt
dsmserv.opt dsmserv.opt.2015-11-23 dsmserv.opt.Sep10.2015
[tsminst1@TSM_SERVER ~]$ ls -l /home/tsminst1/tsminst1/dsmserv.opt*
-rw------- 1 tsminst1 tsmsrvrs 712 Sep 10 15:50 /home/tsminst1/tsminst1/dsmserv.opt
-rw------- 1 tsminst1 tsmsrvrs 712 Nov 23 08:22 /home/tsminst1/tsminst1/dsmserv.opt.2015-11-23


10> Prevent activity on the server by disabling new sessions.

tsm> disable sessions client
tsm> disable
sessions server
tsm> query
session
tsm> cancel session all
This command cancels all sessions except for your current session.

tsm: TSM_SERVER>disable sessions client
ANR2553I Server now disabled for Client access.

tsm: TSM_SERVER>disable sessions server
ANR2553I Server now disabled for Server access.

tsm: TSM_SERVER>cancel session all

ANR0491I No matching session(s) found to cancel.
ANS8001I Return code 11.
tsm: TSM_SERVER>


13> Stop the server by issuing the following Tivoli Storage Manager administrative command:
tsm> halt

tsm: TSM_SERVER>halt

ANR2234W This command will halt the server; if the command is issued from a remote client, it may not be possible to restart the server from the remote location.
Do you wish to proceed? (Yes (Y)/No (N)) yes
ANS8002I Highest return code was 11.

14> Verify that the server is shut down and no processes are running.
# ps -ef | grep dsmserv

[tsminst1@TSM_SERVER ~]$ ps -ef | grep dsmserv
tsminst1 29530 22504 0 08:28 pts/2 00:00:00 grep dsmserv
[tsminst1@TSM_SERVER ~]$


15> In the server instance directory of your installation, locate the NODELOCK file and move it to another directory, where you are saving configuration files. The NODELOCK file contains the previous licensing information for your installation. This licensing information is replaced when the upgrade is complete.

# mv /home/tsminst1/tsminst1/NODELOCK /home/tsminst1/NODELOCK.old

Stopped Operation center -
[root@TSM_SERVER tsminst1]# service opscenter.rc stop

Stopping server guiServer.

Server guiServer stopped.

[root@TSM_SERVER tsminst1]#

  1. Installing the V7.1 server and verifying the upgrade


To complete the process of upgrading the server from V6.3 to V7.1, you must install the V7.1 server. Then, verify that the upgrade was successful by starting the server instance.
Note - Run the upgrade as **root**
-check no processes are running
> # ps -ef |grep dsmserv
> If 'ulimit -Hf' not unlimited, make sure it is
  1. As root, use scp to transfer software package to a temporary directory on the TSM server that hosts the instance.
[root@TSM_SERVER Fix-pack]# pwd
/local/TSM_INSTALL_SERVER/V7.1.3/SERVER/Fix-pack
[root@TSM_SERVER Fix-pack]# ls
7.1.3.100-TIV-TSMSRV-Linuxx86_64.bin
[root@TSM_SERVER Fix-pack]#
  1. Add executable rights to the file
    root@host # chmod +x 7.1.3.100-TIV-TSMSRV-Linuxx86_64.bin
  2. Execute the binary to extract the installation files
    root@host # ./7.1.3.100-TIV-TSMSRV-Linuxx86_64.bin
  3. We have two ways to execute the code. 1. command line and 2. GUI by exporting DISPLAY to VNC Session. I am using GUI at the moment. Set the session’s DISPLAY variable to a VNC session.
  4. Use VNC viewer to connect to the VNC session.
  5. Execute the install.sh script that was extracted from the binary. The install window will appear in the VNC window, not the AIX session.
    root@host: # ./install.sh
  6. Correct any errors that are detected during the installation process. To view installation log files, from the Installation Manager tool, click File > View Log. To collect log files, from the Installation Manager tool, click Help > Export Data for Problem Analysis.
  7. Select Install from menu.
  8. Select the Server and License features.
  9. Accept the defaults for the install directories.
  10. Under Install Packages, select IBM Tivoli Storage Manager Extended Edition.
  11. Accept the license agreements.
  12. Under instance credentials, enter Instance name, password and verify.
    NOTE: If this step fails, contact administrator. Its trying to determine the password it can ssh to the server hostname without a root password prompt.
  13. Allow installation to proceed. It takes from 15-30 minutes.
  14. Once the install finishes, start the TSM server to verify that the upgrade was successful.
NOTE: Startup may take longer than usual as the installation will make database changes at this stage.
# /opt/tivoli/tsm/server/bin/rc.dsmserv -u tsminst1 -i /home/tsminst1/tsminst1 -q >/dev/console 2>&1 &

Note - If TSM serve do not start automatically after upgrade Please follow the steps. Automatically starting servers on Linux systems
  1. Verify that you can connect to the server by using the administrative client. To start an administrative client session, issue the following Tivoli Storage Manager administrative command:
# dsmadmc
TSM > query system
TSM > query db format=detailed

  1. Once the server starts responding, initiate another database full backup.
  1. Register the licenses for the Tivoli Storage Manager server components that are installed on your system by issuing the REGISTER LICENSE command:
For example, if you installed Tivoli Storage Manager Extended Edition in the /opt/tivoli/tsm directory, issue the following command:
TSM > register license file=/opt/tivoli/tsm/server/bin/tsmee.lic
  1. Verify all disk pools are online and enable client sessions.