存档

2010年6月 的存档

finding netcard driver type in linux

2010年6月29日 1 条评论

we have two ways:

1. finding netcard driver by syslog
grep -i ‘driver’ /var/log/messages
or
dmesg | grep -i driver

2.lsmod  
#try to find netcard type.

[root@2hei.net]# modinfo e1000
filename:       /lib/modules/2.6.9-34.ELsmp/kernel/drivers/net/e1000/e1000.ko
parm:           debug:Debug level (0=none,…,16=all)
version:        6.1.16-k3-NAPI 4BCC06D27AAC4C711223CC9
license:        GPL
description:    Intel(R) PRO/1000 Network Driver
author:         Intel Corporation, <linux.nics@intel.com>

[root@2hei.net]# modinfo igb
filename:       /lib/modules/2.6.18-164.11.1.el5/kernel/drivers/net/igb/igb.ko
version:        1.3.16-k2
license:        GPL
description:    Intel(R) Gigabit Ethernet Network Driver
author:         Intel Corporation, <e1000-devel@lists.sourceforge.net>
srcversion:     78555F0A019E05BADBD95AA

[root@2hei.net]# modinfo bonding
filename:       /lib/modules/2.6.18-164.11.1.el5/kernel/drivers/net/bonding/bonding.ko
author:         Thomas Davis, tadavis@lbl.gov and many others
description:    Ethernet Channel Bonding Driver, v3.4.0
version:        3.4.0
license:        GPL
srcversion:     7989A7EEF2EE7B5D78C0E79
depends:        ipv6
vermagic:       2.6.18-164.11.1.el5 SMP mod_unload gcc-4.1

分类: linux 标签:

write a own tools of WorldTime with pytz

2010年6月29日 评论已被关闭

require : python2.6 pytz

#!/usr/bin/env python
# -*- coding: gbk -*-
from datetime import datetime, timedelta
from time import gmtime, strftime
from pytz import timezone
import pytz, time,os

#def convert_datetime(unix_timestamp=1143408000, tz=1, long_fmt=1):
def convert_datetime(dt=’2007-01-01 00:00:00′, tz=”, dest_fmt=”, time_stamp=0):
    fmt      = ‘%Y-%m-%d %H:%M:%S’
    if time_stamp == 0:
        dt_stamp = time.mktime(time.strptime(dt, fmt))
    else:
        dt_stamp = float(dt)
    utc      = pytz.utc
    utc_dt   = datetime.utcfromtimestamp(dt_stamp).replace(tzinfo=utc)  
    dest_tz  = timezone(tz)
    dest_dt  = dest_tz.normalize(utc_dt.astimezone(dest_tz))  
    return dest_dt.strftime(dest_fmt)

#define all citys here
citys = {‘Asia/Shanghai’:’Asia/Shanghai 上 海’,
        ‘America/Los_Angeles’:’America/Los_Angeles 旧金山’,
        ‘Etc/GMT’:’Etc/GMT 格林威治标准时间’,
        ‘US/Pacific’:’US/Pacific PT 太平洋时间’,
        ‘UTC’:’UTC 世界标准时间’,
        #’Etc/GMT+8′:’Etc/GMT+8′,
       }
 
if __name__ == ‘__main__’:
    while True:
        os.system(‘cls’)
        print ‘————–时间对照————–‘
        for k,v in citys.items():
            print convert_datetime(dt=strftime(“%Y-%m-%d %H:%M:%S”, time.localtime()), tz=k,dest_fmt=’%Y-%m-%d %H:%M:%S’),’\t[‘+v+’]’
        print ‘————————————‘
        time.sleep(1)

       
run.bat
set path=D:\python26\;%path%
D:
cd D:\Profiles\2hei.net\eclipse-project\py\myapp\src\time_format
python world_time.py

running like this:

world_time_zone.png

 

分类: python 标签:

notice Hostnames should not contain an ‘_’

2010年6月17日 评论已被关闭
notice Hostnames should not contain an ‘_’:
such as vm_test01.2hei.net
Please have a look at RFC952 (http://tools.ietf.org/html/rfc952) Hostnames should not contain an ‘_’!
ASSUMPTIONS:
   1. A “name” (Net, Host, Gateway, or Domain name) is a text string up
   to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus
   sign (-), and period (.).  Note that periods are only allowed when
   they serve to delimit components of “domain style names”. (See
   RFC-921, “Domain Name System Implementation Schedule”, for
   background).  No blank or space characters are permitted as part of a
   name. No distinction is made between upper and lower case.  The first
   character must be an alpha character.  The last character must not be
   a minus sign or period.  A host which serves as a GATEWAY should have
   “-GATEWAY” or “-GW” as part of its name.  Hosts which do not serve as
   Internet gateways should not use “-GATEWAY” and “-GW” as part of
   their names. A host which is a TAC should have “-TAC” as the last
   part of its host name, if it is a DoD host.  Single character names
   or nicknames are not allowed.
分类: OpenSource 标签:

replacing_hard_disks_in_a_raid1_array

2010年6月9日 评论已被关闭
cat /proc/mdstat
Personalities : 
[raid1] read_ahead 1024 sectors 
md1 : active raid1 sda3[0] sdb3[1] 522048 blocks [2/2] [U_] 
md0 : active raid1 sda2[0] sdb2[1] 4192896 blocks [2/2] [U_] 
md2 : active raid1 sda1[0] sdb1[1] 128384 blocks [2/2] [U_] 
unused devices: <none> 
this shows disk hdb failed!  we will replace it.
work follow it:
Replacing A Failed Hard Drive In A Software RAID1 Array
Version 1.0 
Author: Falko Timme <ft [at] falkotimme [dot] com> 
Last edited 01/21/2007
This guide shows how to remove a failed hard drive from a Linux RAID1 array (software RAID), and how to add a new hard disk to the RAID1 array without losing data.
I do not issue any guarantee that this will work for you!
 
1 Preliminary Note
In this example I have two hard drives, /dev/sda and /dev/sdb, with the partitions /dev/sda1 and /dev/sda2 as well as /dev/sdb1 and /dev/sdb2.
/dev/sda1 and /dev/sdb1 make up the RAID1 array /dev/md0.
/dev/sda2 and /dev/sdb2 make up the RAID1 array /dev/md1.
/dev/sda1 + /dev/sdb1 = /dev/md0
/dev/sda2 + /dev/sdb2 = /dev/md1
/dev/sdb has failed, and we want to replace it.
 
2 How Do I Tell If A Hard Disk Has Failed?
If a disk has failed, you will probably find a lot of error messages in the log files, e.g. /var/log/messages or /var/log/syslog.
You can also run
cat /proc/mdstat
and instead of the string [UU] you will see [U_] if you have a degraded RAID1 array.
 
3 Removing The Failed Disk
To remove /dev/sdb, we will mark /dev/sdb1 and /dev/sdb2 as failed and remove them from their respective RAID arrays (/dev/md0 and /dev/md1).
First we mark /dev/sdb1 as failed:
mdadm –manage /dev/md0 –fail /dev/sdb1
The output of
cat /proc/mdstat
should look like this:
server1:~# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid5] [raid4] [raid6] [raid10]
md0 : active raid1 sda1[0] sdb1[2](F)
      24418688 blocks [2/1] [U_]
md1 : active raid1 sda2[0] sdb2[1]
      24418688 blocks [2/2] [UU]
unused devices: <none>
Then we remove /dev/sdb1 from /dev/md0:
mdadm –manage /dev/md0 –remove /dev/sdb1
The output should be like this:
server1:~# mdadm –manage /dev/md0 –remove /dev/sdb1
mdadm: hot removed /dev/sdb1
And
cat /proc/mdstat
should show this:
server1:~# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid5] [raid4] [raid6] [raid10]
md0 : active raid1 sda1[0]
      24418688 blocks [2/1] [U_]
md1 : active raid1 sda2[0] sdb2[1]
      24418688 blocks [2/2] [UU]
unused devices: <none>
Now we do the same steps again for /dev/sdb2 (which is part of /dev/md1):
mdadm –manage /dev/md1 –fail /dev/sdb2
cat /proc/mdstat
server1:~# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid5] [raid4] [raid6] [raid10]
md0 : active raid1 sda1[0]
      24418688 blocks [2/1] [U_]
md1 : active raid1 sda2[0] sdb2[2](F)
      24418688 blocks [2/1] [U_]
unused devices: <none>
mdadm –manage /dev/md1 –remove /dev/sdb2
server1:~# mdadm –manage /dev/md1 –remove /dev/sdb2
mdadm: hot removed /dev/sdb2
cat /proc/mdstat
server1:~# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid5] [raid4] [raid6] [raid10]
md0 : active raid1 sda1[0]
      24418688 blocks [2/1] [U_]
md1 : active raid1 sda2[0]
      24418688 blocks [2/1] [U_]
unused devices: <none>
Then power down the system:
shutdown -h now
and replace the old /dev/sdb hard drive with a new one (it must have at least the same size as the old one – if it’s only a few MB smaller than the old one then rebuilding the arrays will fail).
 
4 Adding The New Hard Disk
After you have changed the hard disk /dev/sdb, boot the system.
The first thing we must do now is to create the exact same partitioning as on /dev/sda. We can do this with one simple command:
sfdisk -d /dev/sda | sfdisk /dev/sdb
You can run
fdisk -l
to check if both hard drives have the same partitioning now.
Next we add /dev/sdb1 to /dev/md0 and /dev/sdb2 to /dev/md1:
mdadm –manage /dev/md0 –add /dev/sdb1
server1:~# mdadm –manage /dev/md0 –add /dev/sdb1
mdadm: re-added /dev/sdb1
mdadm –manage /dev/md1 –add /dev/sdb2
server1:~# mdadm –manage /dev/md1 –add /dev/sdb2
mdadm: re-added /dev/sdb2
Now both arays (/dev/md0 and /dev/md1) will be synchronized. Run
cat /proc/mdstat
to see when it’s finished.
During the synchronization the output will look like this:
server1:~# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid5] [raid4] [raid6] [raid10]
md0 : active raid1 sda1[0] sdb1[1]
      24418688 blocks [2/1] [U_]
      [=>……………….]  recovery =  9.9% (2423168/24418688) finish=2.8min speed=127535K/sec
md1 : active raid1 sda2[0] sdb2[1]
      24418688 blocks [2/1] [U_]
      [=>……………….]  recovery =  6.4% (1572096/24418688) finish=1.9min speed=196512K/sec
unused devices: <none>
When the synchronization is finished, the output will look like this:
server1:~# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid5] [raid4] [raid6] [raid10]
md0 : active raid1 sda1[0] sdb1[1]
      24418688 blocks [2/2] [UU]
md1 : active raid1 sda2[0] sdb2[1]
      24418688 blocks [2/2] [UU]
unused devices: <none>
That’s it, you have successfully replaced /dev/sdb!
分类: linux 标签: ,