lsiutil to add hot spare drive on line for mpt raid controllers

environment: HP ProLiant ML150 G5 with Ubuntu 8.04 installed

  • Run “mpt-status –i 1” to get the current array information.

    ioc0 vol_id 1 type IM, 2 phy, 231 GB, state DEGRADED, flags ENABLED
    ioc0 phy 0 scsi_id 2 ATA      GB0250C8045      HPG2, 232 GB, state ONLINE, flags NONE
    ioc0 phy 1 scsi_id 9 ATA      GB0250EAFJF      HPG1, 232 GB, state FAILED, flags OUT_OF_SYNC
  • Run “cat /proc/scsi/scsi” to get the available drives information
  • Run “lsiutil”
    • Select the correct port, you can find the information from the 1st step
    • Select 8, and then 16 to confirm the physical drive information, recommended
    • Then select 21 to enter “RAID actions”
    • Select 50 “Create hot spare”
    • You need to figure out the 2 parameters yourselves, I forgot to write down
    • 1st is something like the drive number, you have to compare the information I asked you to collect
    • 2nd is something like the spare group, I suggest you use the same number you use for “mpt-status –i”
    • Then if you select 2 “show physical disks” you will see your hot spare drive
    • Last we run 99 “reset port” to activate the hot spare.
    • Select 0 until you back to shell
  • Run “mpt-status –i 1” again to confirm it is now recovering
    ioc0 vol_id 1 type IM, 2 phy, 231 GB, state DEGRADED, flags ENABLED RESYNC_IN_PROGRESS
    ioc0 phy 2 scsi_id 2 ATA      GB0250C8045      HPG2, 232 GB, state ONLINE, flags NONE
    ioc0 phy 0 scsi_id 3 ATA      GB0250EAFYK      HPG1, 232 GB, state ONLINE, flags OUT_OF_SYNC

Ubuntu 1204 安装NUT监控APC UPS

安装相关程序

apt-get update
apt-get install nut nut-client nut-server

利用udev设定固定的设备文件名

在/etc/udev/rules.d/下面添加52-nut-usb.rules文件,以下是文件内容

# APC - usbhid-ups
SYSFS{idVendor}=="051d", SYSFS{idProduct}=="0002", MODE="664", GROUP="nut", ATTRS{serial}=="ASNNNNNNNNNN", SYMLINK+="ups-test01"

ASNNNNNNNNNN是你的APC UPS序列号,你可以直接在机器上找到,也可以用lsusb -v命令得到(iSerial字段)。

重启udev与ups驱动

udevadm control --reload-rule
udevadm trigger
upsdrvctl start

配置NUT
进入/etc/nut目录。

修改nut.conf文件,将MODE修改为netserver

MODE=netserver

修改ups.conf,在文件最后添加如下内容:

[ups-test01]
        driver = usbhid-ups
        port = /dev/ups-test01
        desc = "UPS-TEST01"
        serial = "ASNNNNNNNNNN"

修改upsd.conf,修改LISTEN字段,把127.0.0.1改为你希望监听的地址,如果监听所有地址,用0.0.0.0

LISTEN 0.0.0.0 3493

修改upsd.users,按如下格式添加用户,这里不详解用户权限了。

[upsclient]
        password = upsclient
        upsmon slave

[upsmaster]
        password = upsmaster
        upsmon master

修改upsmon.conf,添加MONITOR字段

MONITOR ups-test01@localhost 1 upsmaster upsmaster master

重启nut服务之后,ups就已经在监控之中了,你可以用下面的命令查看基本信息了

upsc ups-test01@localhost

添加网页控制页面
直接用命令虽然看的很全面,但是很多时候还是不太方便。nut也提供网页查看方式,设置起来也很方便。

安装相关的软件

apt-get install nut-cgi apache2

修改/etc/nut/hosts.conf,添加如下内容:

MONITOR ups-test01@localhost "UPS-TEST01"

修改apache设置,添加alias到/usr/share/nut下面,然后就可以在网页上查看监控内容了。

Exchange 日常管理:设置邮件转发 [转]

来源: http://blog.sina.com.cn/s/blog_472295620101cxg7.html

场景一:公司有一个Helpdesk的帮助台邮箱,为了方便查看,现在需要设置转发,将发给helpdesk的邮件全部转发到IT系统管理员曾垂鑫的邮箱中。

设置方法如下:

  1. 启动 Exchange 管理控制台。
  2. 在控制台树中,展开“收件人配置”,然后单击“邮箱”。
  3. 搜索helpdesk邮箱,在结果窗格中,右键单击邮箱,然后单击“属性”,如图所示
  4. 1

  5. 在“<邮箱>属性”中的“邮件流设置”选项卡上,单击“传递选项”,然后单击“属性”,如图所示
  6. 2

  7. 单击“转发到”复选框。这将启用“浏览”按钮。如图所示
  8. 3
    注意:如果要将传入邮件传递到邮箱以及所配置的转发地址,请选中“将邮件同时传递到转发地址和原始收件人的邮箱”复选框。如果清除此复选框,则转发所有传入邮件,而不在邮箱中保留副本。

  9. 单击“浏览”打开“选择收件人”对话框。选择要向其转发邮件的收件人,然后单击“确定”。如图所示
  10. 4
    5
    如此设置之后,凡是发往helpdesk的邮件,都将被转发一份副本给曾垂鑫的邮箱。

场景二:曾垂鑫想对其收到的邮件做一个外部邮件系统的副本备份,凡是发给曾垂鑫的邮件都将转发到一个外网的邮箱zengchuixin@126.com中

设置方法如下:

首先我们需要在内部邮件系统为外网的邮箱zengchuixin@126.com增加一个联系人账户。如图所示
6
7
8
9
10
11

然后我们需要修改曾垂鑫邮箱的邮件流设置,首先找到曾垂鑫这个账户,然后选择属性,并切换到邮件流设置选项卡,选择【传递选项】,并点击【属性】,如图所示

12

转发地址设置为我们的外部联系人账户,如图所示

13

然后我们可以发邮件进行测试,让helpdesk给曾垂鑫发一封邮件,可以发现发给曾垂鑫的邮件又被成功地转发到了外网邮箱,外网邮箱成功收到了转发的邮件,如图所示
14

PIN the kernel to the current version in apt

create a new file under /etc/apt/preferences.d with the following content

Package: linux-server
Pin: version 3.2.0.23.25
Pin-Priority: 1001

Package: linux-image-server
Pin: version 3.2.0.23.25
Pin-Priority: 1001

Package: linux-headers-server
Pin: version 3.2.0.23.25
Pin-Priority: 1001

then run

apt-get update
apt-get dist-upgrade

you will find that you won’t get the kernel upgrade notice any more.

you can find you current kernel version with

dpkg -l|grep linux

MegaCli命令速查[转]

转自http://hi.baidu.com/ytjwt/blog/item/6d2dfd108c85db70cb80c4e1.html

最近,老是磁盘error,而自己确没有迅速的定位,实在是感到杯具,看到同事们MegaCli查看raid及磁盘错误信息,我这里粘贴下网上别人用的命令,方便自己查阅(另dmesg:显示开机信息,dmidecode,硬件信息)

MegaCli用起来还是很简单的。摘抄一些比较常用的参数如下:

显示适配器个数: MegaCli -adpCount
显示适配器时间: MegaCli -AdpGetTime –aALL
显示所有适配器信息: MegaCli -AdpAllInfo -aAll
显示所有逻辑磁盘组信息: MegaCli -LDInfo -LALL -aAll
显示所有的物理信息: MegaCli -PDList -aAll
查看充电状态: MegaCli -AdpBbuCmd -GetBbuStatus -aALL |grep ‘Charger Status’
显示BBU(后备电池)状态信息: MegaCli -AdpBbuCmd -GetBbuStatus -aALL
显示BBU容量信息: MegaCli -AdpBbuCmd -GetBbuCapacityInfo -aALL
显示BBU设计参数: MegaCli -AdpBbuCmd -GetBbuDesignInfo -aALL
显示当前BBU属性: MegaCli -AdpBbuCmd -GetBbuProperties -aALL
显示Raid卡型号,Raid设置,Disk相关信息: MegaCli -cfgdsply -aALL
查看Cache 策略设置: MegaCli -cfgdsply -aALL |grep Policy
查看充电进度百分比: MegaCli -AdpBbuCmd -GetBbuStatus -aALL |grep ‘Relative State of Charge’

当挂载一磁盘到raid卡上时,是通过fdisk -l查看不了的。我们需要对其做raid,

在线创建raid:

MegaCli -CfgLdAdd -r0 [1:10] WB Direct -a0
MegaCli -CfgLdAdd -r0 [1:11] WB Direct -a0
echo "scsi add-single-device 0 2 1 0" >/proc/scsi/scsi
echo "scsi add-single-device 0 2 2 0" >/proc/scsi/scsi

这样在fdisk -l 就能看到了

RAID 5时,当磁盘坏了,备盘变为online后,如果坏的磁盘已经修好,那么我们需要把修好的盘变为备盘,命令如下:

MegaCli -PDHSP -Set [-EnclAffinity] [-nonRevertible] -PhysDrv[1:5] -a0
# MegaCli -PDHSP -set -PhysDrv[A:B] -aC
A:  it’s Enclosure Number
B: It’s Slot NUmber
C: It’s Array ID2

各种设备和磁盘的不同状态:

Device         |Normal|Damage|Rebuild|Normal
Virtual Drive     |Optimal|Degraded|Degraded|Optimal
Physical Drive     |Online|Failed –> Unconfigured|Rebuild|Online

完整的操作手册在这里:http://www.lsi.com/DistributionSystem/AssetDocument/80-00156-01_RevF.pdf

VMware ESXi的OpenVPN的Bridge模式

参考http://www.jeremycole.com/blog/2010/03/11/openvpn-bridge-under-vmware-esxi/

前段时间在ESXi里面架了一个小防火墙,用openvpn时想使用bridge模式直接拨入内网,可是设置好之后,无论如何VPN客户端都不能与内网机器进行通讯。查了下原因,原来是ESXi的网络promiscous模式问题,ESXi虚拟交换机在默认情况下会丢失所有的promiscous包。

要解决很简单,用vSphere Client连接到ESXi,然后在”Configuration”标签中选中”Networking” ,然后再选中对应的虚拟交换机的”Properties…”。在跳出来的对话框中,选中”vSwitch”,然后点”Edit”。最后在”Security”标签中,把”Promiscuous Mode”改为”Accept”。

之后,OpenVPN的桥接模式就会生效了~~~

apache强制https

利用mod_rewrite,一段很简单的代码就搞定了。。。。

RewriteEngine on
RewriteCond %{HTTPS}   !^on$   [NC]
RewriteRule   .   https://%{HTTP_HOST}%{REQUEST_URI}    [L]

然后,不管你访问网站的的什么页面,都会自动跳转到https。

postfix 只允许指定的用户给特定的别名发送邮件

本文出自 “一个SA的工作和学习记录” 博客,请务必保留此出处http://chlotte.blog.51cto.com/318402/404764

公司需求:只有公司高层才可以向全体员工发送邮件,除此之外,均无权向全体员工发送邮件。

公司高层邮箱:

wanglujing@ourgame.com
renlina@ourgame.com
caiyanyan@ourgame.com
qinwen@ourgame.com
shiwanting@ourgame.com

全体员工邮箱:qtyg@ourgame.com

postfix相关概念如下,具体的请参考《postfix权威指南》,在第十一章 反垃圾邮件 中讲的很清楚,下面引用了其部分参数:

Smtmpd_restriction_classes

自定义规范等级的名称,列出管理员自定义的所有规范等级,每一组规范等级,都是由一系列UBE限制条件组成。

Check_client_access 客户端
Check_sender_access 发件人
Check_recipient_access 收件人

Check_recipient_access maptype:mapname
Check_recipient_access 指向一个含有邮件地址、网域名称、人名的访问表,用于对比客户端在RCPT TO命令中提供的收件地址,如果发现相符的索引键,则postfix执行相对应的值所提定的动作。

Check_sender_access maptype:mapname
Check_sender_access 指向一个含有邮件地址,网域名称,人名的访问表,用于对比客户端在MAIL FROM命令中提供的寄件人邮件地址,如果发现相符的索引键,则postfix执行相对应的值所指定的动作。

SMTP对话过程以各阶段对应的限制条件:
动作如下:
OK: 通过当前过滤规则的检查,postfix继续检查下一组过滤规则。
REJECT: 拒绝邮件.后面可以加上一段简短信息,说明拒绝的理由,这段信息会连同拒绝码一起返回给客户端,并且被记录在postfix日志文件中。

解决方法如下:
1,定义规范等级,名称分别为local_only与local_only1,修改main.cf

[root@mail postfix]# vi main.cf
#youshengtao 2010-10-12
smtpd_restriction_classes = local_only, local_only1
local_only = check_recipient_access hash:/etc/postfix/plugin/plugin.list,reject
local_only1 = check_sender_access hash:/etc/postfix/plugin/plugin.users,reject
smtpd_recipient_restrictions =
   reject_unknown_sender_domain,
   reject_unknown_recipient_domain,
   reject_non_fqdn_sender,
   reject_non_fqdn_recipient,
   reject_unlisted_recipient,
   check_sender_access hash:/etc/postfix/plugin/plugin.users,        #new added
   check_sender_access hash:/etc/postfix/plugin/local_senders,       #new added
   check_recipient_access hash:/etc/postfix/plugin/local_recipients, #new added
   permit_mynetworks,
   permit_sasl_authenticated,
   reject_unauth_destination,
   reject_non_fqdn_helo_hostname,
   reject_invalid_helo_hostname,
   check_policy_service inet:127.0.0.1:10031

2,建立相关的目录,也可以不建目录,直接放在postifx目录下面,不过,为了以后维护方便,我还是建了一个目录。

[root@mail ~]# mkdir -p /etc/postfix/plugin
[root@mail ~]# cd /etc/postfix/plugin/
[root@mail plugin]#cat local_recipients
qtyg@ourgame.com local_only1
[root@mail plugin]# cat local_senders
wanglujing@ourgame.com local_only
renlina@ourgame.com    local_only
caiyanyan@ourgame.com  local_only
qinwen@ourgame.com     local_only
shiwanting@ourgame.com  local_only
[root@mail plugin]# cat plugin.list
qtyg@ourgame.com OK
[root@mail plugin]# cat plugin.users
wanglujing@ourgame.com OK
renlina@ourgame.com    OK
caiyanyan@ourgame.com  OK
qinwen@ourgame.com     OK
shiwanting@ourgame.com OK

3,使用postmap将下列的文件转换成postfix可直接查询的格式。

postmap hash:/etc/postfix/plugin/plugin.list
postmap hash:/etc/postfix/plugin/plugin.users
postmap hash:/etc/postfix/plugin/local_senders
postmap hash:/etc/postfix/plugin/local_recipients

4,重载postfix后,邮件服务器正常工作,实现了我们需要的功能。

[root@mail npc]# service postfix reload
重新载入postfix:[确定]

备注:不要忘记第3步,否则服务器会不能收发任何邮件,日志中会有如下提示:

Oct 12 13:55:15 mail postfix/smtpd[875]: fatal: open database /etc/postfix/plugin/recipient_list.db: No such file or directory
Oct 12 13:55:16 mail postfix/master[2266]: warning: process /usr/libexec/postfix/smtpd pid 875 exit status 1
Oct 12 13:55:16 mail postfix/master[2266]: warning: /usr/libexec/postfix/smtpd: bad command startup -- throttling