headermask image

header image

Learning IPMI

IPMI 是 Intelligent Platform Management Interface (智能平台管理接口)的缩写。
IPMI 规格说明定义了一组可以被系统管理员用来监测和管理计算机系统的通用接口。
IPMI 独立运作于操作系统之外,并且允许管理员在没有操作系统或者系统管理软件存在的情况下远程管理计算机系统,甚至在系统关机的状态下也可以(但是系统需要接上电源)。

参考链接:
http://en.wikipedia.org/wiki/IPMI
http://en.wikipedia.org/wiki/Baseboard_Management_Controller
http://www.intel.com/design/servers/ipmi/
http://sourceforge.net/projects/openipmi/
http://sourceforge.net/projects/ipmitool/
http://sourceforge.net/projects/ipmiutil/

Gentoo Linux installation 2

昨天由于晚上临时加班,没有来得及安装 GNOME,但也不是没有折腾 Gentoo,而是参照 LinuxSir 论坛中的安装 Gentoo 疑难解答先升级了一次基本系统:

emerge –sync
emerge -avuDN world

man emerge 可以看到 –sync 选项用来启动一次 Portage 树的更新,而更新所使用的 rsync.gentoo.org 镜像是之前安装过程中使用 mirrorselect 来进行选择和设定的。另外,这里还涉及到了为 rsync 设置代理的问题,man rsync 会告诉你设置 RSYNC_PROXY 环境变量即可,每次都 export 会比较麻烦,于是我就把它加到了 /etc/make.conf 中。

剩下的 -a, -v, -u, -D 和 -N 选项的具体意义看看 man emerge 也都一目了然了。最后的 world 是 2 大软件包集合之一,另一个是 system。

今天早上,什么文档都还没有看,就先直接依葫芦画瓢的来了个 emerge -avuDN gnome (事实证明这样是会出问题的),开始 GNOME 安装的漫漫长路,260+ 的包需要全新安装。

结果第一个问题出现了,在安装 gtk+ 时报错了,错误信息告诉我是因为 cairo 需要在 USE 标记中设置 X 标记,把 X 加到 /etc/make.conf 的 USE 中去,然后再次 emerge -avuDN gnome 就过去了。

后来又遇到一个错误,又需要添加了 gtk 到 USE 中,看来这样下去不是办法,只好求助于 Google,结果就搜到了 GNOME 配置指南这篇官方的中文文档,终于有了个 USE 的范例:

USE=”-qt3 -qt4 -arts -kde X dbus gtk gnome hal avahi

只是其中的 avahi 在后来安装 cups 时又遇到了问题,被我拿掉了,其它都保留了下来。

后面的步骤就完全照着这篇文档来了,就此搞定了 GNOME 的安装。

值得一提的是文档中为 gnome-base/gnome-session 这个包单独设置 branding 标记的方法:

echo “gnome-base/gnome-session branding” >> /etc/portage/package.use

在后来安装 net-misc/vnc 时又被我依葫芦画瓢了一次:

echo “net-misc/vnc server” >> /etc/portage/package.use

只有设置了 server 标记,vncserver 才会被包括在安装中,否则默认情况下 emerge vnc 只会生成 vncviewer。

最后,详细的中文 Portage 入门可以看这里,中文 USE 标记使用可以看这里

Gentoo Linux installation 1

昨天第一次尝试安装 Gentoo Linux 失败了,用的是其最新发布的 Gentoo 2008.0 LiveCD。用 LiveCD 启动电脑,进入 GUI 环境,用 Gentoo Linux Installer (GLI) 进行安装,貌似遇到了 Gentoo Bug 231037,install.log.failed 中的报错信息和 Bug 中的相同。失败的安装还弄乱了硬盘上的分区编号,原本挂载 Debian 根分区的 /dev/sda7 莫名变成了 /dev/sda5,导致从硬盘重启后遇到 GRUB Error 17,之后在 GRUB 菜单中手工修改了 root 和 kernel 的值,指向 /dev/sda5 才后再 boot,成功进入 Debian。最后还要记得进入系统之后编辑 /boot/grub/menu.lst 中对应的行。安装 Gentoo 失败之后向 Gentoo 中文发邮件求助,r0bertz 回复说 GLI 不是推荐的安装方法,应当按照手册用 stage3 一步一步地进行安装。

不甘心失败,今天继续实验。有了昨天的经验,今天的我至少已经不怕无法启动昨晚刚刚升级到 lenny 的 Debian 了。找到另外一个 Gentoo Linux x86 快速安装指南CU 上的一篇 Gentoo 安装精华贴之后,开始动手。

还是用昨天的 LiveCD 启动电脑,用 gentoo 来启动之后,这次不进 GUI 界面了,直接 Ctrl + Alt + F1 进入终端模式。

net-setup 也不用了,LiveCD 已经帮我搞定(可用 /sbin/ifconfig -a 进行验证)。

fdisk -l /dev/sda 找到了昨天本来建好给 Gentoo 用的 /dev/sda7 (swap) 和 /dev/sda8 (/)。

mke2fs -j /dev/sda8
mkswap /dev/sda7
swapon /dev/sda7

挂载文件系统:

mount /dev/sda8 /mnt/gentoo
mkdir /mnt/gentoo/boot
cd /mnt/gentoo

从镜像站点下载 stage3 的压缩包并解开:

export http_proxy=你的代理服务器地址:端口
wget -c http://ftp.jaist.ac.jp/pub/Linux/Gentoo/releases/x86/current/stages/stage3-i686-2008.0.tar.bz2
tar xjf stage3-i686-2008.0.tar.bz2

下载最新的 Portage 快照的压缩包并解开:

wget -c http://ftp.jaist.ac.jp/pub/Linux/Gentoo/snapshots/portage-latest.tar.bz2
tar xjf portage-latest.tar.bz2

后面完全按照手册,直到安装完引导程序 GRUB 之后。由于手册中的 grub.conf (menu.lst) 文件内容非常简单,只考虑了启动刚刚安装的 Gentoo,还需要手工加上我的 Debian:

title Debian GNU/Linux 5.0 Lenny
root (hd0,4)
kernel /boot/vmlinuz-2.6.26-1-686 root=/dev/sda5 ro
initrd /boot/initrd.img-2.6.26-1-686

之后就可用退出 chroot 环境,卸载所有文件系统并重启电脑了:

umount /mnt/gentoo/proc /mnt/gentoo
reboot

回来之后就有一个基本的 Gentoo Linux 可用了,总共花去了大概 2 个小时,这时候 GNOME 还没装呢,明天再继续折腾。

Blue bird

羽ばたいたら 戻らないと言って

目指したのは 蒼い 蒼い あの空

The Perl Debugger

今天同事老铁问了我几个关于 Perl 的编程的小问题,包括 @ARGVGetopt::Long 的使用。其间还使用到了 Perl 自带的 debugger,其实这个工具我也不是第一次使用了,但是平时用得少,印象中存留的就剩下 s 和 x 命令了。在调试一个对 Getopt::Long::GetOptions 的调用的时候,用 s 进入了函数的内部半天没有能够出来,后来 Google 了一下,找到了一个 Perl Debugger Quick Reference Card 的 PDF 文档,用 r 命令快速地来到了 GetOptions 的结尾。

另外,这篇文章是我第一次尝试使用 ScribeFire 这个 FireFox 插件来写 Blog,顺便试试能不能同步到 jarodwang.cn 上面去。

10g OCP preparation

CONTROL_FILE_RECORD_KEEP_TIME specifies the minimum number of days before a reusable record in the control file can be reused.

DB_FLASHBACK_RETENTION_TARGET specifies the upper limit (in minutes) on how far back in time the database may be flashed back. How far back one can flashback a database depends on how much flashback data Oracle has kept in the flash recovery area.

By default, the change tracking file is created as an Oracle managed file in DB_CREATE_FILE_DEST.

Oracle Database provides database resource management capability through its Database Resource Manager. The main goal of the Database Resource Manager is to give the Oracle Database server more control over resource management decisions, thus circumventing problems resulting from inefficient operating system management.

DBVERIFY is an external command-line utility that performs a physical data structure integrity check. It can be used on offline or online databases, as well on backup files. You use DBVERIFY primarily when you need to ensure that a backup database (or datafile) is valid before it is restored, or as a diagnostic aid when you have encountered data corruption problems.

You must have a flash recovery area enabled, because flashback logs can only be stored in the flash recovery area. For Real Application Clusters databases, the flash recovery area must be stored in a clustered file system or in ASM.

When flashback is enabled or when there are guaranteed restore points, the background process RVWR writes flashback data to flashback database logs in the flash recovery area.

Database Resource Manager (DRM) allocates resources among resource consumer groups based on a resource plan. A resource plan consists of resource plan directives that specify how resources should be distributed among the groups. Resource consumer groups are categories to which user sessions can be assigned. These groups can then be allocated resources through plan directives.

A sample program for stat()

stat() is a Unix system call that returns useful data about a file inode.

今天在看一个 strace 的输出时,看到下面的一行:

19:42:00.545797 stat64(”/cdctest/orahome”, {st_mode=S_IFDIR|0755, st_size=8192, …}) = 0

Google 之后发现 stat64 背后就是 stat() 系统调用,这里有详细的介绍。

于是一时手痒,想自己写一个简单的程序来实验一下,就在自己的 PC 机(跑的是 Debian “etch” 4.0r5)上动手。

首先是搭建编译环境:

# apt-get install gcc build-essential

然后coding如下:

?Download test_stat.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdio .h>
#include <stdlib .h>
#include <string .h>
#include <errno .h>
#include <sys /stat.h>
 
int main()
{
	struct stat *buf;
	const char *path = "/home/ftp/upload";
 
	buf = (struct stat *) malloc(sizeof(struct stat));
	memset(buf, 0, sizeof(struct stat));
 
	int ret; 
 
	ret = stat("/home/ftp/upload", buf);
 
	if (ret == EACCES)
	{
		printf("EACCES\n");
		free(buf);
		buf = NULL;
		exit(-EACCES);
	}
 
	printf("%d\n", buf->st_mode);
 
	if (S_ISDIR(buf->st_mode))
	{
		printf("%s is a diretory.\n", path);
	}
	else
		printf("%s is NOT a directory.\n", path);
 
	free(buf);
	buf=NULL;
 
	return 0;
}
</sys></errno></string></stdlib></stdio>

编译生成可执行文件

jarod@zhenwan:~$ gcc -o test_stat test_stat.c

运行之:

jarod@zhenwan:~$ ./test_stat
16895
/home/ftp/upload is a diretory.

大功告成。

最后还可以自己 strace 一把:

Keep Reading »

水母·流星

如果可以找到水母·流星

你的名字将浮现在我脑海