Difference between revisions of "Linux"
Line 1: | Line 1: | ||
+ | ==Logrotate== | ||
+ | * Execute lr for specific config file (add -f to force rotate): | ||
+ | /usr/sbin/logrotate -d /etc/logrotate.d/mongodb | ||
+ | * Example logrotate config: | ||
+ | /var/log/mongo/*.log { | ||
+ | missingok | ||
+ | daily | ||
+ | maxage 7 | ||
+ | copytruncate | ||
+ | compress | ||
+ | } | ||
+ | |||
==Network Bonding== | ==Network Bonding== | ||
# cat ifcfg-eth4 | # cat ifcfg-eth4 |
Latest revision as of 07:51, 15 November 2013
Logrotate
- Execute lr for specific config file (add -f to force rotate):
/usr/sbin/logrotate -d /etc/logrotate.d/mongodb
- Example logrotate config:
/var/log/mongo/*.log { missingok daily maxage 7 copytruncate compress }
Network Bonding
# cat ifcfg-eth4 DEVICE=eth4 #HWADDR=54:78:1A:87:0A:D9 UUID=7f9590fa-7247-46de-8fc2-f8f56952db26 ONBOOT=yes MASTER=bond0 SLAVE=yes BOOTPROTO=none USERCTL=no TYPE=Ethernet
# cat ifcfg-eth5 DEVICE=eth5 #HWADDR=54:78:1A:87:0A:DA UUID=70b865ec-476d-4846-b9f6-4726c3d9253f ONBOOT=yes MASTER=bond0 SLAVE=yes BOOTPROTO=none USERCTL=no TYPE=Ethernet
# cat ifcfg-bond0 DEVICE=bond0 IPADDR=10.93.193.240 NETMASK=255.255.254.0 ONBOOT=yes BOOTPROTO=none USERCTL=no BONDING_OPTS="mode=1 miimon=500"
With vlans
- eth4 and 5 are the same as above
# cat ifcfg-bond0 DEVICE=bond0 ONBOOT=yes BOOTPROTO=none
# cat ifcfg-bond0.545 DEVICE=bond0.545 IPADDR=10.93.193.242 NETMASK=255.255.254.0 NETWORK=10.93.192.0 ONBOOT=yes BOOTPROTO=static USERCTL=no BONDING_OPTS="mode=1 miimon=500" VLAN=yes
# cat /etc/sysconfig/network NETWORKING=yes HOSTNAME=btoldb03 GATEWAY=10.93.192.1 GATEWAYDEV=bond0.545
Disk Tools
- Check disk io for benchmarks:
[root@ashmon2 ~]# hdparm -t /dev/sda /dev/sda: Timing buffered disk reads: 54 MB in 3.05 seconds = 17.73 MB/sec [root@ashmon2 ~]# vmstat 3 procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------ r b swpd free buff cache si so bi bo in cs us sy id wa st 1 0 80 1040472 163412 610172 0 0 0 17 1 0 1 0 99 0 0 0 0 80 1040984 163412 610172 0 0 0 0 1057 116 0 0 100 0 0 [root@ashmon2 ~]# iostat -n 5 Linux 2.6.18-164.el5 (ashmon2) 05/07/2012 avg-cpu: %user %nice %system %iowait %steal %idle 0.85 0.02 0.18 0.25 0.00 98.70 Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn sda 2.36 0.19 66.86 2785043 997786784 sda1 2.36 0.19 66.86 2784513 997786784 sdb 0.00 0.00 0.00 2839 160 sdb1 0.00 0.00 0.00 1949 160 Device: rBlk_nor/s wBlk_nor/s rBlk_dir/s wBlk_dir/s rBlk_svr/s wBlk_svr/s ops/s rops/s wops/s ash3070filer1-ss:/vol/vol1_dhs_3070f1_nas/systems 4.33 0.01 0.00 0.00 0.00 0.14 0.24 0.00 0.03
Finding what process is bound to a port
netstat -tlnp | grep 8080
last column is the pid.
Set timezone
ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
Install rpm file and find dependencies
yum --nogpgcheck localinstall foo.rpm
Show swap usage
[root@dsdwsprddb02 ~]# ls -al /var/log/sa/ | grep "Jan 20" -rw-r--r-- 1 root root 303696 Jan 20 14:20 sa20 [root@dsdwsprddb02 ~]# sar -W -f /var/log/sa/sa20 Linux 2.6.18-274.el5 (dsdwsprddb02.traderonline.com) 01/20/2012 12:00:01 AM pswpin/s pswpout/s 12:10:01 AM 22.21 0.00 12:20:01 AM 2.28 0.00 12:30:01 AM 0.30 0.00 12:40:01 AM 0.33 0.00 12:50:01 AM 3.62 0.00 01:00:01 AM 0.40 0.00 01:10:01 AM 0.00 0.00 01:20:01 AM 0.11 0.00 01:30:01 AM 0.35 0.00 ...
Add NetApp LUNS to RHEL with Multipath
I successfully did this on Oracle Linux 5 (RHEL) using multipathd.
Multipathd
No software was needed beyond what came with RHEL, but yum install device-mapper device-mapper-multipath may need to be installed.
[root@ashdwsprddb01 ~]# cat /etc/multipath.conf defaults { user_friendly_names yes max_fds max flush_on_last_del yes queue_without_daemon no } blacklist { # Local SCSI Drive need to blacklist as it doesn't have multiple paths wwid 3600508e000000000293beaba67ceda05 # devnode "^hd[a-z]" devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*" devnode "^cciss.*" } devices { device { vendor "NETAPP" product "LUN" path_grouping_policy group_by_prio features "1 queue_if_no_path" prio "alua" path_checker directio failback immediate path_selector "round-robin 0" hardware_handler "1 alua" rr_weight uniform product "LUN" rr_min_io 128 # getuid_callout "/lib/udev/scsi_id -g -u -d /dev/%n" getuid_callout "/sbin/scsi_id -g -u -s /block/%n" } }
- Replace the wwid of any local disks you have for the blacklist. Find that by running scsi_id -g -u -s /block/sda
- service multipathd start
- chkconfig multipathd on
Once you do that, the luns show should up in /dev/mapper and from multipath -l
[root@ashdwsprddb01 ~]# ls /dev/mapper/ control mpath0 mpath1 mpath2 mpath3 VolGroup00-LogVol00 VolGroup00-LogVol01 [root@ashdwsprddb01 ~]# multipath -l mpath2 (360a98000572d4f5a5a3468623063595a) dm-4 NETAPP,LUN size=30G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw |-+- policy='round-robin 0' prio=-1 status=active | |- 2:0:5:2 sdo 8:224 active undef running | `- 1:0:3:2 sdg 8:96 active undef running `-+- policy='round-robin 0' prio=-1 status=enabled |- 2:0:4:2 sdk 8:160 active undef running `- 1:0:2:2 sdc 8:32 active undef running mpath1 (360a98000572d4f5a5a34686230696f39) dm-3 NETAPP,LUN size=200G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw |-+- policy='round-robin 0' prio=-1 status=active | |- 2:0:5:3 sdp 8:240 active undef running | `- 1:0:3:3 sdh 8:112 active undef running `-+- policy='round-robin 0' prio=-1 status=enabled |- 2:0:4:3 sdl 8:176 active undef running `- 1:0:2:3 sdd 8:48 active undef running mpath0 (360a98000572d4f5a5a346862306d4b2d) dm-2 NETAPP,LUN size=10G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw |-+- policy='round-robin 0' prio=-1 status=active | |- 2:0:5:4 sdq 65:0 active undef running | `- 1:0:3:4 sdi 8:128 active undef running `-+- policy='round-robin 0' prio=-1 status=enabled |- 2:0:4:4 sdm 8:192 active undef running `- 1:0:2:4 sde 8:64 active undef running mpath3 (360a98000572d4f5a5a34686230597757) dm-5 NETAPP,LUN size=1000G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw |-+- policy='round-robin 0' prio=-1 status=active | |- 2:0:5:1 sdn 8:208 active undef running | `- 1:0:3:1 sdf 8:80 active undef running `-+- policy='round-robin 0' prio=-1 status=enabled |- 2:0:4:1 sdj 8:144 active undef running `- 1:0:2:1 sdb 8:16 active undef running
Create partitions and filesystems on luns
Do this for each lun:
[root@ashdwsprddb01 ~]# fdisk /dev/mapper/mpath2 The number of cylinders for this disk is set to 3916. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-3916, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-3916, default 3916): Using default value 3916 Command (m for help): Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 22: Invalid argument. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks. [root@ashdwsprddb01 ~]# [root@ashdwsprddb01 ~]#reboot [root@ashdwsprddb01 ~]# [root@ashdwsprddb01 ~]# ls /dev/mapper/mpath2* /dev/mapper/mpath2 /dev/mapper/mpath2p1
See how it created the partitition p1, now we can create the filesystem:
[root@ashdwsprddb01 ~]# mkfs.ext3 /dev/mapper/mpath2p1 mke2fs 1.39 (29-May-2006) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 3932160 inodes, 7863809 blocks 393190 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 240 block groups 32768 blocks per group, 32768 fragments per group 16384 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 22 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
Mount Luns
You can get the size of each lun from multipath -l', and map that to the mount point. I'm sure there is another way to get hat info too but I don't know it.
[root@ashdwsprddb01 ~]# multipath -l mpath2 mpath2 (360a98000572d4f5a5a3468623063595a) dm-4 NETAPP,LUN size=30G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw [root@ashdwsprddb01 ~]# ssh ashnetapp04 "lun show" | grep dws /vol/vol6_ashtoldws_phy_oracledb1_oracle_ashna4_san/oracle/oracle.lun 30g (32212254720) (r/w, online, mapped)
Now I know the 30g lun is the oracle mount, so it gets mounted on /oracle. Here is the /etc/fstab entry:
/dev/mapper/mpath2p1 /oracle ext3 defaults 0 0
Resize Multipath Luns
1. Delete the partition of the mpath device 2. Create a new primary partition on the device 3. fsck -f the disk (after a reboot) 4. resize2fs <disk>