ceph单节点部署
1.查询挂载信息
lsblk
2.使用自定义镜像源,默认镜像源地址(可选)
/etc/yum.repos.d/CentOS-Base.repo
替换baseurl路径为本地路径
/root/ceph_install_offline/ceph-package
链接:https://pan.baidu.com/s/180zM5gPcXN5gVkeTLEhYuw
提取码:i8bt
更新yum缓存
yum clean all
yum repolist
yum list installed
3.设置主机名
# 设置 hostname
hostnamectl set-hostname ceph1
# 配置 hosts 解析,IP地址根据实际调整
cat /etc/hosts
192.168.180.148 ceph1
# 重启下
reboot
4.关闭防火墙
# 关闭防火樯
systemctl disable firewalld
systemctl stop firewalld
# 关闭 selinux
setenforce 0
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
6.配置免密登录
给ceph单节点配置免密,一台机器也要
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
# 权限设置 644
chmod 644 ~/.ssh/authorized_keys
7.安装依赖
rpm -ivh http://download.ceph.com/rpm-luminous/el7/noarch/ceph-release-1-1.el7.noarch.rpm
sed -i 's#download.ceph.com#mirrors.aliyun.com/ceph#g' /etc/yum.repos.d/ceph.repo
yum install -y epel-release
yum install ceph ceph-radosgw -y
yum install ceph-deploy python-setuptools python2-subprocess32 ceph-common -y
8.开始安装ceph
mkdir -p /root/ceph-cluster
cd /root/ceph-cluster
ceph-deploy new ceph1
#设置单点配置
echo "osd pool default size = 1" >> ceph.conf
echo "osd pool default min size = 1" >> ceph.conf
#初始化monitor
ceph-deploy mon create-initial
#把配置文件和密钥拷贝到管理节点和Ceph节点
ceph-deploy admin ceph1
#部署mgr
ceph-deploy mgr create ceph1
#添加osd节点
ceph-deploy osd create ceph1 --fs-type xfs --data /dev/sdb
#部署cephfs
ceph-deploy mds create ceph1
ceph osd pool create cephfs_data 64
ceph osd pool create cephfs_metadata 64
ceph fs new cephfs cephfs_metadata cephfs_data
ceph fs ls
#创建秘钥
ceph auth get-or-create client.cephfs mon 'allow r' mds 'allow r, allow rw path=/' osd 'allow rw pool=cephfs_data' -o ceph.client.cephfs.keyring
#获得秘钥
ceph auth get-key client.cephfs
9.挂载测试
#挂载测试
mkdir -p /root/test01
mkdir -p /root/test02
mount -t ceph ceph1:/ /root/test01 -o name=cephfs,secret=AQBBAG9kujReFRAAb7s5C5gR7e1SPRLjCzxG9g==
mount -t ceph ceph1:/ /root/test02 -o name=cephfs,secret=AQBBAG9kujReFRAAb7s5C5gR7e1SPRLjCzxG9g==
10.ceph进程删除和目录卸载 (可选)
ps aux|grep ceph |awk '{print $2}'|xargs kill -9
ps aux|grep ceph |awk '{print $2}'|xargs kill -9
ps -ef|grep ceph
umount /var/lib/ceph/osd/*
rm -rf /var/lib/ceph/osd/*
rm -rf /var/lib/ceph/mon/*
rm -rf /var/lib/ceph/mds/*
rm -rf /var/lib/ceph/bootstrap-mds/*
rm -rf /var/lib/ceph/bootstrap-osd/*
rm -rf /var/lib/ceph/bootstrap-rgw/*
rm -rf /var/lib/ceph/bootstrap-mgr/*
rm -rf /var/lib/ceph/tmp/*
rm -rf /etc/ceph/*
rm -rf /var/run/ceph/*
11.格式化osd (可选)
yum install gdisk -y
export DISK="/dev/sdb"
sgdisk --zap-all $DISK
dd if=/dev/zero of="$DISK" bs=1M count=100 oflag=direct,dsync
blkdiscard $DISK
ls /dev/mapper/ceph-* | xargs -I% -- dmsetup remove %
rm -rf /dev/ceph-*