VM Esx 4.1 虚拟机安装ocfs2


 

一:准备工作

虚拟系统:VM esx 4.1 IP:172.21.2.184

按照默认安装完成,配置sshd

vi /etc/ssh/sshd_config

将PermitRootLogin no 改成PermitRootLogin yes,保存退出

然后重起sshd

service sshd restart

 

这样,就可以使用ssh 远程登录到这台虚拟机了

 

使用IE  访问http://172.21.2.184,下载vSphere Client 和vSphere Vcenter

安装vSphere Client。

 

二:创建虚拟主机

这里创建2台虚拟主机

系统:centos 5.4

硬盘;20G

内存:388M

网卡只设置一块。心跳IP使用私有IP地址。这是测试环境。

IP地址分别是172.21.2.177和172.21.2.43

主机名:VMZJJTES01和VMZJJTEST02

为了测试方便,关闭防火墙和selinux.

 

进入创建的虚拟主机系统。

编辑hosts文件

vi /etc/hosts

 

127.0.0.1               VMZJJTEST01 localhost.localdomain VMZJJTEST01

::1             localhost6.localdomain6 localhost6

172.21.2.177    VMZJJTEST01

172.21.2.43     VMZJJTEST02

127.0.0.1 VMZJJTEST02 localhost.localdomain VMZJJTEST02

::1 localhost6.localdomain6 localhost6

172.21.2.177 VMZJJTEST01

172.21.2.43 VMZJJTEST02

 

查看系统内核

uname -a

Linux VMZJJTEST02 2.6.18-164.el5 #1 SMP Thu Sep 3 03:33:56 EDT 2009 i686 i686 i386 GNU/Linux

 

 

 

虚拟机准备完成。

 

三:创建虚拟共享磁盘

 

使用putty远程登录到172.21.2.184虚拟服务器上。

创建磁盘

cd /vmfs/volumes/4exxxxxxxxxxxxxx

上面的4exxxxxx依据虚拟服务器不同而不同。

 

mkdir mydisk

 

cd mydisk

 

创建一个10G大小的共享磁盘

 

vmkfstools -c 10240m -a lsilogic -d eagerzeroedthick mydisk.vmdk

 

四:添加虚拟磁盘

登录vSphere Client ,选择VMZJJTEST01机器,选择编辑-添加磁盘-选择已有虚拟磁盘-独立-永久。这里需要注意,如果虚拟机器的本地硬盘为scsi为0节点,比如scsi0:0,那么现在添加的虚拟共享盘应该设为scsi1:0或者之后的节点。这个很重要。

然后进入到虚拟服务器172.21.2.184的虚拟主机所在目录

cd /vmfs/volumes/4exxxxxxxxxxxxxx

编辑VMZJJTEST01.xmx

 

需要修改或者添加的地方如下:

scsi1.sharedBus = "virtual"

disk.locking="false"

diskLib.dataCacheMaxSize = "0"

diskLib.dataCacheMaxReadAheadSize = "0"

diskLib.DataCacheMinReadAheadSize = "0"

diskLib.dataCachePageSize = "4096"

diskLib.maxUnsyncedWrites = "0"

这样,虚拟共享磁盘添加完成,另外一台类似添加即可。

 

五:安装ocfs2

根据内核,下载相应的ocfs2版本。

一共下载三个安装包,按照安装的顺序如下列所示:

ocfs2-tools-1.4.4-1.el5.i386.rpm

ocfs2-2.6.18-164.el5-1.4.7-1.el5.i686.rpm

ocfs2console-1.4.4-1.el5.i386.rpm

使用rpm -ivh xxxxxx直接安装。

安装完成之后,输入ocfs2图形界面

ocfs2console&

 

说明:上面的使用xming软件获取图形界面。

启动o2cb

/etc/init.d/o2cb start

 

然后在图形界面下点-cluster-Configure Nodes,配置节点。

输入对应的主机名和IP,端口7777.这里添加2台。

然后点"应用"-"退出".

假如上面的配置是在VMZJJTEST01所设置的。那么登录这台机器,使用下面的命令

scp /etc/ocfs2/cluster.conf root@172.21.2.43:/etc/ocfs2/

上面的命令可能会提示172.21.2.43这台机器没有目录。请在这台机器创建目录

mkdir /etc/ocfs2

 

然后分别在2台机器做如下配置:

/etc/init.d/o2cb unload

 

 

/etc/init.d/o2cb offline ocfs2

 

/etc/init.d/o2cb configure

Configuring the O2CB driver.This will configure the on-boot properties of the O2CB driver.The following questions will determine whether the driver is loaded onboot. The current values will be shown in brackets ('[]'). Hitting<ENTER> without typing an answer will keep that current value. Ctrl-Cwill abort.Load O2CB driver on boot (y/n) [n]: y

Cluster to start on boot (Enter "none" to clear) [ocfs2]: ocfs2

Writing O2CB configuration: OK

Loading module "configfs": OK

Mounting configfs filesystem at /config: OK

Loading module "ocfs2_nodemanager": OK

Loading module "ocfs2_dlm": OK

Loading module "ocfs2_dlmfs": OK

Mounting ocfs2_dlmfs filesystem at /dlm: OK

Starting cluster ocfs2: OK

 

大致显示的内容如上,稍有差异,请自行判断。

2台机器都要做这样的设置。

六:分区和挂载

使用fdisk /dev/sdb将虚拟共享磁盘分成2个分区

分别是/dev/sdb5和/dev/sdb6.

使用以下命令格式化文件系统

# mkfs.ocfs2 -b 4K -C 32K -N 4 -L webdatafile /dev/sdb5

/dev/sdb6 将webdatafile换成webos.-L参数后自设。

然后创建目录u01和u02

将/dev/sdb5和/dev/sdb6分别挂载到u01和u02目录下

mount -t ocfs2 -o datavolume,nointr -L "webdatafile" /u01

 

mount -t ocfs2 -o datavolume,nointr -L "webos" /u02

分区和格式化文件系统在一台机器操作即可。

但是挂载需要在2台同时操作。

七:开机自动启动o2cb和挂载u01和u02

chkconfig --add o2cb

 

chkconfig o2cb on

 

自动挂载的fstab如下:

 

 

/dev/sdb5               /u01                    ocfs2   _netdev,datavolume,nointr 0 0

/dev/sdb6               /u02                    ocfs2   _netdev,datavolume,nointr 0 0

关于OCFS2的作用和原理部分,请咨询谷哥。

 

本文出自 “随记千秋” 博客

相关内容

    暂无相关文章