Ceph环境搭建(m版)

环境准备

  • CentOS7.x
  • 三台以上虚拟机
主机名分配角色address
ceph1ceph-deploy+client192.168.5.26
ceph2mon+osd192.168.5.27
ceph3mon+osd192.168.5.28

开始部署

  • 修改yum源(所有节点均需配置)
#有时候CentOS默认的yum源不一定是国内镜像,导致yum在线安装及更新速度不是很理想,这时候需要yum源设置为国内镜像站点
yum install wget -y
#使用阿里云提供
cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.bak
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
  • 升级内核(所有节点均需配置)
#这里在网上找到
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org 
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
yum --disablerepo=\* --enablerepo=elrepo-kernel repolist
yum --disablerepo=\* --enablerepo=elrepo-kernel install  kernel-ml.x86_64  -y
yum remove kernel-tools-libs.x86_64 kernel-tools.x86_64  -y
yum --disablerepo=\* --enablerepo=elrepo-kernel install kernel-ml-tools.x86_64  -y
awk -F \' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
grub2-editenv list
grub2-set-default 0
reboot
uname -r
  • 安装epel仓库(所有节点均需配置)
yum update -y && yum install epel-release -y
  • 配置主机名
#192.168.5.26设置
hostnamectl set-hostname ceph1
#192.168.5.27设置
hostnamectl set-hostname ceph2
#192.168.5.28设置
hostnamectl set-hostname ceph3
  • 配置hosts文件(所有节点均要配置)
vim /etc/hosts
# 内容如下
192.168.5.26 ceph1
192.168.5.27 ceph2
192.168.5.28 ceph3
  • 关闭防火墙(所有节点均要配置)
systemctl  stop firewalld
systemctl   disable firewalld
  • 设置免密登录 (在主节点 192.168.5.26 配置 )
#需按3次回车获得主节点密钥
ssh-keygen
#将密钥分别下发到 各节点
ssh-copy-id root@ceph2
ssh-copy-id root@ceph3
  • 配置时区同步(所有节点均需配置)
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
yum install ntp -y
systemctl enable ntpd
systemctl start ntpd
ntpstat
  • 配置ceph源 (这里在网上找的清华源)
#打开文件
vim /etc/yum.repos.d/ceph.repo
#在文件中写入一下内容
[Ceph]
name=Ceph packages for $basearch
baseurl=https://mirror.tuna.tsinghua.edu.cn/ceph/rpm-mimic/el7/$basearch
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://mirror.tuna.tsinghua.edu.cn/ceph/keys/release.asc
priority=1
[Ceph-noarch]
name=Ceph noarch packages
baseurl=https://mirror.tuna.tsinghua.edu.cn/ceph/rpm-mimic/el7/noarch
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://mirror.tuna.tsinghua.edu.cn/ceph/keys/release.asc
priority=1
[ceph-source]
name=Ceph source packages
baseurl=https://mirror.tuna.tsinghua.edu.cn/ceph/rpm-mimic/el7/SRPMS
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://mirror.tuna.tsinghua.edu.cn/ceph/keys/release.asc
priority=1
  • 安装 ceph-deploy(在主节点 192.168.5.26 执行 )
yum install ceph-deploy -y
mkdir ceph-cluster
cd ceph-cluster
  • 安装 epel-release (所有节点均 执行 )
yum install epel-release -y
  • 创建集群 (在主节点 192.168.5.26 执行 )
ceph-deploy new ceph1 ceph2 ceph3
#执行成功后会在 ceph-cluster 目录下生成配置文件 ceph.conf,打开ceph.conf 
vim ceph.conf
# 在文件尾部添加一下内容
public network = 192.168.5.0/24
cluster network = 192.168.5.0/24
osd pool default size = 3
osd pool default min size = 2
osd pool default pg num = 128
osd pool default pgp num = 128
osd pool default crush rule = 0
osd crush chooseleaf type = 1
max open files = 131072
ms bing ipv6 = false

[mon]
mon clock drift allowed      = 10
mon clock drift warn backoff = 30
mon osd full ratio           = .95
mon osd nearfull ratio       = .85
mon osd down out interval    = 600
mon osd report timeout       = 300
mon allow pool delete      = true

[osd]
osd recovery max active      = 3    
osd max backfills            = 5
osd max scrubs               = 2
osd mkfs type = xfs
osd mkfs options xfs = -f -i size=1024
osd mount options xfs = rw,noatime,inode64,logbsize=256k,delaylog
filestore max sync interval  = 5
osd op threads               = 2

  • 安装Ceph软件到指定节点(在主节点 192.168.5.26 执行 )
ceph-deploy install --no-adjust-repos ceph1 ceph2 ceph3
#使用参数  –no-adjust-repos是直接使用本地源,不生成官方源
  • 部署初始的monitors,并获得keys(在主节点 192.168.5.26 执行 )
ceph-deploy mon create-initial
#执行后会在 ceph-cluster 下生成5个 以  xxx.keyring 文件
  • 将生成的配置文件 以及密钥文件 复制到各节点(在主节点 192.168.5.26 执行 )
ceph-deploy admin ceph1 ceph2 ceph3
  • 配置ceph-mgr(在主节点 192.168.5.26 执行 )
ceph-deploy mgr create cephadmin
  • 配置OSD(在主节点 192.168.5.26 执行)
#如果创建虚拟机时没有添加第二块磁盘则需要关闭虚拟机 添加磁盘后 在进行一下操作
ceph-deploy osd create --data /dev/sdb ceph1
ceph-deploy osd create --data /dev/sdb ceph2
ceph-deploy osd create --data /dev/sdb ceph3
  • 开启MGR 监控模块
yum install ceph-mgr-dashboard -y

vim ceph.conf
#设置配置文件 ceph.conf 并在文件加入一下内容
[mon]
mgr initial modules = dashboard
#将配置文件下发给各节点
ceph-deploy --overwrite-conf config push ceph1 ceph2 ceph3
#重启mgr 
# 重启mgr
systemctl restart ceph-mgr@ceph1 ceph-mgr@ceph2 ceph-mgr@ceph3
  • 配置web登录
#默认情况下,仪表板的所有HTTP连接均使用SSL/TLS进行保护
ceph config-key set mgr/dashboard/server_port 8080 # 设置端口为8080
ceph config-key set mgr/dashboard/server_addr 192.168.5.26 # 设置绑定ip
ceph config set mgr mgr/dashboard/ssl false # 因为是内网使用,所以关闭ssl
# 重启一下dashboard
ceph mgr module disable dashboard
ceph mgr module enable dashboard
ceph dashboard set-login-credentials admin qwe@qwe123 
# 设置用户名密码
  • 到此 安装ceph环境完成 可以登录 所设置的ip 查看

参考原文

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值