Showing posts with label Linux Training in Jaipur. Show all posts
Showing posts with label Linux Training in Jaipur. Show all posts

Thursday, 17 September 2015

Creating and Restore Backup Using LVM snapshot

Lvm Snapshot is ultimate way for creating a backup of that data which is already present into LVM(Logical Volume Management) devices (LV)-Logical volume.
Example: 1. We have a already created LV(logical volume) from any VG
============
of 5GiB/GB size and have copied lots of data for example 4GB
Important :
==========
When you copy or store data it stores in two maners.
i) Data blocks (original data)
ii) metadata pointers (links and location address)
@@@@@@@@@@@@@@@@@@@@ THe concept of LVM SnapShot @@@@@@@@@
————————————————————
LVM Snapshot make a link to Original LV(Logical volume)
just like soft link of a file or directory which doesn’t required much size.
So if we have 5GB of LV(logical VOlume) then we can have its metadata upto 10-15% (50MB) and We can create LVM snapshot of 50MB
—————–
Practical :24 hours
—————–
Step 1:
=======
Mount your LV (logical volume) which you have already created then fill some data.
[root@desktop69 rhel6]# mount /dev/vgcheck/lvm1 /mnt/new
step 2:
=======
copy some data here
[root@desktop69 rhel6]# touch /mnt/new/abd{1..67}
[root@desktop69 rhel6]#cp -rvf /usr/ /mnt/new
Step3 :
======
Now take a snapshot of LVM
[root@desktop69 rhel6]#lvcreate -s –size 20M –name lvmsnapshot1 /dev/vgcheck/lvm1
check by using lvs or lvdisplay command
Note: Now you can mount it to access the stored data

Thursday, 6 August 2015

Managing Partition in Linux using Parted

Parted is another utility  for managing  hard in linux based os

Step 1:-  To check number of partition  in a hard disk
======

[root@desktop12 ~]# parted  /dev/sda print  
Model: ATA ST3160812AS (scsi)
Disk /dev/sda: 160GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system     Flags
 1      1049kB  538MB   537MB   primary   ext4            boot
 2      538MB   79.2GB  78.6GB  primary                   lvm
 3      79.2GB  79.7GB  537MB   primary   linux-swap(v1)
 4      79.7GB  160GB   80.3GB  extended
 5      79.7GB  82.9GB  3221MB  logical
 6      82.9GB  137GB   53.7GB  logical
 7      137GB   137GB   105MB   logical   ext3
 8      137GB   137GB   524MB   logical   ext4
 9      137GB   138GB   524MB   logical   ext4
10      138GB   140GB   2147MB  logical   ext4
11      140GB   140GB   105MB   logical
12      140GB   140GB   41.9MB  logical
13      140GB   141GB   524MB   logical
14      141GB   143GB   2147MB  logical   ext4

OR
==

[root@desktop12 ~]# parted  /dev/sda 
GNU Parted 2.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Model: ATA ST3160812AS (scsi)
Disk /dev/sda: 160GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system     Flags
 1      1049kB  538MB   537MB   primary   ext4            boot
 2      538MB   79.2GB  78.6GB  primary                   lvm
 3      79.2GB  79.7GB  537MB   primary   linux-swap(v1)
 4      79.7GB  160GB   80.3GB  extended
 5      79.7GB  82.9GB  3221MB  logical
 6      82.9GB  137GB   53.7GB  logical
 7      137GB   137GB   105MB   logical   ext3

Step 2: To show create  a new  logical partition 
===================================================

Inside your  hard disk create partition of  2GB

(parted) mkpart  logical  143GB   145GB

Note: quit to exit from partition table

fire partx command to 
[root@desktop12 ~]# partx  -a /dev/sda

step 3: create file system  of desired format 
=============================================

[root@desktop12 ~]# mkfs.vfat   /dev/sda15

step 4: Now mount your partition 
=================================
[root@desktop12 ~]# mkdir  /media/kkk
[root@desktop12 ~]# mount  /dev/sda15  /media/kkk

Now you can save your data and can also made entry in /etc/fstab to make this partition persistance
 
Article Source - http://www.rhce.co.in/managing-partition-in-linux-using-parted/ 

Friday, 12 June 2015

How to configure ISCSI target in Redhat 7

@ Motive behind iscsi protocol is to send hard disk (block device) over the network
@ In redhat 7  we are going to setup a cli target
Step 1 :  To setup target you need to install software which is in version 7 (targetcli)
[root@redhat7 Desktop]# yum install targetcli
step 2 : There is no need to start the service or open configuration file so use targetcli command
====
[root@redhat7 Desktop]# targetcli
targetcli shell version 2.1.fb34
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type ‘help’.
/>                                                            # this is the prompt of targetcli
i)  To list the architecture of iscsi target
/> ls
o- / …………………………………………………………… […]
  o- backstores …………………………………………………. […]
  | o- block ………………………………………. [Storage Objects: 0]
  | o- fileio ……………………………………… [Storage Objects: 0]
  | o- pscsi ………………………………………. [Storage Objects: 0]
  | o- ramdisk …………………………………….. [Storage Objects: 0]
  o- iscsi ……………………………………………….. [Targets: 0]
  o- loopback …………………………………………….. [Targets: 0]
/>
ii) To create a iscsi target block
/> cd  /backstores/block
/backstores/block>
/backstores/block> create  newhd  /dev/sda7
Created block storage object newhd using /dev/sda7.
/backstores/block>
iii)  To  create an  IQN number use below stpes
/backstores/block> cd /iscsi
/iscsi>
/iscsi> create                                                               # create command will automatically IQN number
Created target iqn.2003-01.org.linux-iscsi.redhat7.x8664:sn.66955d1bd65c.
Created TPG 1.
/iscsi>
OR you can give your own IQN number in proper format
/iscsi> create  iqn.2014-10.com.example:iscsit
Created target iqn.2014-10.com.example:iscsit.
Created TPG 1.
/iscsi>
iV)  Now you need to configure the iscsi hard disk for client with given properities like acls , luns , portals
     ==========================================================================================================
/iscsi> cd /iscsi/iqn.2014-10.com.example:iscsit/tpg1/
/iscsi/iqn.20…e:iscsit/tpg1>
/iscsi/iqn.20…e:iscsit/tpg1> ls
o- tpg1 ……………………………………….. [no-gen-acls, no-auth]
  o- acls …………………………………………………. [ACLs: 0]
  o- luns …………………………………………………. [LUNs: 0]
  o- portals ……………………………………………. [Portals: 0]
 A)  Create a portal so that client can connect and access hard disk
 /iscsi/iqn.20…e:iscsit/tpg1> portals  create
Using default IP port 3260
Binding to INADDR_ANY (0.0.0.0)
Created network portal 0.0.0.0:3260.
/iscsi/iqn.20…e:iscsit/tpg1>
Note : IT will automatically create  3260 port binded with all ip of ISCSI server
Important:  You can create you won port and also can bind with any server IP using below step
=========
/iscsi/iqn.20…e:iscsit/tpg1> portals  create   192.168.0.20  1234
Created network portal 192.168.0.20:1234.
/iscsi/iqn.20…e:iscsit/tpg1>
B)  You also need to create a Logical unit number or Luns  for client hard disk
/iscsi/iqn.20…e:iscsit/tpg1> luns/  create /backstores/block/newhd
Created LUN 0.
/iscsi/iqn.20…e:iscsit/tpg1>
C)  By default acls must be implemented in version 7 .To two disable acls use below given steps
i)
/iscsi/iqn.20…fb47f492/tpg1> set  attribute  authentication=0
Parameter authentication is now ‘0’.
/iscsi/iqn.20…fb47f492/tpg1>
ii)
/iscsi/iqn.20…fb47f492/tpg1> set  attribute  generate_node_acls=1
Parameter generate_node_acls is now ‘1’.
/iscsi/iqn.20…fb47f492/tpg1>
Now you can login via any client and use Targetcli from command line which same as Redhat version 6