目录
1.centos1、centos2、centos3、三个虚拟机各加一个磁盘
一、环境搭建
1.基础环境
虚拟机名 | 操作系统 | IP地址 | 安装软件 |
---|---|---|---|
centos1 | centOS7 | 192.168.115.128 | ceph-13.2.10-0.el7.x86_64 lttng-ust-2.4.1-4.el7.x86_64 ceph-deploy-2.0.1-0.noarch |
centos2 | centOS7 | 192.168.115.130 | ceph-13.2.10-0.el7.x86_64 lttng-ust-2.4.1-4.el7.x86_64 ceph-deploy-2.0.1-0.noarch |
centos3 | centOS7 | 192.168.115.131 | ceph-13.2.10-0.el7.x86_64 lttng-ust-2.4.1-4.el7.x86_64 ceph-deploy-2.0.1-0.noarch |
centos4 | centOS7 | 192.168.115.132 | ceph-13.2.10-0.el7.x86_64 lttng-ust-2.4.1-4.el7.x86_64 ceph-deploy-2.0.1-0.noarch |
各个虚拟机先做免密登录并验证
2.centos1安装软件
添加ceph安装源
[Ceph]
name=Ceph packages for $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/ceph/rpm-mimic/el7/x86_64/
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://download.ceph.com/keys/release.asc
[Ceph-noarch]
name=Ceph noarch packages
# 清华源
baseurl=https://mirrors.tuna.tsinghua.edu.cn/ceph/rpm-mimic/el7/noarch/
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://download.ceph.com/keys/release.asc
[ceph-source]
name=Ceph source packages
baseurl=https://mirrors.tuna.tsinghua.edu.cn/ceph/rpm-mimic/el7/SRPMS/
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://download.ceph.com/keys/release.asc
yum install epel-release -y
yum install lttng-ust -y
yum -y install ceph ceph-deploy
3.创建集群
mkdir -p /usr/local/soft/cephcluster
cd /usr/local/soft/cephcluster
ceph-deploy new centos1 centos2 centos3 centos4
4.修改配置文件
vim /usr/local/soft/cephcluster/ceph.conf
#对外开放网段
public network = 192.168.115.0/24
# 设置pool池默认分配数量
osd pool default size = 2
# 容忍更多的时钟误差
mon clock drift allowed = 2
mon clock drift warn backoff = 30
# 允许删除pool
mon_allow_pool_delete = true
[mgr]
# 开启WEB仪表盘
mgr modules = dashboard
5.安装软件
ceph-deploy install centos1 centos2 centos3 centos4
二、构建集群
1.初始化monitor
ceph-deploy mon create-initial
2.同步管理信息
ceph-deploy admin centos1 centos2 centos3 centos4
3.安装mgr
ceph-deploy mgr create centos1 centos2 centos3 centos4
4.安装rgw
ceph-deploy rgw create centos1 centos2 centos3 centos4
5.创建mds服务
ceph-deploy mds create centos1 centos2 centos3 centos4
三、安装OSD
1.centos1、centos2、centos3、三个虚拟机各加一个磁盘
2.热刷新磁盘并格式化
echo "- - -" > /sys/class/scsi_host/host0/scan
mkfs.xfs /dev/sdb
3.创建OSD
ceph-deploy osd create --data /dev/sdb centos1
ceph-deploy osd create --data /dev/sdb centos2
ceph-deploy osd create --data /dev/sdb centos3
四、安装dashboard
1.生成签名和创建安全认证
ceph mgr module enable dashboard
ceph dashboard create-self-signed-cert
mkdir -p /usr/local/jx/cephcluster/mgr-dashboard
cd /usr/local/jx/cephcluster/mgr-dashboard
openssl req -new -nodes -x509 -subj "/O=IT/CN=ceph-mgr-dashboard" -days 3650 -keyout dashboard.key -out dashboard.crt -extensions v3_ca
2.启动服务
ceph mgr module disable dashboard
ceph mgr module enable dashboard
ceph config set mgr mgr/dashboard/server_addr 192.168.115.128
#设置访问IP
ceph config set mgr mgr/dashboard/server_port 9001
#设置访问端口
ceph config set mgr mgr/dashboard/ssl false
#关闭https
ceph mgr services
ceph dashboard set-login-credentials jx123 123.com
#设置账户和密码
五、创建ceph文件系统
1.创建存储池
ceph osd pool create cephfs_data 128
ceph osd pool create cephfs_metadata 64
2. 创建文件系统
ceph fs new fs_test cephfs_metadata cephfs_data
3.在客户端(虚拟机centos4)挂载ceph文件系统
mkdir /ceph
ceph-fuse -k /etc/ceph/ceph.client.admin.keyring -m 192.168.115.128:6789 /ceph