gluster 安装配置基本指南
转自http://blog.sina.com.cn/s/blog_7034a4630100ppzo.html
gluster安装
1、 rpm安装
复制gluster中的core 和 fuse模块,并进行安装。
rpm –ivh glusterfs-core-3.1.3-1.x86_64.rpm
rpm –ivh glusterfs-fuse-3.1.3-1.x86_64.rpm
2、 fuse测试并检查
lsmod | grep fuse
假如没有, 使用命令
modprobe fuse
lsmod | grep fuse
使用 ls /dev/fuse,应该有 /dev/fuse 这个目录
配置gluster服务端
1、创建服务器端文件目录
首先,我们假定我们的gluster服务器安装在192.168.1.2上
mkdir /home/dir1
chmod 1777 /home/dir1
2、修改服务器端配置
1. cd /etc/glusterfs
在目录下有两个文件:
glusterfsd.vol.sample
glusterfs.vol.sample
2. cp glusterfsd.vol.sample glusterfsd.vol
拷贝出一个服务器端配置文件出来,修改配置用。
2.1 编辑glusterfsd.vol
主要是修改 directory, transport.socket.bind-address 两项。
也可以设置下 auth.addr.brick.allow, 端口等
volume brick
type storage/posix # POSIX FS translator
option transport.socket.bind-address 192.168.1.2
option directory /home/dir1 # Export this directory
end-volume
volume server
type protocol/server
option transport-type tcp
option transport.socket.listen-port 24016
subvolumes brick
option auth.addr.brick.allow * # Allow access to "brick" volume
end-volume
3.、启动服务
glusterfsd -f /etc/glusterfs/glusterfsd.vol -l /var/log/glusterfs/glusterfsd.log
3.1 检查服务是否启动成功
ps ax | grep gluster
查看进程
检验端口, 如果已经设置了端口, 例如
netstat -ln | grep 24016
显示如下则说明 24016 端口处在监听状态
tcp 0 0 192.168.1.2:24016 0.0.0.0:* LISTEN
查看 log
vi /var/log/glusterfs/glusterfsd.log
没有error信息就ok
配置gluster客户端
1、复制配置文件
使用下面的命令进行配置cp glusterfs.vol.sample glusterfs.vol
2、编辑配置文件
配置文件的编辑相对来讲比较复杂,这要涉及到gluster服务器的拓扑结构,我们以下面的拓扑结构来进行说明:
在上面拓扑图中,其中001_1和001_2是复制方式,002_1和002_2是复制方式,而这两组是分布式存储的,这样相当于集群中的raid0+raid1方式,很好的数据的安全性和高效性。对于这种情况,client001的配置为
# 服务器列表
volume server001_1
end-volume
volume server 001_2
end-volume
volume server 002_1
end-volume
volume server 002_2
end-volume
#服务器之间的关系
volume images001
end-volume
volume images002
end-volume
volume images
end-volume
当然gluster中的配置和算法很多,具体的配置也需要参考gluster的相关文档
3、启动客户端
glusterfs -f /etc/glusterfs/glusterfs.vol -l /var/log/glusterfs/glusterfs.log /mnt/
其中 /mnt 是挂载目录, 可指定其他目录
验证安装是否正确
1、检查客户端是否挂载成功
查看盘符信息:df –h;包含如下信息表示正常,/etc/glusterfs/glusterfs.vol
查看进程ps ax | grep glusterfs,如果有表示正确
查看 log,vi /var/log/glusterfs/glusterfs.log;如果没有 error 信息,表示连接正确。
2、在客户端操作
进入/mnt目录,这是就可以在该目录下进行文件级别的操作, 然后可以查看 服务器端的 /home/dir1目录下是否有相应变化。
卸载时候 umount /mnt 命令,umount 之后 ps ax | grep gluster 会发现 glusterfs 进程结束。