您的位置:首页 > 其它

Ubuntu 10.04 安装配置 PVFS2 手记

2012-05-09 09:36 639 查看
由于项目需要,试用和学习PVFS2,下面记录安装过程,以方便其他初用者安装。

英文指南参见http://www.pvfs.org/cvs/pvfs-2-8-branch-docs/doc/pvfs2-quickstart/pvfs2-quickstart.php

安装

特定针对安装环境Ubuntu 10.04 Desktop

首先切换到root权限,以方便后续操作:

basicthinker@ubuntu:~$ sudo -s
安装SSL的开发库和头文件等,可能用于PVFS2的网络通讯:

root@ubuntu:~# apt-get install libssl-dev
安装Berkley DB的静态库和头文件等,用于PVFS2的存储:

root@ubuntu:~# apt-get install libdb-dev
安装AIO的库(This library enables userspace to use Linux kernel asynchronous I/O system calls, important for the performance of databases):

root@ubuntu:~# apt-get install libaio-dev
下载PVFS2的源码http://www.pvfs.org/download/ ,拷贝解压到/usr/src目录下:

root@ubuntu:/home/basicthinker/Downloads# cp pvfs-2.8.2.tar.gz /usr/src

root@ubuntu:/home/basicthinker/Downloads# cd /usr/src

root@ubuntu:/usr/src# tar -xzf pvfs-2.8.2.tar.gz
编译源码:

root@ubuntu:/usr/src# cd pvfs-2.8.2

root@ubuntu:/usr/src/pvfs-2.8.2# ./configure

我的结果是:

***** Displaying PVFS Configuration Information *****

------------------------------------------------------

PVFS2 configured to build karma gui : no

PVFS2 configured to perform coverage analysis : no

PVFS2 configured for aio threaded callbacks : yes

PVFS2 configured to use FUSE : no

PVFS2 configured for the 2.6.x kernel module : no

PVFS2 configured for the 2.4.x kernel module : no

PVFS2 configured for using the mmap-ra-cache : no

PVFS2 will use workaround for redhat 2.4 kernels : no

PVFS2 will use workaround for buggy NPTL : no

PVFS2 server will be built : yes

PVFS2 version string: 2.8.2

再运行:

root@ubuntu:/usr/src/pvfs-2.8.2# make

root@ubuntu:/usr/src/pvfs-2.8.2# make install

单机配置 (本机同时扮演metadata server、I/O server和client的角色)

生成配置文件:

root@ubuntu:~# pvfs2-genconfig /etc/pvfs2-fs.conf

这是个交互式脚本,一般选项都默认即可(直接按Enter跳过),只有一个

* Enter hostnames [Default is localhost]:

需要设置为本机的hostname,可以另开控制台输入hostname查看本机的值,我的设置为"ubuntu"。
第一次启动PVFS2服务要首先分配空间,添加参数-f:

root@ubuntu:~# pvfs2-server /etc/pvfs2-fs.conf -f

其后启动服务则不需加参数,或使用-d使得服务运行于前台(占用当前终端窗口,终端窗口关闭后服务终止):

root@ubuntu:~# pvfs2-server /etc/pvfs2-fs.conf
可以设置该服务为开机自启动:

编辑文件/etc/rc.local,在结尾“exit 0”前添加行:

pvfs2-server /etc/pvfs2-fs.conf

(不必包含"sudo",启动阶段等同根权限)。
因为是单机,需要同时配置client,首先设置挂载点,创建目录:

root@ubuntu:~# mkdir /mnt/pvfs2

然后在/etc/fstab文件末尾添加行,其中"ubuntu"为本机的hostname,请读者注意替换:

tcp://ubuntu :3334/pvfs2-fs /mnt/pvfs2 pvfs2 defaults,noauto 0 0
验证安装:

basicthinker@ubuntu:~$ pvfs2-ping -m /mnt/pvfs2

会显示若干验证信息,最后显示 "The PVFS2 filesystem at /mnt/pvfs2 appears to be correctly configured." 即为正常。

可实验将任意文件拷贝到PVFS2文件系统中而后查看:

basicthinker@ubuntu:~$ pvfs2-cp -t ~/Documents/some_file /mnt/pvfs2

Wrote 19 bytes in 0.003468 seconds. 0.005225 MB/seconds

basicthinker@ubuntu:~$ pvfs2-ls /mnt/pvfs2

some_file

lost+found

我们使用用户态的接口,需要pvfs2前缀;最后一行显示的"lost+found"是系统默认包含的文件夹。
【注意】如果想重新安装PVFS2,需要删除设置的数据存储目录(在本节第1步中,默认为/pvfs2-storage-space),而后重复上述过程,否则会产生冲突。

集群配置 (metadata server、I/O server和client分布在多个节点)

个人测试环境推荐VMware Workstation虚拟多个主机,有Team功能,可方便地同时操作多个虚拟机;更重要的是有“克隆”功能,省去很多重复安装配置。
在主界面单机File—New—Team,根据向导建立Team,这里称作"PVFS2 Team"。完成后,在左侧导航栏,右键单击"PVFS2 Team",选择Settings,在Virtual Machines选项卡下可添加虚拟机。
首先添加一个New Virtual Machine,安装Ubuntu 10.04 Desktop(注意一并安装常用包如SSH)以及PVFS2(参照上述“安装”一节);而后添加新的节点,只需选择New Clone of Virtual Mahine进行克隆,不必重复繁琐的安装过程。

这里我们开启3个虚拟节点,其中node1、node2为I/O server,node2、node3为metadata server。
配置VMware虚拟集群:

我选择的是NAT网络,因为它既可以使用保留地址组建局域网(虚拟机之间通讯),又可以访问广域网,使用起来较为方便。参照本节步骤2打开Team Settings,在Connections选项卡下勾选各个节点为NAT。

而后打开VMware配套工具Virtual Network Editor,查看相应NAT网络的NAT Settings,记录Gateway IP,本人这里是192.168.11.2。

在各个节点,编辑/etc/network/interfaces文件如下(以node1为例,"eh1"为其连接名,注意 不同节点可能不同):

auto eth1

iface eth1 inet static

address 192.168.11.201

netmask 255.255.255.0

gateway 192.168.11.2

其余node可依次分配IP 192.168.11.202~203(地址任意)。并且重新启动连接以激活新配置:

basicthinker@ubuntu:~$ sudo ifdown eth1

basicthinker@ubuntu:~$ sudo ifup eth1

将上述分配的静态IP依次写入各个虚拟节点的/etc/hosts文件,以进行主机名的解析:

192.168.11.201 node1

192.168.11.202 node2

192.168.11.203 node3

注意每个hosts文件都要写入上面所有行。
生成配置文件:

选择任意节点运行与“单机配置”第1步相同的命令:

root@ubuntu:~# pvfs2-genconfig /etc/pvfs2-fs.conf

不同之处在于选择I/O server时:

Next you must list the hostnames of the machines that will act as

I/O servers. Acceptable syntax is "node1, node2, ..." or "node{#-#,#,#}".

* Enter hostnames [Default is localhost]: node1, node2

以及选择metadata server时:

Now list the hostnames of the machines that will act as Metadata

servers. This list may or may not overlap with the I/O server list.

* Enter hostnames [Default is localhost]: node2, node3
将生成后的配置文件pvfs2-fs.conf拷贝到各个节点的/etc目录下。

然后依次更改各个节点/etc/hostname文件内容为本节点名称(如node1),而不能使用克隆的源虚拟机的hostname;可能需要重启使更新生效。
如果克隆版本已经分配过空间,还需要首先手动删除/pvfs2-storage-space,其余同“单机配置”的第2步。如果克隆源未执行“单击配置”第3步,此时可依次配置各个节点。
任意节点可作为client,配置方法同“单机配置”第4步。注意更改fstab条目中的hostname,克隆源可能为"ubuntu",现在应改为node1~3中任意一个。
验证安装:分别在各个节点运行pvfs2-ping命令可以初步验证安装成功。

另外我们可以尝试如下几行命令,实际验证多机环境:

在node1节点执行:

basicthinker@node1:~/Documents$ pvfs-cp some_file /mnt/pvfs2

而后到node3节点查看:

basicthinker@node3:~$ pvfs2-ls /mnt/pvfs2

some_file

lost+found

可以看到some_file已经存储到了pvfs2中。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: