ceph在激活OSD的时候提示没有权限

ceph在激活OSD的时候提示没有权限

试验环境:KVM虚拟机

Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.2 LTS
Release:	16.04
Codename:	xenial

我是按着官方文档一步一步部署的:http://docs.ceph.com/docs/master/start/quick-ceph-deploy/

之前都没提示错误,直到最后激活OSD的时候提示没有权限。
ceph-deploy osd activate os0:/var/local/osd0 osd1:/var/local/osd1

部分日志如下:

[2017-06-03 11:07:16,805][osd0][WARNING] Traceback (most recent call last):
[2017-06-03 11:07:16,806][osd0][WARNING]   File "/usr/sbin/ceph-disk", line 9, in 
[2017-06-03 11:07:16,807][osd0][WARNING]     load_entry_point('ceph-disk==1.0.0', 'console_scripts', 'ceph-disk')()
[2017-06-03 11:07:16,808][osd0][WARNING]   File "/usr/lib/python2.7/dist-packages/ceph_disk/main.py", line 5047, in run
[2017-06-03 11:07:16,809][osd0][WARNING]     main(sys.argv[1:])
[2017-06-03 11:07:16,811][osd0][WARNING]   File "/usr/lib/python2.7/dist-packages/ceph_disk/main.py", line 4998, in main
[2017-06-03 11:07:16,812][osd0][WARNING]     args.func(args)
[2017-06-03 11:07:16,813][osd0][WARNING]   File "/usr/lib/python2.7/dist-packages/ceph_disk/main.py", line 3365, in main_activate
[2017-06-03 11:07:16,814][osd0][WARNING]     init=args.mark_init,
[2017-06-03 11:07:16,815][osd0][WARNING]   File "/usr/lib/python2.7/dist-packages/ceph_disk/main.py", line 3185, in activate_dir
[2017-06-03 11:07:16,817][osd0][WARNING]     (osd_id, cluster) = activate(path, activate_key_template, init)
[2017-06-03 11:07:16,818][osd0][WARNING]   File "/usr/lib/python2.7/dist-packages/ceph_disk/main.py", line 3290, in activate
[2017-06-03 11:07:16,819][osd0][WARNING]     keyring=keyring,
[2017-06-03 11:07:16,820][osd0][WARNING]   File "/usr/lib/python2.7/dist-packages/ceph_disk/main.py", line 2773, in mkfs
[2017-06-03 11:07:16,821][osd0][WARNING]     '--setgroup', get_ceph_group(),
[2017-06-03 11:07:16,822][osd0][WARNING]   File "/usr/lib/python2.7/dist-packages/ceph_disk/main.py", line 2720, in ceph_osd_mkfs
[2017-06-03 11:07:16,824][osd0][WARNING]     raise Error('%s failed : %s' % (str(arguments), error))
[2017-06-03 11:07:16,825][osd0][WARNING] ceph_disk.main.Error: Error: ['ceph-osd', '--cluster', 'ceph', '--mkfs', '--mkkey', '-i', u'0', '--monmap', '/var/local/osd0/activate.monmap', '--osd-data', '/var/local/osd0', '--osd-journal', '/var/local/osd0/journal', '--osd-uuid', u'd78c0b25-4972-4b3c-8aa7-5dc19b004f9d', '--keyring', '/var/local/osd0/keyring', '--setuser', 'ceph', '--setgroup', 'ceph'] failed : 2017-06-03 11:07:16.796543 7f037b2a38c0 -1 filestore(/var/local/osd0) mkfs: write_version_stamp() failed: (13) Permission denied
[2017-06-03 11:07:16,829][osd0][WARNING] 2017-06-03 11:07:16.796549 7f037b2a38c0 -1 OSD::mkfs: ObjectStore::mkfs failed with error -13
[2017-06-03 11:07:16,831][osd0][WARNING] 2017-06-03 11:07:16.796565 7f037b2a38c0 -1 ESC[0;31m ** ERROR: error creating empty object store in /var/local/osd0: (13) Permission deniedESC[0m
[2017-06-03 11:07:16,833][osd0][WARNING]
[2017-06-03 11:07:16,846][osd0][ERROR ] RuntimeError: command returned non-zero exit status: 1
[2017-06-03 11:07:16,847][ceph_deploy][ERROR ] RuntimeError: Failed to execute command: /usr/sbin/ceph-disk -v activate --mark-init systemd --mount /var/local/osd0

ceph version 10.2.7 (50e863e0f4bc8f4b9e31156de690d765af245185)

找到原因了,原来是/var/local/osd0和/var/local/osd1这两个目录,ceph用户没有操作权限。

开始没想到是这个原因,因为这两个目录里已经有文件存在了,我就认为ceph已经有权限操作它了,但是实际情况是,有些操作ceph不会使用sudo去操作,所以导至权限问题。

方法1:sudo chown ceph:ceph /var/local/osd0

方法2:

sudo setfacl -m u:ceph:rwx /var/local/osd0

sudo setfacl -m g:ceph:rwx /var/local/osd0

主机osd1用同样的方法操作。

 

这是我在https://www.oschina.net/question/3518954_2243936发的贴子,没人回答自己找到原因了

发表评论