配置apt源
# wget -q -O- 'https://download.ceph.com/keys/release.asc' | sudo apt-key add -# echo deb https://download.ceph.com/debian-jewel/ $(lsb_release -sc) main | sudo tee /etc/apt/sources.list.d/ceph.list
安装ceph-deploy,一台机器即可
# apt-get install ceph-deploy
安装ceph软件,三台机器都需要安装
# apt-get install ceph
创建集群
# mkdir /opt/ceph# cd /opt/ceph# ceph-deploy new k8s1 k8s2 k8s3# echo mon_pg_warn_max_per_osd = 1000 >> ceph.conf# echo cluster_network=172.16.13.0/24 >> ceph.conf # echo max open files = 131072 >> ceph.conf # echo osd_scrub_begin_hour=1 >> ceph.conf # echo osd_scrub_end_hour=7 >> ceph.conf # echo "osd max object name len = 256" >> ceph.conf# echo "osd max object namespace len = 64" >> ceph.conf
初始化集群
# ceph-deploy mon create-initial
拷贝秘钥
# cp ceph.client.admin.keyring /etc/ceph/
添加osd
由于没有裸盘,所以直接指定目录作为osd,尝试了下新版luminous,ceph-deploy里似乎不支持指定目录作为osd
# mkdir -p /data/ceph/data# chown ceph:ceph /data/ceph/data/# ceph-deploy osd prepare k8s2:/data/ceph/data # ceph-deploy osd activate k8s2:/data/ceph/data
三个节点每个节点一个osd
# ceph -s cluster 6d8963e9-9585-4679-8dac-17b60f2d0c30 health HEALTH_OK monmap e1: 3 mons at {tj006=172.16.41.25:6789/0,tj007=172.16.41.26:6789/0,tj008=172.16.41.27:6789/0} election epoch 12, quorum 0,1,2 tj006,tj007,tj008 osdmap e14: 3 osds: 3 up, 3 in flags sortbitwise,require_jewel_osds pgmap v29: 64 pgs, 1 pools, 0 bytes data, 0 objects 7811 GB used, 39739 GB / 50064 GB avail 64 active+clean
添加mds
# ceph-deploy mds create k8s1# ceph osd pool create k8s_data 32# ceph osd pool create k8s_metadata 32# ceph fs new ceph_k8s k8s_metadata k8s_data# mkdir /data/ceph/cephfs# mount -t ceph 172.16.13.160:6789:/ /data/ceph/cephfs -o name=admin,secretfile=/etc/ceph/admin.secret