部署环境:
ip | role |
172.22.115.5 | server、iscsi client |
172.22.115.6 | server、iscsi client |
172.22.115.11 | server |
centos 7 1611 64位
安装前的准备(每台服务器都需要执行)
1.同步时区和时间
安装ntp服务
1 | yum install ntp |
|
开机启动ntp服务
1 | systemctl enable ntpd |
|
编辑ntp服务器
1 | vi /etc/ntp.conf |
|
在
server 0.centos.pool.ntp.org iburst server 1.centos.pool.ntp.org iburst server 2.centos.pool.ntp.org iburst server 3.centos.pool.ntp.org iburst 中可添加内网时间服务器
设置时区
1 | timedatectl set‐timezone Asia/Shanghai |
|
启用ntp同步时间
1 | timedatectl set‐ntp yes |
|
重启ntp服务
1 | systemctl restart ntpd |
|
手动同步时间
1 | ntpd ‐q |
|
2.根据规划修改IP
1 | vi /etc/sysconfig/network‐scripts/ifcfg‐XXX //XXX为网卡名称 |
|
修改如下几项:
BOOTPROTO=static
IPADDR=xxx.xxx.xxx.xxx
NETMASK=xxx.xxx.xxx.xxx
GATEWAY=xxx.xxx.xxx.xxx(可选)验证:
- 使用 ip addr来查看网卡的 IP 配置是否正确,请注意网口与网段的对应是否正确。
- 使用 ethtool <网口名>来检查是否连通及网口速率是否正确
- 使用 ping 来确认服务器之间该网段是否连通 2. 配置 DNS(可选,如果需要访问公网请配置)
1 | vi /etc/resolv.conf |
|
配置 nameserver,如 114.114.114.114 验证:
ping www.baidu.com
能 ping 通即可
3.配置主机名及hosts
修改本机主机名
1 | hostnamectl set‐hostname XXX |
|
根据规划修改hosts
1 | vi /etc/hosts |
|
172.22.115.5 Node1
172.22.115.6 Node2
172.22.115.11 Node3
验证:
ping Node2
能ping通即可
4.配置Selinux与防火墙
Selinux
1 | vi /etc/selinux/config |
|
将SELINUX=enforcing改为SELINUX=permissive
1 | setenforce 0 |
|
防火墙
停止防火墙并禁止防火墙服务
1 2 | systemctl stop firewalld.service systemctl disable firewalld.service |
|
重启服务器
reboot
验证
Selinux
1 | getenforce |
|
结果为
Permissive
防火墙
1 | systemctl status firewalld.service |
|
结果为
● firewalld.service firewalld dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
5.配置ssh免密码登录(在Node1执行)
- 生成本机密钥
1 | ssh‐keygen ‐t rsa |
|
- 将本机密钥拷贝至规划加入集群中的所有服务器(包括本机)
1 | ssh‐copy‐id root@<服务器 IP 地址/hostname> |
|
- 需要输入 yes,而后输入密码
- 验证设置是否成功
1 | ssh root@<服务器 IP 地址/hostname> |
|
安装Glusterfs
查找gluster的最新软件仓库:
1 | yum search centos‐release‐gluster |
|
安装最新版本的gluster软件仓库:
1 | yum ‐y install centos‐release‐gluster310 |
|
安装gluster软件:
1 | yum ‐y install glusterfs glusterfs‐server glusterfs‐fuse glusterfs‐cli glusterfs‐geo‐replication |
|
查看版本信息:
1 | glusterfs ‐V |
|
启动进程:
1 2 3 | systemctl enable glusterd //设置为开机启动 systemctl start glusterd systemctl status glusterd |
|
在Node1上将其他节点加入信任主机池(不需要添加本机):
1 2 | gluster peer probe Node2 gluster peer probe Node3 |
|
在全部节点上查看信任主机池状态:
1 | gluster peer status |
|
Number of Peers: 2
Hostname: 172.22.115.6
Uuid: c0145e6e6bbb4fe6863d29e7bc15b767
State: Peer in Cluster (Connected)
Hostname: 172.22.115.11
Uuid: 586086033b084982b95610a652c7a486 State: Peer in Cluster (Connected)
创建共享目录:
1 | mkdir /opt/gv0_data |
|
创建共享卷,卷名为gv0,由于副本必须大于1且是节点数的因数,所以我
们这里创建3个副本(这里使用force, 是因为/opt/gv0_data目录与系统根'/'在同一个设备上):
1 | gluster volume create gv0 replica 2 transport tcp |
| 172.22.115.5:/opt/gv0_data 172.22.115.6:/opt/gv0_data 172.22. 115.11:/opt/gv0_data force |
启动共享卷gv0:
1 | gluster volume start gv0 |
|
查看共享卷信息:
1 | gluster volume info |
|
Number of Peers: 2
Hostname: 172.22.115.6
Uuid: c0145e6e6bbb4fe6863d29e7bc15b767
State: Peer in Cluster (Connected)
Hostname: 172.22.115.11
Uuid: 586086033b084982b95610a652c7a486
State: Peer in Cluster (Connected)
[root@node1 ~]# gluster volume info
Volume Name: gv0
Type: Replicate
Volume ID: 936d9afe37584a3196f4b177b9949568
Status: Started
Snapshot Count: 0
Number of Bricks: 1 x 3 = 3 Transporttype: tcp
Bricks:
Brick1: 172.22.115.5:/opt/gv0_data
Brick2: 172.22.115.6:/opt/gv0_data Brick3: 172.22.115.11:/opt/gv0_data
Options Reconfigured:
transport.addressfamily: inet nfs.disable: on
查看共享卷状态:
1 | gluster volume status |
|
Status of volume: gv0
Gluster process TCP Port RDMA Port Online Pid
Brick 172.22.115.5:/opt/gv0_data 49152 0 Y 2871
Brick 172.22.115.6:/opt/gv0_data 49152 0 Y 29271
Brick 172.22.115.11:/opt/gv0_data 49152 0 Y 29140
Selfheal Daemon on localhost N/A N/A Y 2891
Selfheal Daemon on 172.22.115.6 N/A N/A Y 29291
Selfheal Daemon on 172.22.115.11 N/A N/A Y 29160
Task Status of Volume gv0
There are no active volume tasks
挂载:
1 2 | mkdir /mnt/gv0 mount ‐t glusterfs 127.0.0.1:/gv0 /mnt/gv0 |
|