打造全免费linux集群heartbeat+freenas(免费存储系统)
freenas 是一款免费的开源网络存储系统,基于freebsd开发,可以将一台普通的PC机变成一台网络存储服务器http://blog.运维网.com/attachment/201103/225435691.jpg
选择第9项 安装fressnas系统
http://blog.运维网.com/attachment/201103/225946476.jpg
选择第3项 从硬盘安装 点击OKhttp://blog.运维网.com/attachment/201103/225946901.jpg http://blog.运维网.com/attachment/201103/225946598.jpg
选择CDROM
http://blog.运维网.com/attachment/201103/225946457.jpg 选择硬盘
http://blog.运维网.com/attachment/201103/230253589.jpg
选择硬盘分区大小http://blog.运维网.com/attachment/201103/230253800.jpg
我这写的是 1000MB http://blog.运维网.com/attachment/201103/230253708.jpg
增加交换分区
http://blog.运维网.com/attachment/201103/230253143.jpg
设置交换分区大小
点击OK 完成配置
http://blog.运维网.com/attachment/201103/225435691.jpg
选择第7项重启
http://blog.运维网.com/attachment/201103/231555733.jpg
安装成功 这里9项没了 我们选择第2项配置IP地址
http://blog.运维网.com/attachment/201103/231319544.jpg
选择你要配置IP的网卡http://blog.运维网.com/attachment/201103/231319970.jpg
选择第3项
http://blog.运维网.com/attachment/201103/231319275.jpg
是否让DHCP自动获取,我们选择NO
http://blog.运维网.com/attachment/201103/231319904.jpg
设置 IP地址
http://blog.运维网.com/attachment/201103/231957693.jpg
设置子网掩码
http://blog.运维网.com/attachment/201103/231957507.jpg
设置网关
接下来选项是设置DNS ,IPV6地址
完成后 http://172.16.1.10账号 admin密码 freenas
登录后界面
http://blog.运维网.com/attachment/201103/234842644.jpg
首先我设置中文显示
在system选项 选择General 在WebGUI选择Language
http://blog.运维网.com/attachment/201103/235308595.jpg
(我们选择中文)
OK 设置完成 保存
http://blog.运维网.com/attachment/201103/000557697.jpg
中文显示
点击硬盘-管理 首先来添加硬盘
http://blog.运维网.com/attachment/201103/085345421.jpg
点击硬盘-格式化 (来格式刚添加的那3块硬盘)文件系统 我们选择Software RAID(做RAID 5)
点击硬盘-软RAID-raid5选择所选的硬盘 勾上最下面创建和初始化RAID
在回到 点击硬盘-格式化文件系统 ext2
点击硬盘-挂载点 选择硬盘(我刚做的RAID5)partition type选择MBRpartition 文件系统:ext2 mount ponit name(挂载点名字)data
http://blog.运维网.com/attachment/201103/091144831.jpg
点击服务-CIFS/SMB/网上邻居|设置 点击共享
http://blog.运维网.com/attachment/201103/121810117.jpg
在点设置选项 保存并重启服务
测试是否共享是否开启
http://blog.运维网.com/attachment/201103/122258868.jpg
heartbeat配置
http://blog.运维网.com/attachment/201103/192709706.jpg
首先我们在安装heartbeat之前我们需要安装 几个软件 ,heartbeat需要这些软件包的支持
我们在我们系统光盘安装以下软件包
http://blog.运维网.com/attachment/201103/193301668.jpg http://blog.运维网.com/attachment/201103/193301377.jpg http://blog.运维网.com/attachment/201103/193301983.jpg
创建用户和用户组
#groupadd -g 3000 haclient
#useradd -u 2000 -g haclient hacluster
编译安装libnet
tar -zxvf libnet-1.1.2.1.tar.gz
cd libnet
./configure
make
make install
编译安装heartbea
ttar -zxvf heartbeat-2.0.7.tar.gz
cd heartbeat-2.0.7
./ConfigureMe configure --enable-mgmt --with-ccmuser-name=hacluster
make
make install
把heartbeat-2.0.7软件包
分别在doc文件下如下3个文件分别复制到:
doc/ha.cf文件复制到etc/ha.d/
doc/haresources文件 复制到 /etc/ha.d/
doc/authkeys 文件复制到/etc/ha.d
ha.cf为配置文件 haresources配置HA资源文件 authkeys各节点的认证配置文件
#echo> /etc/ha.d/ha.cf
#vi /etc/ha.d/ha.cf 添加下列参数
logfile /var/log/ha-log
bcast eth1
keepalive 2
warntime 10
deadtime 30
initdead 120
udpport 694
auto_failback on
node ns1.abc.com
node ns2.abc.com
respawn hacluster /usr/lib/heartbeat/ccm
respawn hacluster /usr/lib/heartbeat/ipfail
ping windows
Logfile /var/log/ha-log日志文件存放路径
bcast eth1选择心条线的接口 这里选择的接口eth1
keepalive2 心跳保持连接是2秒(每两秒发一次)
warntime 10 如果10秒没接收到对方的数据包,就发记录在日志里。但是不切换服务器
deadtime 30 当30s没收到对方数据包 就切换服务,自己变成主动状态
initdead 120 #在某些配置下,重启后网络需要一些时间才能正常工
作。这个单独的“deadtime” 选项可以处理这种情况。它的取值至少应该为通常
deadtime 的两倍。
udpport 694 节点之间通讯端口号
auto_failback on 当主节点恢复后,是否自动切回
node ns1.abc.com集群中机器的主机名 在/etc/hosts文件有记录
node ns2.abc.com 集群中机器的主机名 在/etc/hosts文件有记录
respawn hacluster /usr/lib/heartbeat/ccm #列出将要执行和监控的命令。
respawn hacluster /usr/lib/heartbeat/ipfail
ping windows #列出ping 节点(这些节点不是集群节点,而是你所列出这个虚拟IP网段的其他IP地址的主机)
#vi/etc/hosts 配置集群节点的主机记录 添加下列选项
192.168.10.1 ns1.abc.com
192.168.10.2 ns2.abc.com
172.16.1.1 ns1.abc.com
172.16.1.2 ns2.abc.com
192.168.10.11 windows #我客户机的IP
#echo > /etc/ha.d/haresources
#vi /etc/ha.d/haresources添加下列选项ns1.abc.com 192.168.10.10/24/eth0/192.168.10.255 Filesystem::/dev/sdb1::/share::ext3 httpd
设置ns1.abc.com为主节点 192.168.10.10虚拟IP(为2个节点或者多个节点虚拟IP)24为子网掩码长度 eth0所要虚拟这IP的网卡接口/dev/sdb1 共享磁盘 并且挂载/share文件中 文件类型为ext3 集群服务是http服务
把这4个文件用scp复制到192.168.10.2那台机(2边配置一样 )
#scp /etc/ha.d/ha.cfroot@192.168.10.2:/etc/ha.d/
#scp /etc/ha.d/haresourcesroot@192.168.10.2:/etc/ha.d/
#scp /etc/ha.d/authkeysroot@192.168.10.2:/etc/ha.d/
#scp /etc/ha.d/ahostsroot@192.168.10.2:/etc/
chmod 600 /etc/ha.d/authkeys 更改认证文件的权限 (注意 没有这一步 服务无法开启)
测试效果
http://blog.运维网.com/attachment/201103/195401767.jpg
ns1.abc.com这台机
eth0:0接口为虚拟出的IP 192.168.10.10
http://blog.运维网.com/attachment/201103/195540966.jpg
这是ns2.abc.com这台机的
http://blog.运维网.com/attachment/201103/195752395.jpg
ns1.abc.com 自动挂载了/dev/sdb1 到/share
访问 192.168.10.10网址
http://blog.运维网.com/attachment/201103/195936997.jpg
我首先关闭ns1.abc.com这台机
http://blog.运维网.com/attachment/201103/200016435.jpg
ns2.abc.com 马上接替ns1.abc.com的工作也自动挂载这个共享硬盘
在输入这个网址
http://blog.运维网.com/attachment/201103/195936997.jpg
下面来设置heartbeat+freenas
#vi/etc/ha.d/haresources 修改添加
ns1.abc.com 192.168.10.10/24/eth0/192.168.10.255 Filesystem:://172.16.1.10/data::/share::cifs httpd
scp/etc/ha.d/haresources root#192.168.10.2:/etc/
我们重启下机
http://blog.运维网.com/attachment/201103/202029383.jpg
#cd/share
#echo "freenas" > index.html
测试效果
http://blog.运维网.com/attachment/201103/202301907.jpg
关闭ns1.abc.com这台机
http://blog.运维网.com/attachment/201103/202516458.jpg
ns2.abc.com以切换过来
在次输入 http://192.168.10.10
http://blog.运维网.com/attachment/201103/202301907.jpg
页:
[1]