Category: Life

  • linux查看RAID信息

    RAID分为软RAID和硬RAID

    软RAID查看

    cat /proc/mdstat

    硬RAID查看

    在启动画面进raid卡查看

    IM(RAID1)、IME(RAID1E)、IS(RAID0)

    在系统中查看

    # dmesg |grep -i raid
    
    [ 6.346983] megaraid_sas 0000:03:00.0: PCI INT A -> GSI 33 (level, low) -> IRQ 33
    [ 6.346992] megaraid_sas 0000:03:00.0: setting latency timer to 64
    [ 6.470380] scsi0 : LSI SAS based MegaRAID driver
    [ 25.827254] md: Autodetecting RAID arrays.

    proc中的RAID信息

    # cat /proc/scsi/scsi
    
    Attached devices:
    Host: scsi0 Channel: 00 Id: 32 Lun: 00
    Vendor: DP Model: BACKPLANE Rev: 1.07
    Type: Enclosure ANSI SCSI revision: 05
    Host: scsi0 Channel: 02 Id: 00 Lun: 00
    Vendor: DELL Model: PERC 6/i Rev: 1.22
    Type: Direct-Access ANSI SCSI revision: 05
    Host: scsi0 Channel: 02 Id: 01 Lun: 00
    Vendor: DELL Model: PERC 6/i Rev: 1.22
    Type: Direct-Access ANSI SCSI revision: 05
    Host: scsi1 Channel: 00 Id: 00 Lun: 00
    Vendor: TEAC Model: DVD-ROM DV-28SW Rev: R.2A
    Type: CD-ROM ANSI SCSI revision: 05

    查看RAID卡型号

    # lspci | grep RAID
    03:00.0 RAID bus controller: LSI Logic / Symbios Logic MegaRAID SAS 1078 (rev 04)

    可以发现上面这台服务器的RAID卡是LSI的,服务器是DELL的,要查看更详尽的信息就需要针对RAID卡在系统里面装驱动了,如去LSI,或DELL网站可以找到对应的驱动。

    http://www.lsi.com/support/pages/download-search.aspx

    搜到megaCLI可以试一下

    http://www.lsi.com/downloads/Public/Obsolete/Obsolete%20Common%20Files/1.01.39_Linux_Cli.zip

    通过DELL对应驱动查看

    http://www.dell.com/support/drivers/us/en/04/Product/poweredge-r710

    网上还有通用工具,如megasasctl,很久没有更新了,也可以试一下

    http://sourceforge.net/projects/megactl/files/

    更多可参考:http://hwraid.le-vert.net/wiki/LSIMegaRAIDSAS

    dmesg 显示时间

    dmesg -T
  • ethtool检测和管理网卡

    ethtool是检测和管理网卡设置的工具

    ethtool的实用之处之一是可以查看网线是否插到网卡上

    如果有显示信息Link detected: yes,则说明在链路状态,表明插上网线并且在通讯

    #ethtool em1
    
    Settings for em1:
    Supported ports: [ TP ]
    Supported link modes: 10baseT/Half 10baseT/Full
    100baseT/Half 100baseT/Full
    1000baseT/Full
    Supports auto-negotiation: Yes
    Advertised link modes: 10baseT/Half 10baseT/Full
    100baseT/Half 100baseT/Full
    1000baseT/Full
    Advertised pause frame use: No
    Advertised auto-negotiation: Yes
    Speed: 1000Mb/s
    Duplex: Full
    Port: Twisted Pair
    PHYAD: 1
    Transceiver: internal
    Auto-negotiation: on
    MDI-X: Unknown
    Supports Wake-on: g
    Wake-on: d
    Link detected: yes

    如果显示Link detected: no,表明插上网线但没有链路

    #ethtool em2
    Settings for em2:
    Supported ports: [ TP ]
    Supported link modes: 10baseT/Half 10baseT/Full
    100baseT/Half 100baseT/Full
    1000baseT/Full
    Supports auto-negotiation: Yes
    Advertised link modes: 10baseT/Half 10baseT/Full
    100baseT/Half 100baseT/Full
    1000baseT/Full
    Advertised pause frame use: No
    Advertised auto-negotiation: Yes
    Speed: Unknown!
    Duplex: Half
    Port: Twisted Pair
    PHYAD: 1
    Transceiver: internal
    Auto-negotiation: on
    MDI-X: Unknown
    Supports Wake-on: g
    Wake-on: d
    Link detected: no

    如果找不到设备,则没有网线插入

    #ethtool em3
    Settings for em3:
    Cannot get device settings: No such device
    Cannot get wake-on-lan settings: No such device
    Cannot get message level: No such device
    Cannot get link status: No such device
    No data available

    查看 veth 设备对的 peer 另一端

    ethtool -S veth1
  • smbclient的使用

    使用smbclient可以方便的连接上windows共享目录或samba

    smbclient //192.168.11.32/test -U administrator 回车输入密码
    Enter administrator's password: 
    Domain=[COMPUTER] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
    smb: \>

    常用的命令有ls显示,cd切换目录,del删除,put上传,get下载等。

  • chattr lsattr命令

    chattr与lsattr可以修改文件属性,是比chmod, chown的属性更底层的属性。

    chattr可以结合 -减  +增  = 指定 属性

    查看属性,默认只有一个e属性

    #lsattr /etc/hosts
    -------------e- /etc/hosts

    添加i属性,则这个文件将不能修改,删除,重命名,追加,也不能创建硬链接。root也只能在回收这个属性值之后才能正常使用。

    # chattr +i /etc/hosts
    # lsattr /etc/hosts
    ----i--------e- /etc/hosts
    rm /etc/hosts会出现Operation not permitted

    添加a属性,使文件只能被追加,不能被删除,常用于日志文件,比如说在logrotate的时候对日志文件先-a,然后再+a。如nginx的logrotate

    # This configuration is from jpuyy 2013-12-16
     /web/nginx/logs/access.log {
     weekly
     rotate 5
     compress
     sharedscripts
     prerotate
     /usr/bin/chattr -a /web/nginx/logs/access.log
     endscript
     sharedscripts
     postrotate
     /usr/bin/killall -HUP nginx
     /usr/bin/chattr +a /web/nginx/logs/access.log
     endscript
     }

    chattr -R 递规更改属性

  • mysql between用法

    mysql中的between and用于将一定范围内的数据取出,包含了边界值, 查看ID号在20至50之间的用户,包含20和50:

    SELECT * FROM user WHERE uid BETWEEN 20 AND 50

    还可以查看在字符范围内的,应该是按ASCII码排序

    SELECT * FROM user WHERE name BETWEEN a AND e;

    between and 比较时间,可以是从1970-01-01 00:00:00的秒数,如1387210733,可以是date格式,也可以是datetime格式。如

    SELECT * FROM user WHERE rtime BETWEEN '2010-08-10' AND '2013-12-10';
  • dpkg使用方法

    查看已经安装的软件包

    dpkg --get-selections

    查看npm包都包含哪些文件

    dpkg -L npm

    查看npm的详情(status)

    dpkg -s npm