Ads 468x60px

Pages

2012年3月7日 星期三

Dell PowerEdge R710 - 查詢 RAID 的設定

臨時要查詢目前主機上的 RAID 設定值,不過找了一下,這方面的資訊不是很好找;而且每種廠牌,軟/硬體的 RAID Controller 都不同;在這紀錄一下我的設定

環境:
* Dell R710 E5520*2/146GB*6 SAS/2GB*4
* Integrated RAID Controller(HW)
* CentOS 5.x

一開始要先找到系統上的 RAID Controller 系統型號是什麼,試了以下的方式。

root@m001 { /proc/scsi  }$ cat scsi 
Attached devices:
Host: scsi0 Channel: 02 Id: 00 Lun: 00
  Vendor: DELL     Model: PERC H700        Rev: 2.0.
  Type:   Direct-Access                    ANSI SCSI revision: 05
Host: scsi1 Channel: 00 Id: 00 Lun: 00
  Vendor: PLDS     Model: DVD+-RW DS-8A3S  Rev: HD52
  Type:   CD-ROM                           ANSI SCSI revision: 05

不過,我的系統是用 SAS 的,所以應該不是這一個。再試

root@m001 { /proc  }$ cat devices 
Character devices:
  1 mem
  4 /dev/vc/0
  4 tty
  4 ttyS
  5 /dev/tty
  5 /dev/console
  5 /dev/ptmx
  6 lp
  7 vcs
 10 misc
 13 input
 21 sg
 29 fb
128 ptm
136 pts
162 raw
180 usb
189 usb_device
202 cpu/msr
203 cpu/cpuid
216 rfcomm
251 blktap
252 uio
253 megaraid_sas_ioctl
254 pcmcia

Block devices:
  1 ramdisk
  8 sd
  9 md
 11 sr
 65 sd
 66 sd
 67 sd
 68 sd
 69 sd
 70 sd
 71 sd
128 sd
129 sd
130 sd
131 sd
132 sd
133 sd
134 sd
135 sd
253 device-mapper
254 mdp

也沒看出什麼端泥

root@m001 { /proc  }$ cat diskstats 
   1    0 ram0 0 0 0 0 0 0 0 0 0 0 0
   1    1 ram1 0 0 0 0 0 0 0 0 0 0 0
   1    2 ram2 0 0 0 0 0 0 0 0 0 0 0
   1    3 ram3 0 0 0 0 0 0 0 0 0 0 0
   1    4 ram4 0 0 0 0 0 0 0 0 0 0 0
   1    5 ram5 0 0 0 0 0 0 0 0 0 0 0
   1    6 ram6 0 0 0 0 0 0 0 0 0 0 0
   1    7 ram7 0 0 0 0 0 0 0 0 0 0 0
   1    8 ram8 0 0 0 0 0 0 0 0 0 0 0
   1    9 ram9 0 0 0 0 0 0 0 0 0 0 0
   1   10 ram10 0 0 0 0 0 0 0 0 0 0 0
   1   11 ram11 0 0 0 0 0 0 0 0 0 0 0
   1   12 ram12 0 0 0 0 0 0 0 0 0 0 0
   1   13 ram13 0 0 0 0 0 0 0 0 0 0 0
   1   14 ram14 0 0 0 0 0 0 0 0 0 0 0
   1   15 ram15 0 0 0 0 0 0 0 0 0 0 0
   8    0 sda 2912902 5836954 68738123 7169600 160459782 17123814 1395096183 25929156 0 13643852 33091376
   8    1 sda1 40 239 580 256 0 0 0 0 0 224 256
   8    2 sda2 119 381 638 256 0 0 0 0 0 228 256
   8    3 sda3 98 1738 2073 300 26 10 70 16 0 268 316
   8    4 sda4 4 0 8 48 0 0 0 0 0 48 48
   8    5 sda5 2912623 5834579 68734544 7168636 160459756 17123804 1395096113 25929140 0 13643356 33089664
 253    0 dm-0 9539 0 268418 38228 2335167 0 18681336 3292088 0 1955100 3331236
 253    1 dm-1 8687278 0 67271513 17692256 154407246 0 1209683729 24606260 0 8434120 42334020
 253    2 dm-2 12322 0 263170 11840 16610092 0 132880736 14888900 0 4044548 14900772
 253    3 dm-3 284 0 2266 952 2883732 0 23069856 468160 0 61080 469112
 253    4 dm-4 39746 0 928154 173252 1347557 0 10780456 917888 0 69840 1091140
 253    5 dm-5 75 0 600 304 0 0 0 0 0 52 304
  11    0 sr0 7 10 136 3248 0 0 0 0 0 3144 3248
   9    0 md0 0 0 0 0 0 0 0 0 0 0 0

有看到 sdx ,不過沒什麼用

root@m001 { /proc  }$ dmidecode | grep -i sas
root@m001 { /proc  }$ dmidecode | less
root@m001 { /proc  }$ dmidecode
# dmidecode 2.7
SMBIOS 2.6 present.
83 structures occupying 4569 bytes.
Table at 0xCF79C000.

Handle 0xDA00, DMI type 218, 11 bytes.
OEM-specific Type
        Header and Data:
                DA 0B 00 DA B2 00 17 00 0E 20 00

Handle 0x0000, DMI type 0, 24 bytes.
BIOS Information
        Vendor: Dell Inc.
        Version: 1.3.6
        Release Date: 10/30/2009
        Address: 0xF0000
        Runtime Size: 64 kB
        ROM Size: 4096 kB
......

連這個都沒有。最後試到

root@m001 { /proc  }$ dmesg | grep -i sas
megasas: 00.00.04.31-RH1 Tues. June. 15 14:13:02 EST 2010
megasas: 0x1000:0x0079:0x1028:0x1f17: bus 3:slot 0:func 0
 gen2: instance->base_addr = df1bc000<6>megasas: FW now in Ready state
megasas_init_mfi: fw_support_ieee=0<6>scsi0 : LSI SAS based MegaRAID driver

終於有了。不過,怎麼不是它 SPEC 上說的 PERC 6/xx , SAS 5/E 呢?

不過,這個 MegaRAID driver 到是很多人討論到,所以就跟著找下去了。然後,找到了 LSI MegaRaid – MegaCli Linux Commands 這篇,就照著它,去 LSI Web Site 下載它的命令列工具。我是用第二頁的 MegaRAID SAS MegaCLI - Linux, Version 1.01.39 這個檔案。把 rpm 裝一下唄

[root@qa1 ~]# rpm -Uvh MegaCli-1.01.39-0.i386.rpm

[root@qa1 ~]# rpm -ql MegaCli-1.01.39-0
/opt/MegaRAID/MegaCli/MegaCli
/opt/MegaRAID/MegaCli/MegaCli64

接著去看看 help 吧. 一堆 command(請小心使用,它可以直接修改,刪除 VD)。由於我只要查詢而已,所以就執行以下 command.

[root@qa1 ~]# /opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -aAll
                                     
Adapter #0

==============================================================================
                    Versions
                ================
Product Name    : PERC 6/i Integrated
Serial No       : 1122334455667788
FW Package Build: 6.2.0-0013

                    Mfg. Data
                ================
Mfg. Date       : 06/24/08
Rework Date     : 06/24/08
......

終於看到它是:PERC 6/i Integrated, 然後

[root@qa1 ~]# /opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -L0 -a0
                                     
Adapter 0 -- Virtual Drive Information:
Virtual Disk: 0 (target id: 0)
Name:
RAID Level: Primary-5, Secondary-0, RAID Level Qualifier-3
Size:696960MB
State: Optimal
Stripe Size: 64kB
Number Of Drives:6
Span Depth:1
Default Cache Policy: WriteBack, ReadAheadNone, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteBack, ReadAheadNone, Direct, No Write Cache if Bad BBU
Access Policy: Read/Write
Disk Cache Policy: Disk's Default

噔噔!終於出現了。原來是 RAID 5.

2012年1月2日 星期一

網路監控 : 活用 Nagios + ndo2db + Cacti + NPC (二)



2. 安裝 Apache, Mysql, Php
yum install httpd php php-mysql mysql mysql-server php-snmp net-snmp-utils

安裝完畢後,設定服務於 Server 啟動後,自動重啟
service httpd start     # Start httpd service
chkconfig httpd on      # Start after init

service mysqld start     # Start mysql service
chkconfig mysqld on      # Start after init

mysql 預設 root 密碼為 '' 空值,如要變更如下:
mysqladmin -uroot password '123456'  

Mysql for Cacti 配置, 資料庫名稱為 cactidb, 使用者為 cactier
mysql> CREATE DATABASE cactidb;
mysql> GRANT ALL ON cactidb.* TO cactier@'192.168.253.%' IDENTIFIED BY '123456';
mysql> FLUSH privileges;

基本配置完成,接下來安裝 rrdtool

3. 安裝 rrdtool

其中主要用到的是 rrdtool-1.2.27-3.el5.i386.rpm 和 rrdtool-devel-1.2.27-3.el5.i386.rpm 和rrdtool-php-1.2.27-3.el5.i386.rpm 這三個 packages.

yum install rrdtool rrdtool-devel rrdtool-php

4. 安裝 Cacti

效能問題:cacti 在做 polling 時,預設會使用 cmd.php 的方式去做,不過它的效能很差,所以需改用 Spine (Cactid)

Spine 使用 C 來取代呼叫 cmd.php ,在效能上提升很多。官方網頁也寫說 ,如果執行 php poller.php 時間超過 300 秒,就需要使用 Spine 。使用方法很簡單,照著官方網頁作就可以了,不在此贅述。個人是覺得 cmd.php 的方法該廢掉了,目前存在的意義只是因為 php 讓 cacti 達成跨平台的特性。

For cacti-spine package, download from here http://pkgs.repoforge.org/cacti-spine/cacti-spine-0.8.7g-1.el5.rf.x86_64.rpm , and then install cacti and spine.
yum install cacti-0.8.7g-1.el5.1.noarch.rpm
yum -y localinstall --nogpgcheck cacti-spine-0.8.7g-1.el5.rf.x86_64.rpm

根據 mysql 的設定,修改 spine.conf 的配置
DB_Host         192.168.1.100
DB_Database     cactidb
DB_User         cactier
DB_Pass         123456
DB_Port         3306

5. 安裝及配置 snmpd

# yum install net-snmp

在被監控的主機,配置 /etc/snmp/snmpd.conf
rocommunity public
#com2sec notConfigUser  default       public
com2sec readonly  default       public

syslocation Taipei
syscontact admin@yourdomain.com

測試 snmp
# snmpwalk -v 1 -c public 192.168.1.103 | less

SNMPv2-MIB::sysDescr.0 = STRING: Linux w1.yourdomain.com 2.6.18-238.1.1.el5 #1 SMP Tue Jan 4 13:32:19 EST 2011 x86_64
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (32300) 0:05:23.00
SNMPv2-MIB::sysContact.0 = STRING: admin@yourdomain.com
SNMPv2-MIB::sysName.0 = STRING: w1.yourdomain.com
SNMPv2-MIB::sysLocation.0 = STRING: Taipei
...

7. 配置 Cacti

建立 cacti 資料庫
# mysql -u root -p cactidb < /usr/share/doc/cacti-0.8.7g/cacti.sql
## 將 cacti.sql 資料庫文件導入,並輸入 root 密碼即可 
編輯 /usr/share/cacti/include/config.php,對應到 mysql 的設定
$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "192.168.100.1";
$database_username = "cactier";
$database_password = "123456";
$database_port = "3306";
先暫時把 selinux 關閉,不然不能以 web 執行 install
# setenforce 0
修改目錄權限, cacti 服務以 cacti 這個 unix user 在執行
# chown -R cacti /usr/share/cacti/rra
# chown -R cacti /usr/share/cacti/log
好了,下面就可以用 web 訪問 cacti 進行配置管理了。 筆者所用的 web ip 為 192.168.100.1 從瀏覽器直接訪問以下地址 即可看到 cacti 配置畫面 http://192.168.100.1/cacti/install/ 如果看到以下畫面,則可以進行之後的配置 如果上面全是 [FOUND] ,則可以點擊 Finish 完成,當中的路徑可能與圖片不同。 Finish 後就會出現登入畫面 用戶名 admin, 密碼 admin 即可登入(第一次登作後會強迫修改密碼) 等待 5~10 分鐘後,即會有圖形出現。 8. 安裝 NDOUtils 安裝 NDOUtils,NDOUtils 用來將 Nagios 的配置信息和各 event產生的數據存入資料庫,以實現這些數據的快速檢索和處理。http://packages.sw.be/ndoutils/ndoutils-1.4-0.beta7.3.el5.rf.x86_64.rpm
# yum install postgresql-libs-8.1.22-1.el5_5.1.x86_64 postgresql-8.1.22 perl-DBD-MySQL.x86_64
# rpm -ivh ndoutils-1.4-0.beta7.3.el5.rf.x86_64.rpm
配置 mysql for ndo
mysql> create database ndodb;
mysql> grant all privileges on ndodb.* to ndouser@'192.168.100.%' IDENTIFIED BY '123456';
mysql> grant all privileges on ndodb.* to ndouser@'192.168.100.%' IDENTIFIED BY '123456';
mysql> flush privileges;
載入 ndodb
root@h { /usr/share/ndoutils  }$ ./installdb -u ndouser -p 123456 -h 192.168.100.1 -d ndodb
編輯以下配置檔
/etc/nagios/nagios.cfg
/etc/nagios/ndo2db.cfg
/etc/nagios/ndomod.cfg
## /etc/nagios/nagios.cfg
broker_module=/usr/libexec/ndomod-3x.o config_file=/etc/nagios/ndomod.cfg
## /etc/nagios/ndo2db.cfg
socket_type=unix
socket_name=/var/nagios/rw/ndo.sock
db_servertype=mysql
db_host=192.168.100.1
db_name=cacti
db_user=cacti
db_pass=123456
db_prefix=npc_
## /etc/nagios/ndomod.cfg
output_type=unixsocket
output=/var/nagios/rw/ndo.sock
Restart nagios and cacti. 9. 安裝 NTop
# yum install ntop
設定 ntop admin 密碼
# ntop -A

Wed Nov  9 18:17:35 2011  NOTE: Interface merge enabled by default
Wed Nov  9 18:17:35 2011  Initializing gdbm databases

ntop startup - waiting for user response!

Please enter the password for the admin user: 
Please enter the password again: 
Wed Nov  9 18:17:41 2011  Admin user password has been set
10. Cacti 整合 NPC, Nagios 依據你的 npc 版本,下載 http://mirror.cactiusers.org/downloads/plugins/cacti-plugin-0.8.7g-PA-v2.8.tar.gz
# {/} tar xvfz cacti-plugin-0.8.7g-PA-v2.8.tar.gz 
# {/} cd cacti-plugin-arch/
# {/cacti-plugin-arch/} cd files-0.8.7g/
# {/cacti-plugin-arch/files-0.8.7g/} cp -rp * /usr/share/cacti/
# {/cacti-plugin-arch/files-0.8.7g/} cd /usr/share/cacti/
# {/usr/share/cacti/} patch -p1 -N < ~/cacti/cacti-plugin-arch/cacti-plugin-0.8.7g-PA-v2.8.diff
Modify /usr/share/cacti/include/global.php file
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "192.168.253.6";
$database_username = "cacti";
$database_password = "e29e776dbdd150c30c55171cb3bcd452";
$database_port = "3306";
$url_path = "/"; ## depend on your apache config
回到 Browser 介面 http://service_url/cacti 选择左下的 User Managenment 之后点击 admin 在其中最后一项打钩,并保存 ... 好了,现在 cacti 就支持其他插件功能了,下面把 ntop 和 nagios 加进去就可以了 http://docs.cacti.net/_media/plugin:ntop-v0.2-1.tgz 首先去下载cacti的ntop插件,而后解压至cacti的插件目录: # tar zxvf ntop-0.1.tar.gz -C /var/www/html/cacti/plugins/ 接着配置cacti的主配置文件,启用此插件: # vim /var/www/html/cacti/include/config.php 添加如下内容: $plugins[] = 'ntop'; For NPC https://api.opensuse.org/public/source/server:monitoring/cacti-npc/npc-2.0.4.tar.gz
root@img2 { ~/cacti/npc  }$ tar xvfz npc-2.0.4.tar.gz 
root@img2 { ~/cacti/npc  }$ cd ../
root@img2 { ~/cacti  }$ cp -rp npc /usr/share/cacti/plugins

接下来到cacti的控制台中"settings"中配置此插件,将其指向实际的ntop服务器所在的URL;然后再到cacti控制台的"user Management"中的admin用户中启用此插件即可。