CentOS7.0 开发模式安装

环境:CentOS7.0 开发模式安装
1、tar -zxvf glusterfs-3.6.0.tar.gz
2、./configure
默认的模块如下如所示

3、make && make install
4、sudo vim /etc/glusterfs/glusterfsd.vol
 
   
  1. <span style=”font-family:Microsoft YaHei;font-size:14px;”>volume brick  
  2. type storage/posix # POSIX FS translator  
  3. option directory /home/dir1 # Export this directory  
  4. end-volume  
  5. volume server  
  6. type protocol/server  
  7. option transport-type tcp/server  
  8. option transport.socket.bind-address 172.10.2.222 # Default is to listen on all interfaces  
  9. subvolumes brick  
  10. option auth.addr.brick.allow *   # Allow access to “brick” volume  
  11. end-volume</span>  
<span style="font-family:Microsoft YaHei;font-size:14px;">volume brick
type storage/posix # POSIX FS translator
option directory /home/dir1 # Export this directory
end-volume
volume server
type protocol/server
option transport-type tcp/server
option transport.socket.bind-address 172.10.2.222 # Default is to listen on all interfaces
subvolumes brick
option auth.addr.brick.allow *   # Allow access to "brick" volume
end-volume</span>

5、开启glusterfsd
glusterfsd -f /etc/glusterfs/glusterfsd.vol -l /var/log/glusterfs/glusterfsd.log

这里讲一下glusterfs包里几个重要的组件,gluster,glusterfsd,glusterd,glusterfs

gluster:服务器端的CLI,运行添加节点,删除节点之类都是它发命令给glusterd
glusterd:运行于服务器端的守护进程,它打开了gluster才能用,它把gluster的命令传递给glusterfsd
glusterfsd:服务器端主要干活的,它接受服务器端的管理指令和客户端的数据请求,配合底层VFS和文件系统完成工作
glusterfs:运行于客户端,接收fuse的指令,因为客户端的APP都是通过FUSE和glusterfs通信的,它接收到请求后传给glusterfs,再通过RPC传给服务器端的gluserfsd

6、检验glusterfsd进程是否存在
ps -ef|grep -v grep |grep gluster
这里我没有查到进程,有问题,可以查看日志
/var/log/glusterfs/glusterfsd.log


我的port没有设置,使用的默认的port可能被占用了,另外设置了一个6996
  1. <pre name=”code” class=”plain”><span style=”font-family:Microsoft YaHei;font-size:14px;”>option transport.socket.bind-address  
  2. option transport.socket.listen-port 6996</span>  
<pre name="code" class="plain"><span style="font-family:Microsoft YaHei;font-size:14px;">option transport.socket.bind-address
option transport.socket.listen-port 6996</span>
 
  
设置监听端口前先查一下这个端口有没有被使用
netstat -ln | grep 6996
显示如下则说明6996端口处在监听状态
tcp 0 0 124.127.117.28:6996 0.0.0.0:* LISTEN

卷的路径:option directory /home/dir没有创建,mkdir了一个,这个简单
再次查看
ps -ef|grep -v grep |grep gluster


7、开启glusterd
[root@localhost glusterfs]# service glusterd start 

Redirecting to /bin/systemctl start glusterd.service


8、为磁盘分区,挂载

格式化成XFS文件系统

[root@localhost glusterfs]# mount /dev/sdb /brick1 
[root@localhost glusterfs]# mount /dev/sdc /brick2

9、clone,将clone的机器开启(虚机环境嘛)

10、开启glusterd服务:service glusterd start,开启了它gluster才能用

chkconfig glusterd on可设置开机时自动开启

11、建立存储池
  1. [root@localhost ~]# gluster peer status  
  2. Number of Peers: 0  
  3. [root@localhost ~]# gluster peer probe 172.10.2.171  
  4. peer probe: failed: Probe returned with unknown errno 107  
[root@localhost ~]# gluster peer status
Number of Peers: 0
[root@localhost ~]# gluster peer probe 172.10.2.171
peer probe: failed: Probe returned with unknown errno 107
这里遇到了错误,查看日志
/var/log/glusterfs/usr-local-etc-glusterfs-glusterd.vol.log”

好像是网络的问题,节点的IP都是dhcp的,试着改成了static,并添加网关,添加网关后还是出错,日志信息如下,因为之前关闭防火墙只关了iptables,查了查CentOS7.0还有个防火墙,可能是它的问题

关闭防火墙 

  1. sudo systemctl stop firewalld.service  
  2. sudo systemctl disable firewalld.service  
  3. sudo systemctl stop iptables.service  
  4. sudo systemctl disable iptables.service  
  5. sudo vim /etc/selinux/config  
  6. 注释下面两行:  
  7. #SELINUX=enforcing  
  8. #SELINUXTYPE=targeted  
  9. sudo setenforce 0  
sudo systemctl stop firewalld.service
sudo systemctl disable firewalld.service
sudo systemctl stop iptables.service
sudo systemctl disable iptables.service
sudo vim /etc/selinux/config
注释下面两行:




SELINUX=enforcing

SELINUXTYPE=targeted

sudo setenforce 0这回就成功了


查询存储池状态:



一共两个节点,本节点只能查询另外的节点的信息,这是分别在两个节点上查询到的信息
试验一下删除的操作
删除节点:gluster peer detach node2

12、创建卷
# gluster volume create NEW-VOLNAME [stripe COUNT | replica COUNT]
[transport [tcp | rdma | tcp,rdma]] NEW-BRICK1 NEW-BRICK2 NEW-BRICK3…

gluster vol create testvol replica 2 node1:/brick1 node2:/brick1 
  1. [root@localhost ~]# gluster vol create testvol replica 2 node1:/brick1 node2:/brick1  
  2. volume create: testvol: failed: The brick node2:/brick1 is a mount point. Please create a sub-directory under the mount point and use that as the brick directory. Or use ‘force’ at the end of the command if you want to override this behavior.  
[root@localhost ~]# gluster vol create testvol replica 2 node1:/brick1 node2:/brick1
volume create: testvol: failed: The brick node2:/brick1 is a mount point. Please create a sub-directory under the mount point and use that as the brick directory. Or use 'force' at the end of the command if you want to override this behavior.
成功了
  1. [root@localhost ~]# gluster vol create testvol replica 2 node1:/brick1 node2:/brick1 force   
  2. volume create: testvol: success: please start the volume to access data  
[root@localhost ~]# gluster vol create testvol replica 2 node1:/brick1 node2:/brick1 force 
volume create: testvol: success: please start the volume to access data
查看卷的信息:gluster vol info

13、开启卷:gluster vol start testvol

失败的一种情况:

由于机器重启,brick挂载失败了,在/etc/fstab里设置会在开机时自动挂载,这里就重新挂载一次就行了

试验一下停止卷:gluster vol stop testvol


14、利用原生客户端挂载
  1. [root@localhost ~]# mkdir /mnt/gls   
  2. [root@localhost ~]# mount -t glusterfs node1:testvol /mnt/gls  
  3.   
  4. [root@localhost ~]# mkdir /mnt/gls   
  5. [root@localhost ~]# mount -t glusterfs node1:testvol /mnt/gls   
  6. [root@localhost ~]# df -h   
  7. Filesystem Size Used Avail Use% Mounted on   
  8. /dev/mapper/centos-root 8.5G 7.0G 1.6G 82% /   
  9. devtmpfs 489M 0 489M 0% /dev   
  10. tmpfs 498M 92K 498M 1% /dev/shm   
  11. tmpfs 498M 7.2M 491M 2% /run   
  12. tmpfs 498M 0 498M 0% /sys/fs/cgroup   
  13. /dev/sda1 497M 120M 377M 25% /boot   
  14. node1:testvol 2.0G 33M 2.0G 2% /mnt/gls  
[root@localhost ~]# mkdir /mnt/gls 
[root@localhost ~]# mount -t glusterfs node1:testvol /mnt/gls

[root@localhost ~]# mkdir /mnt/gls 
[root@localhost ~]# mount -t glusterfs node1:testvol /mnt/gls 
[root@localhost ~]# df -h 
Filesystem Size Used Avail Use% Mounted on 
/dev/mapper/centos-root 8.5G 7.0G 1.6G 82% / 
devtmpfs 489M 0 489M 0% /dev 
tmpfs 498M 92K 498M 1% /dev/shm 
tmpfs 498M 7.2M 491M 2% /run 
tmpfs 498M 0 498M 0% /sys/fs/cgroup 
/dev/sda1 497M 120M 377M 25% /boot 
node1:testvol 2.0G 33M 2.0G 2% /mnt/gls

15、扩展卷: volume add-brick <VOLNAME> <NEW-BRICK> …


扩展了两个节点,就从复制卷变成了分布式复制卷

16、负载均衡
        volume rebalance <VOLNAME> start
              Start rebalancing the specified volume.

        volume rebalance <VOLNAME> stop
              Stop rebalancing the specified volume.

        volume rebalance <VOLNAME> status
              Display the rebalance status of the specified volume.
这是没有开始负载均衡时查询到的状态:

这是负载均衡后查询到的状态:


原始
  1. [root@localhost ~]# ll /brick*   
  2. /brick1:   
  3. total 8   
  4. -rw-r–r–. 2 root root 14 11?.18 13:14 file1   
  5. -rw-r–r–. 2 root root 11 11?.18 13:14 file2   
  6.   
  7. /brick2:   
  8. total 0   
[root@localhost ~]# ll /brick* 
/brick1: 
total 8 
-rw-r--r--. 2 root root 14 11?.18 13:14 file1 
-rw-r--r--. 2 root root 11 11?.18 13:14 file2 

/brick2: 
total 0 
过程1
  1. [root@localhost ~]# ll /brick*   
  2. /brick1:   
  3. total 8   
  4. ———T. 2 root root 14 11?.18 13:14 file1   
  5. -rw-r–r–. 2 root root 11 11?.18 13:14 file2   
  6.   
  7. /brick2:   
  8. total 4   
  9. -rw-r–r–. 2 root root 14 11?.18 13:14 file1  
[root@localhost ~]# ll /brick* 
/brick1: 
total 8 
---------T. 2 root root 14 11?.18 13:14 file1 
-rw-r--r--. 2 root root 11 11?.18 13:14 file2 

/brick2: 
total 4 
-rw-r--r--. 2 root root 14 11?.18 13:14 file1
结果 
  1. [root@localhost ~]# ll /brick*   
  2. /brick1:   
  3. total 4   
  4. -rw-r–r–. 2 root root 11 11?.18 13:14 file2   
  5.   
  6. /brick2:   
  7. total 4   
  8. -rw-r–r–. 2 root root 14 11?.18 13:14 file1   
  9. ———T. 2 root root 11 11?.18 13:42 file2   
[root@localhost ~]# ll /brick* 
/brick1: 
total 4 
-rw-r--r--. 2 root root 11 11?.18 13:14 file2 

/brick2: 
total 4 
-rw-r--r--. 2 root root 14 11?.18 13:14 file1 
---------T. 2 root root 11 11?.18 13:42 file2 
这是写file2,T文件变成真实的文件,又新写了几个文件

17、设置卷的参数
gluster volume set VOLNAME OPTION PARAMETER
e.g.
gluster volume set testvol performance.cache-size 256MB






        </div>
            </div>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值