LSI MegaSAS RAID 驱动 BUG

表现为使用MegaCli工具在线创建或者移除VD时不更新linux的设备文件,只有重启后才能更新。

已知在内核驱动/drivers/scsi/megaraid/megaraid_sas.c的00.00.04.17.1-rc1版本修复。

另外,DELL、IBM等某些服务器上,不使用RAID卡会出现硬盘的slot编号和linux的设备文件顺序不一致的情况,据说创建单盘RAID0能够解决。

Posted in 运维 | Tagged , , , | 1 Comment

关于moosefs的changelog

如果metalogger和master的连接中断过,那么moosefs metalogger的changelog可能会丢失部分log,导致使用mfsmetarestore的时候失败。所以mfs迁移master不推荐使用metalogger进行restore。可以考虑rsync或者共享存储,如drbd。

Posted in moosefs | Tagged , , , | 3 Comments

puppet的generate函数

这个函数不能直接执行shell脚本,需要/usr/bin/env等做为第一个参数,如:

$hostalias = generate("/usr/bin/env", "/tmp/genhname.sh", "172.16.0.133")

其次,这个函数的执行的是master上的脚本,它仅仅是将client上的变量拿回来,在本地执行;也就是说/tmp/genhname.sh要位于master的相应路径上,且有执行权限,不需要将脚本文件分发到client。

Posted in puppet, 运维 | Tagged , | 5 Comments

puppet dashboard的安装

以下过程基于debian:

系统要求:
ruby >= 1.8.1
rake >= 0.8.3 (在lenny里版本不够,需要squeeze,不过我觉得使用gem应该也能装)
mysql
ruby mysql bindings(我个人觉得对应的包为libmysql-ruby,不过网上的另一个deb包依赖的是dbconfig-common libdbd-mysql-ruby)

安装过程:

1. 获得最新源码:

git clone git://github.com/reductivelabs/puppet-dashboard.git

2. 设置数据库:

cd puppet_dashboard/config
cp database.yml.example database.yml

编辑database.yml,在development域中加入数据库用户名、密码,然后进行数据库初始化(确保mysql服务已经启动):

rake install

(中间可能需要运行rake gem:install)

3.设置puppetmaster:

部署lib文件:(在puppet 2.6版本中不再需要)

cp  puppet_dashboard/lib/puppet/puppet_dashboard.rb  /usr/lib/ruby/1.8/puppet/reports/

这点和readme中描述不符,不过作者的方法怎么实验都不成功。:(

然后在/etc/puppet/puppet.conf的puppetmasterd域中加入:

reports = puppet_dashboard

Puppet 2.6版本是:

reports = http

可以写多种方法,用逗号分隔,比如:

reports = puppet_dashboard, log, store

最后重启服务端

4.运行dashboard server

script/server

5.设置puppet client:

在/etc/puppet/puppet.conf的puppetd域加入:

report = true

重启客户端

如果没有意外,dashboard将会接收到新的report,访问http://localhost:3000/进入web界面。

如果想将以前的report导入,在dashboard目录运行:

rake reports:import

如果reportdir不是/var/lib/puppet/reports则运行:

rake reports:import REPORT_DIR=/path/to/your/reports

如果时区显示有问题,在config/enviroment.rb文件中修改:

config.time_zone = 'Beijing'

参考:

1. http://docs.puppetlabs.com/guides/installing_dashboard.html

2.http://zcentric.com/2010/03/11/install-puppet-dashboard-on-redhatcentos-5/

Posted in puppet, 运维 | Tagged , | 3 Comments

关于puppet的import

import "autofs"
import "autofs/init.pp"
import "autofs/util/stuff.pp"

第一句与第二句会在模块路径中寻找autofs/manifests/init.pp并载入。
第三句只载入autofs/util/stuff.pp文件。

puppet 0.23.1之后的版本,位于modulepath下(默认是/etc/puppet/modules)的模块会被自动载入,所以不需要手动载入此目录下的各个模块了。

当你引用autofs模块中的craziness类时,puppet会自动在autofs模块下寻找craziness.pp文件中的这个类。使用这个技巧就可以不在模块的init.pp中写入额外的import了。

Posted in puppet | Tagged , , | Leave a comment

python全局变量与命名空间

[python]
KEY_WORD = "A"

def temp():
print KEY_WORD
KEY_WORD = "B"
[/python]

这段代码运行会提示变量KEY_WORD在定义前使用。原因是因为一旦在函数中修改全局变量,则python会将全局变量认成局部变量,在函数的命名空间内寻找其定义。如果要修改全局变量,要在函数内使用global关键字进行声明。如下:

[python]
KEY_WORD = "A"

def temp():
global KEY_WORD
print KEY_WORD
KEY_WORD = "B"
[/python]

当然,我个人更倾向将全局变量只作为常量。

Posted in Code, Python | Tagged , , | Leave a comment

shell中的$@与通配符

$@在shell中表示所有参数,与$*不同的是,$@中的每个参数都相当于被双引号包含的独立字符串。

然而如果使用通配符传递文件名的时候,如果文件名中包含空格,$@会将包含空格的文件名理解成数个文件,这时只要使用引号将通配符引起再传递或者使用”$@”就可以了。

Posted in Code | Tagged , , | Leave a comment

Apache在子目录取消访问控制

Removing controls in subdirectories

The following example shows how to use the Satisfy directive to disable access controls in a subdirectory of a protected directory. This technique should be used with caution, because it will also disable any access controls imposed by mod_authz_host.
[code gutter="false" highlight="7"]
<Directory /path/to/protected/>
Require user david
</Directory>
<Directory /path/to/protected/unprotected>
# All access controls and authentication are disabled
# in this directory
Satisfy Any
Allow from all
</Directory>

[/code]

截取自apache 2.2手册http://httpd.apache.org/docs/2.2/mod/core.html#require

Posted in 运维 | Tagged , , | 2 Comments

Marvell 88E8056 网卡驱动

在Marvell官网有linux 2.6内核驱动下载,然而在2.6.32内核上以模块形式编译安装时总是出错

/tmp/Sk98IAfiDEcqKrUTbOYRkXjlT/all/skge.c: In function ‘SkGeTestIsr’:
/tmp/Sk98IAfiDEcqKrUTbOYRkXjlT/all/skge.c:1750: error: ‘TASK_NORMAL’ undeclared (first use in this function)
/tmp/Sk98IAfiDEcqKrUTbOYRkXjlT/all/skge.c:1750: error: (Each undeclared identifier is reported only once
/tmp/Sk98IAfiDEcqKrUTbOYRkXjlT/all/skge.c:1750: error: for each function it appears in.)
/tmp/Sk98IAfiDEcqKrUTbOYRkXjlT/all/skge.c: In function ‘SkGeTestMsi’:
/tmp/Sk98IAfiDEcqKrUTbOYRkXjlT/all/skge.c:1780: warning: passing argument 2 of ‘request_irq’ from incompatible pointer type
/tmp/Sk98IAfiDEcqKrUTbOYRkXjlT/all/skge.c:1790: error: ‘TASK_UNINTERRUPTIBLE’ undeclared (first use in this function)
/tmp/Sk98IAfiDEcqKrUTbOYRkXjlT/all/skge.c:1790: error: implicit declaration of function ‘schedule_timeout’

根据readme的步骤,以patch的方式打到内核里就没有问题了。

Posted in 应用 | Tagged , , | Leave a comment

find的exec参数

find的-exec参数执行命令时,当前目录是执行者运行find程序时所在的目录。如果需要在执行命令时进入匹配项所在目录,使用-execdir参数。两者均不能识别命令中的通配符,可以通过间接调用一个单行脚本来解决。

Posted in 应用 | Tagged , , | Leave a comment