一、使用civetweb配置
1.構建第一個radosgw
1)安裝ceph-radosgw
yum install ceph-radosgw -y
2)創建pool,先忽略
cat pool .rgw .rgw.root .rgw.control .rgw.gc .rgw.buckets .rgw.buckets.index .rgw.buckets.extra .log .intent-log .usage .users .users.email .users.swift .users.uid create-pool.sh #!/bin/bash PG_NUM=64 PGP_NUM=64 SIZE=3 for i in `cat /root/pool` do ceph osd pool create $i $PG_NUM ceph osd pool set $i size $SIZE done for i in `cat /root/pool` do ceph osd pool set $i pgp_num $PGP_NUM done
3)創建keyring
ceph-authtool --create-keyring /etc/ceph/ceph.client.radosgw.keyring creating /etc/ceph/ceph.client.radosgw.keyring cat /etc/ceph/ceph.client.radosgw.keyring 生成的是空文件
4)修改文件權限
chown ceph:ceph /etc/ceph/ceph.client.radosgw.keyring
5)生成ceph-radosgw服務對應的用戶和key
ceph-authtool /etc/ceph/ceph.client.radosgw.keyring -n client.rgw.ceph4 --gen-key cat /etc/ceph/ceph.client.radosgw.keyring [client.rgw.ceph4] key = AQCL6s5cilxrIBAA8N40PhP2GAgsmC2dwU3Sig==
6)為用戶添加訪問權限
ceph-authtool -n client.rgw.ceph4 --cap osd 'allow rwx' --cap mon 'allow rwx' /etc/ceph/ceph.client.radosgw.keyring cat /etc/ceph/ceph.client.radosgw.keyring [client.rgw.ceph4] key = AQCL6s5cilxrIBAA8N40PhP2GAgsmC2dwU3Sig== caps mon = "allow rwx" caps osd = "allow rwx"
7)導入keyring到集群中
ceph -k /etc/ceph/ceph.client.admin.keyring auth add client.rgw.ceph4 -i /etc/ceph/ceph.client.radosgw.keyring added key for client.rgw.ceph4 ceph auth list |grep -A 3 rgw installed auth entries: client.rgw.ceph4 key: AQCL6s5cilxrIBAA8N40PhP2GAgsmC2dwU3Sig== caps: [mon] allow rwx caps: [osd] allow rwx
8)配置ceph.conf
[client.rgw.ceph4] host=ceph4 keyring=/etc/ceph/ceph.client.radosgw.keyring log file=/var/log/radosgw/client.radosgw.gateway.log rgw_s3_auth_use_keystone = False rgw_frontends = civetweb port=8080
9)創建日志目錄並修改權限
mkdir /var/log/radosgw chown ceph:ceph /var/log/radosgw
10)啟動radosgw
systemctl start ceph-radosgw@rgw.ceph4 systemctl status ceph-radosgw@rgw.ceph4
啟動rgw,會出現4個pool
[root@ceph4 ~]# ceph osd lspools 1 .rgw.root,2 default.rgw.control,3 default.rgw.meta,4 default.rgw.log, [root@ceph4 ~]# ceph df GLOBAL: SIZE AVAIL RAW USED %RAW USED 29.4GiB 23.3GiB 6.13GiB 20.84 POOLS: NAME ID USED %USED MAX AVAIL OBJECTS .rgw.root 1 1.09KiB 0 7.27GiB 4 default.rgw.control 2 0B 0 7.27GiB 8 default.rgw.meta 3 0B 0 7.27GiB 0 default.rgw.log 4 0B 0 7.27GiB 175
11)查看端口監聽狀態
netstat -antup |grep 8080 tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 25815/radosgw
12)設置開機自啟
systemctl enable ceph-radosgw@rgw.ceph4
2.構建第二個radosgw,(一台主機啟動多實例)
1)創建keyring
ceph-authtool --create-keyring /etc/ceph/ceph.client.ceph4-2.keyring creating /etc/ceph/ceph.client.ceph4-2.keyring cat /etc/ceph/ceph.client.ceph4-2.keyring 生成的是空文件
2)修改文件權限
chown ceph:ceph /etc/ceph/ceph.client.ceph4-2.keyring
3)生成ceph-radosgw服務對應的用戶和key
ceph-authtool /etc/ceph/ceph.client.ceph4-2.keyring -n client.rgw.ceph4-2 --gen-key cat /etc/ceph/ceph.client.ceph4-2.keyring [client.rgw.ceph4-2] key = AQBy+s5cKQNtLRAAfxC7wcnZi0HvgBwtHN7Brw==
4)為用戶添加訪問權限
ceph-authtool -n client.rgw.ceph4-2 --cap osd 'allow rwx' --cap mon 'allow rwx' /etc/ceph/ceph.client.ceph4-2.keyring cat /etc/ceph/ceph.client.ceph4-2.keyring [client.rgw.ceph4-2] key = AQBy+s5cKQNtLRAAfxC7wcnZi0HvgBwtHN7Brw== caps mon = "allow rwx" caps osd = "allow rwx"
5)導入keyring到集群中
ceph -k /etc/ceph/ceph.client.admin.keyring auth add client.rgw.ceph4-2 -i /etc/ceph/ceph.client.ceph4-2.keyring added key for client.rgw.ceph4-2 ceph auth list |grep -A 3 rgw.ceph4-2 installed auth entries: client.rgw.ceph4-2 key: AQBy+s5cKQNtLRAAfxC7wcnZi0HvgBwtHN7Brw== caps: [mon] allow rwx caps: [osd] allow rwx
6)配置ceph.conf
[client.rgw.ceph4-2] host=ceph4 keyring=/etc/ceph/ceph.client.ceph4-2.keyring log file=/var/log/radosgw/client.ceph4-2.log rgw_s3_auth_use_keystone = False rgw_frontends = civetweb port=8082
7)啟動radosgw
systemctl start ceph-radosgw@rgw.ceph4-2 systemctl status ceph-radosgw@rgw.ceph4-2
8)查看端口監聽狀態
netstat -antup |grep 8082 tcp 0 0 0.0.0.0:8082 0.0.0.0:* LISTEN 28356/radosgw
9)設置開機自啟
systemctl enable ceph-radosgw@rgw.ceph4-2
10)驗證倆個實例,均是正常提供服務
netstat -tnlp |grep radosgw tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 25815/radosgw tcp 0 0 0.0.0.0:8082 0.0.0.0:* LISTEN 28356/radosgw
[root@ceph4 ~]# curl ceph4:8080 <?xml version="1.0" encoding="UTF-8"?><ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Owner><ID>anonymous</ID><DisplayName></DisplayName></Owner><Buckets></Buckets></ListAllMyBucketsResult>[root@ceph4 ~]# [root@ceph4 ~]# curl ceph4:8082 <?xml version="1.0" encoding="UTF-8"?><ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Owner><ID>anonymous</ID><DisplayName></DisplayName></Owner><Buckets></Buckets></ListAllMyBucketsResult>[root@ceph4 ~]#