|
1 | 1 | # Triển khai Radosgw trên Ceph Cluster
|
2 | 2 | ---
|
3 | 3 | ## Chuẩn bị
|
4 |
| -Đọc các tài liệu |
5 |
| -Sử dụng lab 3 node ceph |
| 4 | +### Sơ đồ |
| 5 | + |
| 6 | +### Tài nguyên |
| 7 | +__Yều cầu 3 node chạy ceph, 1 node giả lập app sử dụng s3 API__ |
| 8 | + |
| 9 | +> Tất cả chạy CentOS 7 |
6 | 10 |
|
7 | 11 | ## Cài đặt
|
8 |
| -### Phần 1: Thiết lập Ceph Radosgw |
| 12 | +### Phần 1: Cài đặt Ceph |
| 13 | +[Cài đặt Ceph theo Lab 3 node](ceph-3node-lab.md) |
| 14 | + |
| 15 | +> Thiết lập IP theo lab hiện tại |
| 16 | +
|
| 17 | +### Phần 2: Thiết lập Ceph Radosgw |
| 18 | +> Thực hiện trên __ceph-admin__ |
| 19 | +
|
9 | 20 | #### Bước 1: Thiết lập tại ceph-admin (Node có quyền admin)
|
10 |
| -> Thực hiện trên ceph-admin |
11 | 21 |
|
12 | 22 | Truy cập ceph-admin
|
13 | 23 | ```
|
@@ -35,7 +45,9 @@ __Kết quả__
|
35 | 45 |
|
36 | 46 | pic 1
|
37 | 47 |
|
38 |
| -### Phần 2: Tạo radosgw user |
| 48 | +### Phần 3: Tạo radosgw user |
| 49 | +> Thực hiện trên __ceph-admin__ |
| 50 | +
|
39 | 51 | #### Tổng quát
|
40 | 52 | Để có thể sử dụng Ceph object storage, ta cần tạo user truy cập Radosgw. User được định danh bằng access và secret key, sử dụng cho mục đích truy cập, thực hiện các hoạt động trên Ceph object storage.
|
41 | 53 |
|
@@ -118,8 +130,8 @@ ssh root@ceph-admin
|
118 | 130 | "temp_url_keys": []
|
119 | 131 | }
|
120 | 132 | ```
|
121 |
| -### Phần 3: Kiểm tra user cung cấp bởi Radosgw |
122 |
| -> Thực hiện trên ceph-admin (có thể trên ceph-client) |
| 133 | +### Phần 4: Kiểm tra user cung cấp bởi Radosgw |
| 134 | +> Thực hiện trên __ceph-admin__ (có thể trên ceph-client) |
123 | 135 |
|
124 | 136 | __Cài đặt gói__
|
125 | 137 | ```
|
@@ -173,7 +185,138 @@ __Xóa bucket test__
|
173 | 185 | radosgw-admin bucket rm my-new-bucket
|
174 | 186 | ```
|
175 | 187 |
|
176 |
| -### Phần 3: Truy cập Ceph object storage |
| 188 | +### Phần 5: Truy cập Ceph object storage thông qua s3 interface |
177 | 189 | Ở đây sẽ truy cập Ceph object thông qua S3 API tương thích.
|
| 190 | +> Thực hiện các bước sau tại __ceph-s3 node__ |
| 191 | +
|
| 192 | +#### Thiết lập file host |
| 193 | +Thiết lập file host trên ceph-s3 node |
| 194 | +``` |
| 195 | +[root@ceph-s3 ~]# vim /etc/hosts |
| 196 | +``` |
| 197 | +Nội dung |
| 198 | +``` |
| 199 | +192.168.2.136 ceph-admin |
| 200 | +
|
| 201 | +192.168.2.137 ceph-node-1 cephgw.test.lab |
| 202 | +
|
| 203 | +192.168.2.138 ceph-node-2 |
| 204 | +
|
| 205 | +192.168.2.144 ceph-s3 |
| 206 | +``` |
| 207 | +#### Bước 1: Cài đặt s3cmd |
| 208 | +``` |
| 209 | +yum install epel-release -y |
| 210 | +yum install python-pip -y |
| 211 | +pip install s3cmd |
| 212 | +``` |
| 213 | + |
| 214 | +Kiểm tra version s3cmd |
| 215 | +``` |
| 216 | +[root@ceph-s3 ~]# s3cmd --version |
| 217 | +s3cmd version 2.0.1 |
| 218 | +``` |
| 219 | + |
| 220 | +#### Bước 2: Thiết lập kết nối s3cmd với Ceph thông qua S3 API |
| 221 | +> Sử dụng user vừa tạo tại phần 2 để truy cập Radosgw |
| 222 | +
|
| 223 | +``` |
| 224 | +[root@ceph-s3 ~]# s3cmd --configure |
| 225 | +
|
| 226 | +Enter new values or accept defaults in brackets with Enter. |
| 227 | +Refer to user manual for detailed description of all options. |
| 228 | +
|
| 229 | +Access key and Secret key are your identifiers for Amazon S3. Leave them empty for using the env variables. |
| 230 | +Access Key [UDW5NH3UZ83CK1W0U2PW]: |
| 231 | +Secret Key [BjPiwiRRdTmgK50SjeDCmgVgfNWjfPgTIRTTr4Zq]: |
| 232 | +Default Region [US]: |
| 233 | +
|
| 234 | +Use "s3.amazonaws.com" for S3 Endpoint and not modify it to the target Amazon S3. |
| 235 | +S3 Endpoint [cephgw.test.lab:7480]: |
| 236 | +
|
| 237 | +Use "%(bucket)s.s3.amazonaws.com" to the target Amazon S3. "%(bucket)s" and "%(location)s" vars can be used |
| 238 | +if the target S3 system supports dns based buckets. |
| 239 | +DNS-style bucket+hostname:port template for accessing a bucket [cephgw.test.lab:7480]: cephgw.test.lab:7480 |
| 240 | +
|
| 241 | +Encryption password is used to protect your files from reading |
| 242 | +by unauthorized persons while in transfer to S3 |
| 243 | +Encryption password [thanh]: |
| 244 | +Path to GPG program [/bin/gpg]: |
| 245 | +
|
| 246 | +When using secure HTTPS protocol all communication with Amazon S3 |
| 247 | +servers is protected from 3rd party eavesdropping. This method is |
| 248 | +slower than plain HTTP, and can only be proxied with Python 2.7 or newer |
| 249 | +Use HTTPS protocol [No]: No |
| 250 | +
|
| 251 | +On some networks all internet access must go through a HTTP proxy. |
| 252 | +Try setting it here if you can't connect to S3 directly |
| 253 | +HTTP Proxy server name: |
| 254 | +
|
| 255 | +New settings: |
| 256 | + Access Key: UDW5NH3UZ83CK1W0U2PW |
| 257 | + Secret Key: BjPiwiRRdTmgK50SjeDCmgVgfNWjfPgTIRTTr4Zq |
| 258 | + Default Region: US |
| 259 | + S3 Endpoint: cephgw.test.lab:7480 |
| 260 | + DNS-style bucket+hostname:port template for accessing a bucket: cephgw.test.lab:7480 |
| 261 | + Encryption password: thanh |
| 262 | + Path to GPG program: /bin/gpg |
| 263 | + Use HTTPS protocol: False |
| 264 | + HTTP Proxy server name: |
| 265 | + HTTP Proxy server port: 0 |
| 266 | +
|
| 267 | +Test access with supplied credentials? [Y/n] y |
| 268 | +Please wait, attempting to list all buckets... |
| 269 | +Success. Your access key and secret key worked fine :-) |
| 270 | +
|
| 271 | +Now verifying that encryption works... |
| 272 | +Success. Encryption and decryption worked fine :-) |
| 273 | +
|
| 274 | +Save settings? [y/N] y |
| 275 | +Configuration saved to '/root/.s3cfg' |
| 276 | +``` |
| 277 | +> Kết nối s3 API thành công với Ceph Radosgw |
| 278 | +
|
| 279 | +> Lưu ý cả thiết lập: Access Key, Secret Key, S3 Endpoint, S3 system supports dns based buckets, Use HTTPS protocol [No]: No |
| 280 | +__Tạo bucket thông qua s3 cmd__ |
| 281 | + |
| 282 | +``` |
| 283 | +[root@ceph-s3 ~]# s3cmd ls |
| 284 | +[root@ceph-s3 ~]# s3cmd mb s3://first-bucket |
| 285 | +Bucket 's3://first-bucket/' created |
| 286 | +[root@ceph-s3 ~]# s3cmd put /etc/hosts s3://first-bucket |
| 287 | +upload: '/etc/hosts' -> 's3://first-bucket/hosts' [1 of 1] |
| 288 | + 287 of 287 100% in 1s 149.55 B/s done |
| 289 | +``` |
| 290 | + |
| 291 | +### Phần 6: Kiểm chứng |
| 292 | +#### Kiểm tra tại Ceph storage cluste |
| 293 | +> Thực hiện tại node có quyền admin trong ceph |
| 294 | +
|
| 295 | +Kiểm tra bucket vừa tạo thông qua s3 interface tại ceph-s3 node |
| 296 | +``` |
| 297 | +[root@ceph-admin cluster]# radosgw-admin bucket list --bucket=first-bucket |
| 298 | +[ |
| 299 | + { |
| 300 | + "name": "hosts", |
| 301 | + "instance": "", |
| 302 | + "namespace": "", |
| 303 | + "owner": "lacoski", |
| 304 | + "owner_display_name": "my user lacoski", |
| 305 | + "size": 287, |
| 306 | + "mtime": "2018-03-01 06:54:26.738998Z", |
| 307 | + "etag": "4913007553cb4d9f13babc6cec275407", |
| 308 | + "content_type": "text\/plain", |
| 309 | + "tag": "f0332421-32af-4fc3-8a3e-c55a5b365b60.84105.9", |
| 310 | + "flags": 0, |
| 311 | + "user_data": "" |
| 312 | + } |
| 313 | +] |
| 314 | +``` |
| 315 | +> The Ceph Object Gateway supports a subset of the Amazon S3 policy language applied to buckets. [Link](http://docs.ceph.com/docs/master/radosgw/bucketpolicy/) |
178 | 316 |
|
179 |
| -#### |
| 317 | +## Nguồn |
| 318 | +http://docs.ceph.com/docs/master/radosgw/bucketpolicy/# |
| 319 | +http://s3tools.org/usage |
| 320 | +http://s3tools.org/s3cmd |
| 321 | +http://s3tools.org/s3cmd-howto |
| 322 | +https://linuxconfig.org/getting-started-with-aws-s3cmd-command-by-examples |
0 commit comments