安装
ceph-deploy purge ceph01 ceph01
ceph-deploy purge ceph02 ceph02
ceph-deploy purgedata ceph01 ceph01
ceph-deploy purgedata ceph02 ceph02
配置文件ceph.conf
osd_pool_default_size = 2
public_network =192.168.99.1/24
osd_max_object_name_len = 256
osd_max_object_namespace_len = 64
部署,初始化
ceph-deploy new ceph01
ceph-deploy install ceph01 ceph02
ceph-deploy mon create-initial
添加osd
ssh ceph01
sudo mkdir /var/local/osd0
exit
ssh ceph02
sudo mkdir /var/local/osd1
exit
ceph-deploy osd prepare ceph01:/var/local/osd0 ceph02:/var/local/osd1
activate 之前要先chown ceph:ceph /var/local/osd0
ceph-deploy osd activate ceph01:/var/local/osd0 ceph02:/var/local/osd1
用 ceph-deploy 把配置文件和 admin 密钥拷贝到管理节点和 Ceph 节点,这样你每次执行 Ceph 命令行时就无需指定 monitor 地址和 ceph.client.admin.keyring 了。
ceph-deploy admin ceph01 ceph02
添加 MONITORS
ceph-deploy mon add ceph02
新增 Monitor 后,Ceph 会自动开始同步并形成法定人数。你可以用下面的命令检查法定人数状态:
ceph quorum_status --format json-pretty
练习:定位某个对象
作为练习,我们先创建一个对象,用 rados put 命令加上对象名、一个有数据的测试文件路径、并指定存储池。例如:
创建pool, 两个100分别代表pg_num 和pgp_num
ceph osd pool create data 100 100
echo {Test-data} > testfile.txt
rados put {object-name} {file-path} --pool=data
rados put test-object-1 testfile.txt --pool=data
为确认 Ceph 存储集群存储了此对象,可执行:
rados -p data ls
现在,定位对象:
ceph osd map {pool-name} {object-name}
ceph osd map data test-object-1
Ceph 应该会输出对象的位置,例如:
osdmap e537 pool 'data' (0) object 'test-object-1' -> pg 0.d1743484 (0.4) -> up [1,0] acting [1,0]
用rados rm
命令可删除此测试对象,例如:
rados rm test-object-1 --pool=data
网友评论