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
Wednesday, December 28, 2011
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
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--
# 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
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
Subscribe to:
Posts (Atom)
Welcome to the UNIX world