Powered By Blogger

Wednesday, December 28, 2011

IP Forwarding on RHEL

We can modify IP_forwarding temporally or permanently

For temporally

There are two methods for temporally change,

Method 1

Check if IP Forwarding was already enabled or not

[root@Ram ~]# cat /proc/sys/net/ipv4/ip_forward
0

if it is 0 it is disabled, if 1 then it is enabled

Modify the value

[root@Ram ~]# echo 1 > /proc/sys/net/ipv4/ip_forward
[root@Ram ~]# cat /proc/sys/net/ipv4/ip_forward
1

Method 2

[root@Ram ~]# sysctl -a|grep ip_forward
net.ipv4.ip_forward = 0

[root@Ram ~]# sysctl -w net.ipv4.ip_forward=1
net.ipv4.ip_forward = 1

[root@Ram ~]# sysctl -a|grep ip_forward
net.ipv4.ip_forward = 1




For permanent change,

Modify following line in /etc/sysctl.conf to 1 from 0

# Controls IP packet forwarding
net.ipv4.ip_forward = 1


Execute following command to load the configuration

[root@Ram ~]# sysctl -p

LVM creationg, Extend and reduce in RHEL

fdisk -l

Disk /dev/sda: 8589 MB, 8589934592 bytes

Added new hard disk(2 GB) using Vmware settings


From the host, used following command to scan new disk

echo "- - -" > /sys/class/scsi_host/host2/scan

Disk /dev/sda: 8589 MB, 8589934592 bytes
Disk /dev/sdb: 2147 MB, 2147483648 bytes


Noticed new disk /dev/sdb after scan


Now Creating new LVM using new disk

1) Creating Physical volume

[root@Ram ~]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created

2) Assign physical volume to volume group

[root@Ram ~]# vgcreate vg1 /dev/sdb
Volume group "vg1" successfully created

3) Check your work

[root@Ram ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg1 1 0 0 wz--n- 2.00g 2.00g

[root@Ram ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb vg1 lvm2 a- 2.00g 2.00g

Now Create Logical Volumes of 1 GB initially. I will explain how to extend and reduce after this

[root@Ram ~]# lvcreate -L 1GB -n lg1 vg1
Logical volume "lg1" created

[root@Ram ~]# mke2fs -j /dev/vg1/lg1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.


Now Create new filesystem

[root@Ram ~]# mkdir /test
[root@Ram ~]# mount /dev/vg1/lg1 /test
[root@Ram ~]# df -h
/dev/mapper/vg1-lg1 1008M 34M 924M 4% /test

Now filesystem is mounted but when you restart the system, it will not mount it again. For that, we need to update /etc/fstab file

/dev/mapper/vg1-lg1 /test ext4 defaults 0 0

After updating, we can make sure it is correct by unmounting and mounting it again

[root@Ram ~]# umount /test

[root@Ram ~]# mount /test

Cool. Now we will extend the filesystem from 1 GB to 1.5 GB.

First we will check if we have enough space for this

[root@Ram ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg1 1 1 0 wz--n- 2.00g 1020.00m


Yep, we have space.

[root@Ram ~]# lvextend -L +512MB /dev/vg1/lg1
Extending logical volume lg1 to 1.50 GiB
Logical volume lg1 successfully resized

It will still show 1 GB

/dev/mapper/vg1-lg1 1008M 34M 924M 4% /test

Now we have to execute following command to extend

root@Ram ~]# resize2fs /dev/vg1/lg1
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg1/lg1 is mounted on /test; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/vg1/lg1 to 393216 (4k) blocks.
The filesystem on /dev/vg1/lg1 is now 393216 blocks long.

[root@Ram ~]# df -h

/dev/mapper/vg1-lg1 1.5G 34M 1.4G 3% /test


We got email from developer to reduce the filesystem to 1 GB since he accidently sent wrong filesystem

Ok, the problem for reducing filesystem, we have to unmount the filesystem

[root@Ram ~]# umount /test

Check the filesytem

[root@Ram ~]# e2fsck -f /dev/vg1/lg1
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vg1/lg1: 11/98304 files (0.0% non-contiguous), 14765/393216 blocks

[root@Ram ~]# resize2fs /dev/vg1/lg1 1024M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vg1/lg1 to 262144 (4k) blocks.
The filesystem on /dev/vg1/lg1 is now 262144 blocks long.


[root@Ram ~]# lvreduce -L 1024M /dev/vg1/lg1
WARNING: Reducing active logical volume to 1.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lg1? [y/n]: y
Reducing logical volume lg1 to 1.00 GiB
Logical volume lg1 successfully resized

Mount the filesystem

[root@Ram ~]# mount /test

[root@Ram ~]# df -h
/dev/mapper/vg1-lg1 1008M 34M 924M 4% /test

Tuesday, December 27, 2011

ACL setup on RHEL

In the following setting up ACL under home directory which is mounted under /(root)

# mount -o remount,acl /
# mount |grep /
/dev/sda2 on / type ext4 (rw,usrquota,grpquota,acl)

# touch testacl.txt
# getfacl /home/testacl.txt
getfacl: Removing leading '/' from absolute path names
# file: home/testacl.txt
# owner: root
# group: root
user::rw-
group::r--
other::r--

[root@Ram home]# setfacl -m u:ram:rwx /home/testacl.txt
[root@Ram home]# getfacl /home/testacl.txt
getfacl: Removing leading '/' from absolute path names
# file: home/testacl.txt
# owner: root
# group: root
user::rw-
user:ram:rwx
group::r--
mask::rwx
other::r--

Tuesday, December 13, 2011

Blocking port 80 using IPTABLES in RHEL

This is just basic example using iptables, it needs more practice since it is complicated task.


Make sure port 80 is accessible on the server.

# telnet 80

to check iptables contents:

# less /etc/sysconfig/iptables

For blocking port 80 using command line

# iptables -I INPUT -p tcp --dport 80 -j REJECT

Save the configuration

# service iptables save
Saving firewall rules to /etc/sysconfig/iptables: [ OK ]

Restart the service

# service iptables restart
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK ]
Applying iptables firewall rules: [ OK ]
Loading additional iptables modules: ip_conntrack_netbios_n[ OK ]


Make sure port 80 is not accessible now.

# telnet 80

To remove the configuration enter the following command, save and restart the service:

# iptables -D INPUT -p tcp --dport 80 -j REJECT


Now, you should access port 80 again.

Monday, December 12, 2011

Resetting ROOT password on RHEL 5 and RHEL 6

If you don't know root password on RHEL 5. it is straight forward. Reboot to the single user mode and change the password using passwd.

How to boot to the single user mode.

When system reboot, Press Enter and Highlight Kernel line and press E. Enter single or s at the end of the line and enter.
Enter b to boot to the single user mode.

You will get # and type passwd to change the password.

Reboot the system

The only difference in RHEL 6 is, we have to disable selinux to be able to change the root password in the single user mode.

How to disable seLinux

Use following command to verify, whether is enabled or not.

# /usr/sbin/getenforce

Edit /etc/selinux/config file and change following line

SELINUX=enforcing to disabled and reboot the system to the single user mode using same steps as RHEL 5. Change the password using passwd

Friday, December 2, 2011

Using KSAR for Graphs from SAR

As UNIX administrator, we use sar to see the server stats. KSAR is free gui tool, where it will show sar output in graphs and also we can save the output in pdf file.

--> Download GUI tool from
http://sourceforge.net/projects/ksar/files/latest/download
--> unzip the gip file
--> under Ksar-5.N.N folder, click on ksat executable jar file (It will open gui window)

Either you can see full day output using data -> Lauch SSH Command -> Connect to remote server

or

Copy SAR output to local desktop (If you have sar output from previous days)

Enter Data -> Load from text file

To convert to text file

LC_ALL=C sar -A -f /var/adm/sa/sa11111 > sar111111.txt




LVM commands

pvs Displays physical volumes
vgs Displays volume groups
lvs Displays logical volumes
pvdisplay Displays detailed informationon physical volumes
vgdisplay Displays detailed informationon volume groups
lvdisplay Displays detailed informationon logical volumes
pvcreate Creates a new physical volume
vgcreate Creates a new volume group
lvcreate Creates a new logical volume
vgextend Extends an existing volume group
lvextend Extends a logical volume
lvresize Resizes a logical volume
lvreduce Reduces a logical volume
lvrename Renames a logical volume
pvmove Moves/migrates data from one physicalvolume to another
vgreduce Reduces a volume group
pvremove Removes a physical volume
vgremove Removes a volume group
lvremove Removes a logical volume

Some of the PRCTL commands

Most of the times, we get email from oracle team to modify some of the project setting. Following are the some of the commands:

Command to check value for project.max-shm-memory
# prctl -n project.max-shm-memory -i projectuser.oracle
Command to increase memory to 96 GB memory for running Process
# prctl -n project.max-shm-memory -r -v 96GB-i project user.oracle
Command to Make it permanentby updating /etc/project file
# projmod -sK "project.max-shm-memory=(privileged,103079215104,deny)"user.oracle
Command to check all parametersfor current user
# prctl $$
Command to check all parametersused for Oracle user
# prctl -i project user.oracle

Saturday, October 29, 2011

Mounting ISO to the solaris zones

# lofiadm -a /path/to/the/iso/file.iso
# mount -F hsfs -o ro /dev/lofi/1 /mnt
# mount -F lofs /mnt /zones//root/mnt

Steps to increase SWAP cap for solaris zones

# /bin/prctl -n zone.max-swap`pgrep -z init`
# prctl -n zone.max-swap-r -v 10GB `pgrep -z init`
# /bin/prctl -n zone.max-swap`pgrep -z init`

Monday, September 19, 2011

Booting from Mirror Disk (ZFS Filesystem)

Checking the system if root file system is mirrored or not

# zpool status rpool
config:

NAME STATE READ WRITE CKSUM
rpool ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
c1t0d0s0 ONLINE 0 0 0
c1t1d0s0 ONLINE 0 0 0


You can see c1t1d0s0 is root mirror disk

If pool was attached later please execute following command to make it bootable

# installboot -F zfs /usr/platform/`uname -i`/lib/fs/zfs/bootblk /dev/rdsk/c1t1d0s0


Changing use-nvramrcvalue for using eeprom feature from the system


Check the value
# eeprom use-nvramrc?
use-nvramrc?=false

Set to true

# eeprom use-nvramrc?=true

Check the value

# eeprom use-nvramrc?
Getting device Information and configure it

# ls -l /dev/dsk/c1t1d0s0
lrwxrwxrwx 1 root root 49 Feb 11 2010 /dev/dsk/c1t1d0s0 ->../../devices/pci@400/pci@0/pci@8/scsi@0/sd@1,0:a

In the above highlighted output, remove /devices and replace disk in the place sd
Like
/pci@400/pci@0/pci@8/scsi@0/disk@1,0

Enter following command to create root mirror devalias

# eeprom nvramrc="devaliasrootmirror /pci@400/pci@0/pci@8/scsi@0/disk@1,0"



Bring the system to ok Prompt and verify configuration

# init 0

ok devalias ( to verify rootmirror is created)

rootmirror /pci@400/pci@0/pci@8/scsi@0/disk@1,0
primary-vds0 /virtual-devices@100/channel-devices@200/virtual-disk-server@0
primary-vswp0 /virtual-devices@100/channel-devices@200/virtual-network-switch@0
primary-vswp1 /virtual-devices@100/channel-devices@200/virtual-network-switch@1
primary-vcc0 /virtual-devices@100/channel-devices@200/virtual-console-concentrator@0
ttya /ebus@c0/serial@0,ca0000
net3 /pci@500/pci@0/pci@8/network@0,3
net2 /pci@500/pci@0/pci@8/network@0,2
net1 /pci@500/pci@0/pci@8/network@0,1
net0 /pci@500/pci@0/pci@8/network@0
net /pci@500/pci@0/pci@8/network@0
cdrom /pci@400/pci@0/pci@1/pci@0/usb@0,2/hub@4/device@4/storage@0/disk@0:f
disk15 /pci@400/pci@0/pci@8/scsi@0/disk@f
disk14 /pci@400/pci@0/pci@8/scsi@0/disk@e
disk13 /pci@400/pci@0/pci@8/scsi@0/disk@d
disk12 /pci@400/pci@0/pci@8/scsi@0/disk@c
disk11 /pci@400/pci@0/pci@8/scsi@0/disk@b
disk10 /pci@400/pci@0/pci@8/scsi@0/disk@a
disk9 /pci@400/pci@0/pci@8/scsi@0/disk@9
disk8 /pci@400/pci@0/pci@8/scsi@0/disk@8
disk7 /pci@400/pci@0/pci@8/scsi@0/disk@7
disk6 /pci@400/pci@0/pci@8/scsi@0/disk@6
disk5 /pci@400/pci@0/pci@8/scsi@0/disk@5
disk4 /pci@400/pci@0/pci@8/scsi@0/disk@4
disk3 /pci@400/pci@0/pci@8/scsi@0/disk@3
disk2 /pci@400/pci@0/pci@8/scsi@0/disk@2
disk1 /pci@400/pci@0/pci@8/scsi@0/disk@1
disk0 /pci@400/pci@0/pci@8/scsi@0/disk@0
disk /pci@400/pci@0/pci@8/scsi@0/disk@0
scsi /pci@400/pci@0/pci@8/scsi@0
virtual-console /virtual-devices/console@1


Boot from the roor mirror

ok boot rootmirror

Boot device: /pci@400/pci@0/pci@8/scsi@0/disk@1,0 File and args:





Tuesday, May 10, 2011

Configuring Linux Bonding

Switch:

Connect cables to the switch
Make link-aggregate active in the switch for the ports

Server:

1. Create the configuration file for bondX (where X is a number, we'll use 0 to explain the steps forward)
vi /etc/sysconfig/network-scripts/ifcfg-bond0

2. Add the fallowing content to it, update IP with correct information:
DEVICE=bond0
IPADDR=192.10.10.51
NETWORK=192.10.10.32
NETMASK=255.255.255.224
USERCTL=no
BOOTPROTO=none
ONBOOT=yes

3. Update all configuration files for the network interface that will be used by the new bond, using the fallowing template (Update the red text with the right values).
for eth0:
vi /etc/sysconfig/network-scripts/ifcfg-eth0:
DEVICE=eth0
HWADDR=00:34:34:D8:45:89
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

4. Prepare the drivers adding the fallowing lines to /etc/modprobe.conf:
alias bond0 bonding
options bond0 mode=802.3ad miimon=100
5. Load bonding module
# modprobe bonding mode=802.3ad miimon=100
6. Restart network
# service network restart
7. Test the bond
ping -I bond0 192.10.10.12

Monday, May 2, 2011

Expanding LUN on Solaris

1) Unmount the filesystem
umount /testing

2) Comment the line in the /etc/vfstab

3) format
Enter disk number
format> type
AVAILABLE DRIVE TYPES:
0. Auto configure
...
Specify disk type (enter its number)[24]: 0

format> part
partition> print ( verify)
partition> label ( Label it)
partition> quit
format> label (label it)
format> verify ( to Verify)
format> quit

4) uncomment the line in the /etc/vfstab which was commented in the step 2
5) mount /testing
6) growfs -M /testing /dev/rdsk/c3t12d0s6 ( Which will grow the filesystem)

Thursday, April 21, 2011

Restricted access on Solaris Server

1) Create a group with the users who need access

sshuser::140:testuser,tomcat,apache

2) Modify /etc/ssh/sshd_config, add following line

AllowGroups sshuser

3) Restart the ssh service

#svcadm restart network/ssh:default

Tuesday, April 12, 2011

Removing bonding in LINUX

ifconfig bond0 down
echo "-eth0" > /sys/class/net/bond0/bonding/slaves
echo "-eth1" > /sys/class/net/bond0/bonding/slaves
echo "-bond0" > /sys/class/net/bonding_masters
rmmod bonding

Removing Link Aggregate on Solaris

To remove an interface from an link aggregate:
Test-Server # dladm remove-aggr -d e1000g2 1
Test-Server #
To delete an aggregate:
Test-Server # dladm delete-aggr 1
Test-Server #

Monday, April 4, 2011

Checking apache httpd.conf location

execute following command from bin directory
# ./httpd -V and look for
-D SERVER_CONFIG_FILE="/etc/apache2/httpd.conf"

Tuesday, March 22, 2011

Changing between ALOM and ILOM

ALOM -> ILOM
sc> userclimode admin default
sc> logout

ILOM -> ALOM
-> set /SP/users/admin cli_mode=alom
-> exit

Wednesday, March 2, 2011

Killing session in oracle

Finding session:

SQL> select SID,serial# from v$session where username='TESTER'

and Killing it


SQL> ALTER SYSTEM KILL SESSION '2090,4043'IMMEDIATE;

Saturday, February 19, 2011

124861-15 patch install for ORACLE 11G RAC

When I was trying to install 124861-15 patch for ORACLE RAC 11G pre-req patch. It was failed due to package was not installed. I went online and installed latest Solaris Studio 12.2 version but still it was not working. I realized that this patch will only work if we install Studio 12 version. I have removed 12.2 and installed 12. It worked like a charm after that.

Oracle Solaris 12.2 Components and Packages
http://download.oracle.com/docs/cd/E18659_01/html/821-1385/gentextid-1431.html


Uninstallation of studio 12.2
http://download.oracle.com/docs/cd/E18659_01/html/821-1385/gentextid-822.html


Troubleshooting document for fixing a failed installation and uninstallation of Studio 12.2, plus viewing the installation log file
http://download.oracle.com/docs/cd/E18659_01/html/821-1385/gentextid-922.html


Sun Studio documentation
http://developers.sun.com/sunstudio/documentation/ss12/index.jsp


oracle product download for studio, url in devtool
http://www.oracle.com/technetwork/indexes/downloads/index.html#tools


Previos release of studio product
http://www.oracle.com/technetwork/server-storage/solarisstudio/downloads/index-jsp-142582.html


Solaris Studio 12 download link
http://www.oracle.com/technetwork/server-storage/solarisstudio/downloads/ss12-136026.html

Thursday, February 17, 2011

Taking explorer on SUN machines

If your system is a SunFire midframe server (38x0, 48x0, or 68x0 model), use this command to include data from the system console:

# /opt/SUNWexplo/bin/explorer -q -e -w default,scextended

If your system uses an alom (advanced lights out manager), some additional data can be collected. Systems that use that include:
Sun Fire V210,V240,V250,V245,V440,V440R,V445 Server Netra 240,440 (AC) Server
Use this command:

# /opt/SUNWexplo/bin/explorer -q -e -w default,alomextended

If your system uses T1 processors (system type starts with T, and uname -a command will say architecture is sun4v), use this command:

# /opt/SUNWexplo/bin/explorer -q -e -w default,Tx000

For any other model of Sun system, use this command:

# /opt/SUNWexplo/bin/explorer -q -e

The -q option suppresses printing of error messages during the run.
The -e option prevents explorer from automatically sending email.
The -w scextended option collects data from the system console (sc).

If you cannot run explorer for some reason, here are the most important things to collect:

/var/adm/messages or messages.# file for the time when the crash was taken. Be sure to include any messages that occurred just before panic.

/etc/system file

output of the showrev -p command, for a list of patches on system

Detailed hardware configuration of the system. To determine which command to use, issue the command uname -m to find the system architecture type.

If it is sun4u, send the output of this command:
/usr/platform/sun4u/sbin/prtdiag -v
If it is sun4v, send the output of this command:
/usr/platform/sun4v/sbin/prtdiag -v
Output of this command:
prtconf -vp

If your system is a SunFire midframe server (38x0, 48x0, or 68x0 model), include the output of these commands to collect data from the system console:

showlogs -v
showlogs -d showboards -v showplatform -v showenvironment -v showsc -v

Tuesday, February 1, 2011

NFS mount option for Oracle Data Pump

mount -o hard,rw,noac,rsize=32768,wsize=32768,suid,proto=tcp,vers=3 -F nfs NFSSERVER:/FILESYTEM /SOMEFILESYSTEM

Thursday, January 6, 2011

Remove iscsi targets in centOS

#service iscsi stop
#iscsiadm -m node -T iqn.NNNNNNNNNNNNNNNNNNNNNNNNNNNNNN --op=delete
#service iscsi start
Welcome to the UNIX world