知识屋:更实用的电脑技术知识网站
所在位置:首页 > 操作系统 > linux

Ubuntu 12.04 64 bit安装glusterfs 3.3.0配置replica

发布时间:2014-09-05 15:47:54作者:知识屋


Ubuntu 12.04 64 bit安装glusterfs 3.3.0配置replica
 
需要使用两台服务器作gluster replication server端,同时把server端当client端
server1  10.10.10.10
server2  10.10.10.11
 
进入server1 root下
sudo -s 
  www.zhishiwu.com  
分别在两台服务器上添加
vim /etc/hosts
10.10.10.10  server1
10.10.10.11  server2
 
cat /etc/hosts 
127.0.0.1   localhost
10.10.10.10  server1
10.10.10.11  server2
 
# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
 
安装配置Gluster
 
http://download.gluster.org/pub/gluster/glusterfs/LATEST/Ubuntu/12.04/glusterfs_3.3.0-1_amd64.deb
 
apt-get install flex bison libssl-dev fuse  fuse-utils libevent-dev libreadline6-dev
 
dpkg -i  glusterfs_3.3.0-1_amd64.deb
 
update-rc.d  glusterd defaults 
/etc/init.d/glusterd  start 
  www.zhishiwu.com  
安装完成后在server1运行如下命令:
glusterfs  --version 
 
glusterfs 3.3.0 built on Jun  4 2012 11:39:45
Repository revision: git://git.gluster.com/glusterfs.git
Copyright (c) 2006-2011 Gluster Inc. <http://www.gluster.com>
GlusterFS comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GlusterFS under the terms of the GNU General Public License.
 
gluster
>peer probe server2
Probe successful
>peer status
Number of Peers: 1
Hostname: server2
Uuid: 7cd93007-fccb-4fcb-8063-133e6ba81cd9
State: Peer in Cluster (Connected)
 
> volume create filestore replica 2 server1:/data/disk01 server2:/data/disk01
Creation of volume filestore has been successful. Please start the volume to access data.
 
> volume start filestore
Starting volume filestore has been successful
 
> volume info  filestore 
Volume Name: filestore
Type: Replicate
Status: Started
Number of Bricks: 2
Transport-type: tcp
Bricks:
Brick1: server1:/data/disk01
Brick2: server2:/data/disk01
  www.zhishiwu.com  
mkdir /srv/filestore
mount -t glusterfs  server2:/filestore /srv/filstore 
 
然后运行mount 或df -h 查看是否挂载上了
mount 
 
/dev/mapper/server3-root on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
/dev/sdb1  on /data/disk01  type ext4 (rw)
/dev/sda1 on /boot type ext2 (rw)
server2:/filestore on /mnt/glusterfs type fuse.glusterfs (rw,allow_other,default_permissions,max_read=131072)
 
echo  "server1:/filestore /srv/filestore  glusterfs  defaults,_netdev 0 0" >> /etc/fstab   
重启服务器 shutdown -h now  系统启动时挂载server2:/filestore 
 
cd /srv/filestore/
touch {1,2,3,4} 
dd if=/dev/zero  of=test01 bs=1M count=10 
dd if=/dev/zero  of=test02 bs=1M count=10 
 
ls -l  /srv/filestore
-rw-r--r-- 1 root root         0 Oct  8 11:30 1
-rw-r--r-- 1 root root         0 Oct  8 11:30 2
-rw-r--r-- 1 root root         0 Oct  8 11:30 3
-rw-r--r-- 1 root root         0 Oct  8 11:30 4
-rw-r--r-- 1 root root  10485760 Oct  8 11:31 test01
-rw-r--r-- 1 root root  10485760 Oct  8 11:31 test02
 
在server1 上查看/data/disk01下的内容
ls -l /data/disk01/
 
-rw-r--r-- 1 root root         0 Oct  8 11:30 1
-rw-r--r-- 1 root root         0 Oct  8 11:30 2
-rw-r--r-- 1 root root         0 Oct  8 11:30 3
-rw-r--r-- 1 root root         0 Oct  8 11:30 4
-rw-r--r-- 1 root root  10485760 Oct  8 11:31 test01
-rw-r--r-- 1 root root  10485760 Oct  8 11:31 test02
 
在server2上查看/data/disk01下的内容
 
ls -l /data/disk01 
-rw-r--r-- 1 root root         0 Oct  8 11:30 1
-rw-r--r-- 1 root root         0 Oct  8 11:30 2
-rw-r--r-- 1 root root         0 Oct  8 11:30 3
-rw-r--r-- 1 root root         0 Oct  8 11:30 4
-rw-r--r-- 1 root root  10485760 Oct  8 11:31 test01
-rw-r--r-- 1 root root  10485760 Oct  8 11:31 test02
  www.zhishiwu.com  
如果要配置distribute  replication , 可以为replication 再添加两块磁盘。
 
gluster  volume filestore add-brick server1:/data/disk02 server02:/data/disk02 
 
gluster volume info filestore  就会变成
 
Volume Name: filestore
Type: Distribute  Replicate 
Status: Started
Number of Bricks: 2×2
Transport-type: tcp
Bricks:
Brick1: server1:/data/disk01
Brick2: server2:/data/disk01
Brick3: server1:/data/disk02
Brick4: server2:/data/disk02
 
数据需要fix-layout 和migrate-data 一下。
(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)
收藏
  • 人气文章
  • 最新文章
  • 下载排行榜
  • 热门排行榜