ceph对象存储服务、高可用安装配置
简介: Ceph本质上就是一个rados,利用命令rados就可以访问和使用ceph的对象存储,但作为一个真正产品机的对象存储服务,通常使用的是Restfulapi的方式进行访问和使用。而radosgw其实就是这个作用,安装完radosgw以后,就可以使用api来访问和使用ceph的对象存储服务了。 首先明白一下架构,radosgw其实名副其实,就是rados的一个网关,作用是对外提供对象存储服务。本质上radosgw(其实也是一个命令)和rbd命令一样,其实是ceph集群的客户端。只不过,radosgw即作为rados的客户端,同时又提供http restful接口,作为服务端供用户使用。Radosgw对用户而言就是一个http restful的应用,因此本质上来讲,对其进行使用就是通过http的方式,但显然每次都要用户构建http访问的url和headers不是一个很方便的方式,因此radosgw兼容了通用的对象存储接口,分别是亚马逊的s3和openstack的swift,这也就是说你可以用swift或者s3的客户端来访问radosgw。 Radosgw包含两个命令行工具: 一个是radosgw,这个是用来启动radosgw服务的脚b本,是一个二进制文件; 另外一个是radosgw-admin,这是用来管理radosgw的账号的一个命令行工具,主要用来创建、查看、修改radosgw的账号信息。注意,radowgw的账号信息仅仅是对radosgw的用户而言,这个和ceph中的用户不是一个概念。 Radosgw作为ceph集群(rados)的客户端,因此他在ceph中有一个账号,通常叫做client.radosgw.gateway。在启动radosgw这个服务时,会读取ceph.conf中[client.radosgw.gateway]这个section。RGW业务处理流程:http reqest --> apache 转 FastCgi moduleFastCgi module --> radosgw 通过socket请求实现radosgw --> ceph集群 通过socket实现,调用rados接口一:配置部署环境介绍:1:系统版本:[root@node242 ~]# more /etc/redhat-release CentOS Linux release 7.1.1503 (Core) 2:内核版本:[root@node242 ~]# uname -aLinux node242 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux3:ceph 版本:[root@node242 ~]# ceph --versionceph version 0.94.5 (9764da52395923e0b32908d83a9f7304401fee43)4:集群节点数和osd 情况:[root@node242 ~]# ceph osd treeID WEIGHT TYPE NAME UP/DOWN REWEIGHT PRIMARY-AFFINITY -6 0 host node01 -1 1.35999 root default -2 0.09000 host ceph-deploy 0 0.09000 osd.0 up 1.00000 1.00000 -3 0.09000 host node241 1 0.09000 osd.1 up 1.00000 1.00000 -4 0.09000 host node242 2 0.09000 osd.2 up 1.00000 1.00000 -5 1.00000 host node243 3 1.00000 osd.3 up 1.00000 1.00000 -7 0.09000 host node245 5 0.09000 osd.5 up 1.00000 1.00000 二:部署1:安装Apache服务 在Apache 2.4发行版(如RHEL 7,CentOS7),mod_proxy_fcgi默认已经会安装。 httpd 安装完成,mod_proxy_fcgi可用的服务器上使用。yum install httpd -y2:修改httpd服务,先清理一下配置文件的无用注释;cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak sed -i '/^#/d' /etc/httpd/conf/httpd.conf vim /etc/httpd/conf/httpd.conf修改配置中的LISTEN字段,将网关所在主机的IP地址添加进去Listen 192.168.2.42:80添加ServerName项,添加上自己服务器的IP地址ServerName 192.168.2.42:803:在配置尾部增加如下信息,加载mod_proxy_fcgi首先确认一下模块存在[root@node242 ~]# ll /etc/httpd/modules/mod_proxy_fcgi.so -rwxr-xr-x 1 root root 19360 Nov 20 05:44 /etc/httpd/modules/mod_proxy_fcgi.so添加内容如下:<IfModule !proxy_fcgi_module>LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so</IfModule>4:重启apache服务systemctl start httpd5:配置apache ssl配置 此选项主要为了对应,一些resetful客户端默认使用https;如果公司有信任机构颁发的证书,可以直接使用,如果没有可以自己做一个自认证的证书,网上有很多配置参考文档,本次演示直接使用公司的正式ssl证书。6:安装apache ssl证书相关依赖软件包安装yum install mod_ssl openssl -y##########################需要做自签名证书的参照信息如下:http://docs.ceph.com/docs/master/install/install-ceph-gateway/Enable SSL ==》步骤 2~6############################7:上传公司ssl证书到服务器 (本次演示直接使用公司的正式ssl证书)[root@node242 ceph]# ll-rw-r--r-- 1 root root 6335 Dec 23 15:48 ptengine.cn.crt-rw-r--r-- 1 root root 1704 Dec 23 15:48 ptengine.cn.keycopy文件到相关目录cp -rp ptengine.cn.crt /etc/pki/tls/certs/ptengine.cn.crtcp -rp ptengine.cn.key /etc/pki/tls/private/ptengine.cn.key验证文件是否就位ll /etc/pki/tls/certs/ptengine.cn.crtll /etc/pki/tls/private/ptengine.cn.key8:配置文件修改/etc/httpd/conf.d/ssl.conf首先清理配置文件注释项;cp -rp /etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ssl.conf.baksed -i '/^#/d' /etc/httpd/conf.d/ssl.conf 9:修改配置项如下:vim /etc/httpd/conf.d/ssl.conf SSLCertificateFile /etc/pki/tls/certs/ptengine.cn.crtSSLCertificateKeyFile /etc/pki/tls/private/ptengine.cn.key10:配置修改完成,重启apachesystemctl restart httpd三:安装Ceph对象存储网关服务 ceph网关其实是ceph集群的一个客户端,用户通过这个网关间接访问ceph集群,1:软件包安装:yum install ceph-radosgw -y2:配置Ceph的对象存储准备信息 ceph网关其实是ceph集群的一个客户端,用户通过这个网关间接访问ceph集群,作为客户端,它需要准备如下内容:网关名称,此处用gateway称呼、一个可以访问存储集群的用户以及对应的KEYRING数据资源池,这个由ceph集群提供为网关服务示例准备一个数据存放空间在ceph.conf配置文件中设置gateway信息3:创建访问用户及权限设置创建gateway keyring,ceph-authtool --create-keyring /etc/ceph/ceph.client.radosgw.keyringchmod +r /etc/ceph/ceph.client.radosgw.keyring4:创建网关用户名以及key 此处名字为 client.radosgw.gatewayceph-authtool /etc/ceph/ceph.client.radosgw.keyring -n client.radosgw.gateway --gen-key5:验证:[root@node242 ceph]# more ceph.client.radosgw.keyring [client.radosgw.gateway] key = AQBXI3lWoOC7MBAAWMHg+sNAelf8S3Hm3S5BiQ==6:为KEYRING添加权限ceph-authtool -n client.radosgw.gateway --cap osd 'allow rwx' --cap mon 'allow rwx' /etc/ceph/ceph.client.radosgw.keyring7:验证授权:[root@node242 ceph]# more ceph.client.radosgw.keyring [client.radosgw.gateway] key = AQBXI3lWoOC7MBAAWMHg+sNAelf8S3Hm3S5BiQ== caps mon = "allow rwx" caps osd = "allow rwx" 8:将key添加到集群中ceph -k /etc/ceph/ceph.client.admin.keyring auth add client.radosgw.gateway -i /etc/ceph/ceph.client.radosgw.keyring备注:如果想在多节点安装对象存储服务,将相关的KEYRING文件拷贝到rados-gateway所在的主机 /etc/ceph/目录下9:手动创建poolCeph的对象网关要求Ceph的存储集群池存储特定网关的数据。 如果您创建的用户有权限,网关将自动创建池,但是有些可能创建不成功。手工创建方式如下: 参考命令:ceph osd pool create {poolname} {pg-num} {pgp-num}ceph osd pool create .rgw 128 128ceph osd pool create .rgw.root 128 128ceph osd pool create .rgw.control 128 128ceph osd pool create .rgw.gc 128 128ceph osd pool create .rgw.buckets 128 128ceph osd pool create .rgw.buckets.index 128 128ceph osd pool create .log 128 128ceph osd pool create .intent-log 128 128ceph osd pool create .usage 128 128ceph osd pool create .users 128 128ceph osd pool create .users.email 128 128ceph osd pool create .users.swift 128 128ceph osd pool create .users.uid 128 128如果pool已经存在,系统会给出提示pool '.users.uid' already exists10:查看pool[root@node242 ceph]# ceph osd lspools4 rbd,5 mypool,13 flask_test,16 .rgw,17 .rgw.root,18 .rgw.control,19 .rgw.gc,20 .rgw.buckets,21 .rgw.buckets.index,22 .log,23 .intent-log,24 .usage,25 .users,26 .users.email,27 .users.swift,28 .users.uid,11:将网关配置信息添加到集群配置中,不同的主机注意需要修改host=后面的信息[client.radosgw.gateway]host=node242keyring=/etc/ceph/ceph.client.radosgw.keyringrgw socket path=/var/run/ceph/ceph.radosgw.gateway.fastcgi.socklog file=/var/log/radosgw/client.radosgw.gateway.logrgw frontends=fastcgi socket_port=9000 socket_host=0.0.0.0rgw print continue=false另外按需添加debgu 配置,辅助调试;添加位置为[global] 注意:按需添加,非必须[global]#append the following in the global section.debug ms = 1debug rgw = 2012:创建radosgw服务启动所需环境并修改权限创建数据目录mkdir -p /var/lib/ceph/radosgw/ceph-radosgw.gateway 调整apache运行权限chown apache:apache /var/run/ceph调整日志权限touch /var/log/radosgw/client.radosgw.gateway.logchown apache:apache /var/log/radosgw/client.radosgw.gateway.log13:启动网关服务/etc/init.d/ceph-radosgw start14:验证,服务监听端口 9000[root@node242 ceph]# netstat -tunlpProto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:9000 0.0.0.0:* LISTEN 9372/radosgw 15:添加网关配置文件,用于web server和FastCGI之间的交互官网演示配置信息如下(仅http):vi /etc/httpd/conf.d/rgw.conf<VirtualHost *:80>ServerName localhost 《---如果内部有dns服务器可以写域名,没有dns也可以写本机ip地址,推荐写域名DocumentRoot /var/www/htmlErrorLog /var/log/httpd/rgw_error.logCustomLog /var/log/httpd/rgw_access.log combined# LogLevel debugRewriteEngine OnRewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]SetEnv proxy-nokeepalive 1ProxyPass / unix:///var/run/ceph/ceph.radosgw.gateway.fastcgi.sock|fcgi://localhost:9000/</VirtualHost>本次测试环境将对http、https 同时进行配置,配置文件如下:#########################测试环境配置############################http访问配置<VirtualHost *:80>ServerName rgw.ptengine.cn#DocumentRoot /var/www/htmlErrorLog /var/log/httpd/rgw_error.logCustomLog /var/log/httpd/rgw_access.log combined# LogLevel debugRewriteEngine OnRewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]SetEnv proxy-nokeepalive 1ProxyPass / fcgi://localhost:9000/#ProxyPass / unix:///var/run/ceph/ceph.radosgw.gateway.fastcgi.sock|fcgi://localhost:9000/</VirtualHost>#https访问配置<VirtualHost *:443>SSLEngine onSSLProtocol all -SSLv2SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEASSLCertificateFile /etc/pki/tls/certs/ptengine.cn.crtSSLCertificateKeyFile /etc/pki/tls/private/ptengine.cn.keyServerName rgw.ptengine.cn#DocumentRoot /var/www/htmlErrorLog /var/log/httpd/rgw_error.logCustomLog /var/log/httpd/rgw_access.log combined# LogLevel debugRewriteEngine OnRewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]SetEnv proxy-nokeepalive 1ProxyPass / fcgi://localhost:9000/#ProxyPass / unix:///var/run/ceph/ceph.radosgw.gateway.fastcgi.sock|fcgi://localhost:9000/</VirtualHost>####################################################16:重启apache服务systemctl restart httpd以上配置将对象存储网关配置完成,下面将进行对象存储网关相关功能演示;四:对象存储功能测试;1:radosgw-admin命令简要介绍命令可以是以下选项之一:创建一个新用户user create修改用户user modify显示信息的用户,以及任何潜在的可用子用户和秘钥user info删除用户user rm修改一个子用户subuser modify删除子用户subuser RM 查看存储空间列表radosgw-admin bucket list[ "rgw", "my-new-bucket", "ptmind-test-bucket查看所有的bucket删除bucketradosgw-admin bucket rm s3://my-new-bucket获取s3用户名:rados -p .users.uid ls获取用户详细信息:for user in `rados -p .users.uid ls` ;do radosgw-admin metadata get user:$user;done;删除一个bucket:radosgw-admin bucket unlink --bucket=foo删除一个用户和所有相关的bucket与他们的内容:radosgw-admin user rm --uid=johnny --purge-data删除用户命令:radosgw-admin user rm --uid=pttest2:创建s3类型访问用户radosgw-admin user create --uid=ptmind --display-name="ptmind for ceph" --email=kevin@ptmind.com返回信息如下:{ "user_id": "ptmind", "display_name": "ptmind for ceph", "email": "kevin@ptmind.com", "suspended": 0, "max_buckets": 1000, "auid": 0, "subusers": [], "keys": [ { "user": "ptmind", "access_key": "CLAV9B0BEAAA6XF17P2Y", "secret_key": "DbiQnQGuC7HMadOuptFgVMOMJhnMKKG2UNtePbS5" } ], "swift_keys": [], "caps": [], "op_mask": "read, write, delete", "default_placement": "", "placement_tags": [], "bucket_quota": { "enabled": false, "max_size_kb": -1, "max_objects": -1 }, "user_quota": { "enabled": false, "max_size_kb": -1, "max_objects": -1 }, "temp_url_keys": []}3:创建SWIFT类型USERradosgw-admin subuser create --uid=ptmind --subuser=ptmind :swift --access=full{ "user_id": "ptmind", "display_name": "ptmind for ceph", "email": "kevin@ptmind.com", "suspended": 0, "max_buckets": 1000, "auid": 0, "subusers": [ { "id": "ptmind:ptmind", "permissions": "full-control" } ], "keys": [ { "user": "ptmind:ptmind", "access_key": "3O61RZPCIR5Y4YCKBKP2", "secret_key": "" }, { "user": "ptmind", "access_key": "CLAV9B0BE9BA6XF17P2Y", "secret_key": "DbiQnQGuC7HMadOuptFgVMOMJhnMKKG2UNtePbS5" } ], "swift_keys": [], "caps": [], "op_mask": "read, write, delete", "default_placement": "", "placement_tags": [], "bucket_quota": { "enabled": false, "max_size_kb": -1, "max_objects": -1 }, "user_quota": { "enabled": false, "max_size_kb": -1, "max_objects": -1 }, "temp_url_keys": []}4:实际验证访问下面是官网一段python代码,用于访问网关,并创建bucket,并通过list方法罗列出当前所有的bucket。5:依赖库安装yum install python-boto -y6:保存脚本内容:注意:修改host= 后面ip地址vi s3test.pyimport botoimport boto.s3.connectionaccess_key = 'CLAV9B0BE9BA6XF17P2Y' secret_key = 'DbiQnQGuC7HMadOuptFgVMOMJhnMKKG2UNtePbS5' conn = boto.connect_s3(aws_access_key_id = access_key,aws_secret_access_key = secret_key,host = '192.168.2.42',is_secure=False,calling_format = boto.s3.connection.OrdinaryCallingFormat(),)bucket = conn.create_bucket('ptmind-test-bucket')for bucket in conn.get_all_buckets(): print "{name}\t{created}".format( name = bucket.name, created = bucket.creation_date,)7:运行脚本,查看结果;python s3test.py ptmind-test-bucket 2015-10-10T06:23:48.000Z至此,Ceph集群的对象存储网关安装设置完毕 五:对象存储调试工具推荐:调试对象存储,推荐式s3cmd1:安装和配置s3cmdyum install s3cmd -y2:配置s3cmd进行S3接口测试,初始化 s3cmd本地环境 将之前radosgw-admin创建的user的access_key和secret_key,根据本机实际进行赋值;vim ~/.s3cfg[default]access_key = 6FIZEZBT3LUBTPC60Z33bucket_location = UScloudfront_host = ceph.ptengine.cncloudfront_resource = /2015-12-15/distributiondefault_mime_type = binary/octet-streamdelete_removed = Falsedry_run = Falseencoding = UTF-8encrypt = Falsefollow_symlinks = Falseforce = Falseget_continue = Falsegpg_command = /usr/bin/gpggpg_decrypt = %(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)sgpg_encrypt = %(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)sgpg_passphrase =guess_mime_type = Truehost_base = ceph-100-80host_bucket = %(*)s.ceph-100-80human_readable_sizes = Falselist_md5 = Falselog_target_prefix =preserve_attrs = Trueprogress_meter = Trueproxy_host =proxy_port = 0recursive = Falserecv_chunk = 4096reduced_redundancy = Falsesecret_key = DbiQnQGuC7HMadOuptFgVMOMJhnMKKG2UNtePbS5send_chunk = 4096simpledb_host = rgw.ptengine.cnskip_existing = Falsesocket_timeout = 10urlencoding_mode = normaluse_https = Falseverbosity = WARNING3:测试是否配置成功:s3cmd --configure将会问你一系列问题: AWS S3的访问密钥和安全密钥 对AWS S3双向传输的加密密码和加密数据 为加密数据设定GPG程序的路径(例如,/usr/bin/gpg) 是否使用https协议 如果使用http代理,设定名字和端口配置将以保存普通文本格式保存在 ~/.s3cfg.一路选确定,因为我们已经配置过了,直到最后一步Test选y:########################本人测试环境配置,s3cmd自测ok#############################[root@ceph-100-80 ceph]# more ~/.s3cfg [default]access_key = 6FIZEZBT3LUBTPC60Z33access_token = add_encoding_exts = add_headers = bucket_location = USca_certs_file = cache_file = check_ssl_certificate = Truecheck_ssl_hostname = Truecloudfront_host = rgw.ptengine.cndefault_mime_type = binary/octet-streamdelay_updates = Falsedelete_after = Falsedelete_after_fetch = Falsedelete_removed = Falsedry_run = Falseenable_multipart = Trueencoding = UTF-8encrypt = Falseexpiry_date = expiry_days = expiry_prefix = follow_symlinks = Falseforce = Falseget_continue = Falsegpg_command = /usr/bin/gpggpg_decrypt = %(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)sgpg_encrypt = %(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)sgpg_passphrase = guess_mime_type = Truehost_base = rgw.ptengine.cnhost_bucket = %(*)s.rgw.ptengine.cnhuman_readable_sizes = Falseinvalidate_default_index_on_cf = Falseinvalidate_default_index_root_on_cf = Trueinvalidate_on_cf = Falsekms_key = limitrate = 0list_md5 = Falselog_target_prefix = long_listing = Falsemax_delete = -1mime_type = multipart_chunk_size_mb = 15preserve_attrs = Trueprogress_meter = Trueproxy_host = proxy_port = 0put_continue = Falserecursive = Falserecv_chunk = 4096reduced_redundancy = Falserequester_pays = Falserestore_days = 1secret_key = DbiQnQGuC7HMadOuptFgVMOMJhnMKKG2UNtePbS5send_chunk = 4096server_side_encryption = Falsesignature_v2 = Falsesimpledb_host = rgw.ptengine.cnskip_existing = Falsesocket_timeout = 10stop_on_error = Falsestorage_class = urlencoding_mode = normaluse_https = Falseuse_mime_magic = Trueverbosity = WARNINGwebsite_endpoint = http://rgw.ptengine.cn/website_error = website_index = index.html#####################################################4:s3cmd命令参数介绍:帮助命令:s3cmd --help使用方法1:配置,主要是 Access Key ID 和 Secret Access Keys3cmd --configure2:列举所有 Buckets。(bucket 相当于根文件夹)s3cmd ls3:创建 bucket,且 bucket 名称是唯一的,不能重复。s3cmd mb s3://my-bucket-name4:删除空 buckets3cmd rb s3://my-bucket-name5:列举 Bucket 中的内容s3cmd ls s3://my-bucket-name6:上传 file.txt 到某个 bucket,s3cmd put file.txt s3://my-bucket-name/file.txt7:上传并将权限设置为所有人可读s3cmd put --acl-public file.txt s3://my-bucket-name/file.txt8:批量上传文件s3cmd put ./* s3://my-bucket-name/9:下载文件s3cmd get s3://my-bucket-name/file.txt file.txt10:批量下载s3cmd get s3://my-bucket-name/* ./11:删除文件s3cmd del s3://my-bucket-name/file.txt12:来获得对应的bucket所占用的空间大小s3cmd du -H s3://my-bucket-name######目录处理规则########以下命令都能将dir1 中的文件上传至my-bucket-name,但效果只截然不同的。1:dir1 不带"/"斜杠,那么dir1会作为文件路径的一部分,相当于上传整个dir1目录,即类似 "cp -r dir1/"~/demo$ s3cmd put -r dir1 s3://my-bucket-name/dir1/file1-1.txt -> s3://my-bucket-name/dir1/file1-1.txt [1 of 1]2:带"/"斜杠的 dir1,相当于上传dir1目录下的所有文件,即类似 "cp ./* "~/demo$ s3cmd put -r dir1/ s3://my-bucket-name/dir1/file1-1.txt -> s3://my-bucket-name/file1-1.txt [1 of 1]########同步方法########这是s3cmd 使用难点,但却是最实用的功能。官方使用说明见《s3cmd sync HowTo》http://s3tools.org/s3cmd-sync首先明确,同步操作是要进行MD5校验的,只有当文件不同时,才会被传输。常规同步操作1:同步当前目录下所有文件s3cmd sync ./ s3://my-bucket-name/s3cmd sync s3://my-bucket-name/ ./2:加 "--dry-run"参数后,仅列出需要同步的项目,不实际进行同步。s3cmd sync --dry-run ./ s3://my-bucket-name/3:加 " --delete-removed"参数后,会删除本地不存在的文件。s3cmd sync --delete-removed ./ s3://my-bucket-name/s3cmd sync --delete-removed --force ./ s3://test.bucket 4:加 " --skip-existing"参数后,不进行MD5校验,直接跳过本地已存在的文件。s3cmd sync --skip-existing ./ s3://my-bucket-name/4.2、高级同步操作4.2.1、排除、包含规则(--exclude 、--include)file1-1.txt被排除,file2-2.txt同样是txt格式却能被包含。~/demo$ s3cmd sync --dry-run --exclude '*.txt' --include 'dir2/*' ./ s3://my-bucket-name/exclude: dir1/file1-1.txtupload: ./dir2/file2-2.txt -> s3://my-bucket-name/dir2/file2-2.txt4.2.2、从文件中载入排除或包含规则。(--exclude-from、--include-from)s3cmd sync --exclude-from pictures.exclude ./ s3://my-bucket-name/pictures.exclude 文件内容# Hey, comments are allowed here ;-)*.jpg*.gif4.2.3、排除或包含规则支持正则表达式--rexclude 、--rinclude、--rexclude-from、--rinclude-from六:多节点部署对象存储服务1:安装相关软件包yum install httpd mod_ssl openssl ceph-radosgw python-boto s3cmd -y2:copy文件到相关目录ceph rgw key文件、apache配置文件、ssl证书等rsync -avp --delete /etc/ceph root@172.16.100.81:/etc/cephscp -rp /etc/httpd/conf/httpd.conf root@172.16.100.81:/etc/httpd/conf/scp -rp /etc/pki/tls/certs/ptengine.cn.crt root@172.16.100.81:/etc/pki/tls/certs/ptengine.cn.crtscp -rp /etc/pki/tls/private/ptengine.cn.key root@172.16.100.81:/etc/pki/tls/private/ptengine.cn.keyscp -rp /etc/httpd/conf.d/ssl.conf root@172.16.100.81:/etc/httpd/conf.d/ssl.confscp -rp /etc/httpd/conf.d/rgw.conf root@172.16.100.81:/etc/httpd/conf.d/rgw.conf scp -rp ~/.s3cfg root@172.16.100.81: ~/.s3cfg3:创建目录及日志文件mkdir -p /var/lib/ceph/radosgw/ceph-radosgw.gatewaychown apache:apache /var/run/cephtouch /var/log/radosgw/client.radosgw.gateway.logchown apache:apache /var/log/radosgw/client.radosgw.gateway.log4:将网关配置信息添加到集群配置中,如果是从配置成功的节点copy过来的配置文件,只要修改host=项为本机ip地址即可[client.radosgw.gateway]host=ceph-100-81keyring=/etc/ceph/ceph.client.radosgw.keyringrgw socket path=/var/run/ceph/ceph.radosgw.gateway.fastcgi.socklog file=/var/log/radosgw/client.radosgw.gateway.logrgw frontends=fastcgi socket_port=9000 socket_host=0.0.0.0rgw print continue=false5:修改http监听ip地址为本机vim /etc/httpd/conf/httpd.conf Listen 172.16.100.82:80ServerName 172.16.100.82:806:重启httpd 服务 systemctl restart httpd7:启动radosgw 服务[root@ceph-100-82 ceph]# /etc/init.d/ceph-radosgw startStarting ceph-radosgw (via systemctl): [ OK ]8:验证监听端口[root@ceph-100-82 ceph]# netstat -tunlpActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 172.16.100.82:80 0.0.0.0:* LISTEN 20328/httpd 9:运行脚本,查看结果;python s3test.py ptmind-test-bucket 2015-10-10T06:23:48.000Z如需再次添加节点,按照以上步骤操作即可;七:对象存储高可用、负载均衡配置;本次测试环境,3台服务器配置radosgw服务,信息如下: 172.16.100.80 172.16.100.81 172.16.100.82 实现功能目标:1:多接点负载请求压力;2:单节点故障实现自动冗余;3:提供http、https 请求;使用nginx服务配置反向代理负载均衡;详细配置如下:#########################nginx 反向代理配置###########################nginx——apache/fastcgi/ceph#port 80 upstream rgwstream80 { ip_hash; server 172.16.100.80 max_fails=2 fail_timeout=10s; server 172.16.100.81 max_fails=2 fail_timeout=10s; server 172.16.100.82 max_fails=2 fail_timeout=10s; } upstream rgwstream443 { ip_hash; server 172.16.100.80:443 max_fails=2 fail_timeout=10s; server 172.16.100.81:443 max_fails=2 fail_timeout=10s; server 172.16.100.82:443 max_fails=2 fail_timeout=10s; } server { listen 80; server_name rgw.ptengine.cn; access_log /data/nginxlog/rgw.ptengine.cn.log etllog; proxy_redirect off; location / { # proxy_next_upstream error timeout invalid_header http_500 http_503 http_404; proxy_pass http://rgwstream80; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #允许客户端请求的最大单个文件字节数 client_max_body_size 10m; #缓冲区代理缓冲用户端请求的最大字节数,可以理解为先保存到本再传给用户 client_body_buffer_size 256k; #跟后端服务器连接的超时时间_发起握手等候响应超时时间 proxy_connect_timeout 6m; #连接成功后_等候后端服务器响应时间_其实已经进入后端的排队之等候处理 proxy_read_timeout 6m; #后端服务器数据回传时间_就是在规定时间内后端服务器必须传完所有的数据 proxy_send_timeout 6m; #代理请求缓存区_这个缓存区间会保存用户的头信息以供Nginx进行则处理_一般只要能保存下头信息即可 proxy_buffer_size 64k; #同上 告诉Nginx保存单个用的几个Buffer 最大用多大空间 proxy_buffers 4 256k; #如果系统很忙的时候可以申请更大的proxy_buffers 官方推荐*2 proxy_busy_buffers_size 256k; #proxy缓存临时文件的大小 proxy_temp_file_write_size 256k; # redirecet server error pages to the static pag ! error_page 502 503 504 /502.html; } } server { listen 443; server_name rgw.ptengine.cn; access_log /data/nginxlog/rgw.ptengine.cn.log etllog; ssl on; ssl_certificate /usr/local/nginx/ssl/www.ptengine.cn.crt; ssl_certificate_key /usr/local/nginx/ssl/www.ptengine.cn.key; proxy_redirect off; location / { proxy_next_upstream error timeout invalid_header http_500 http_503 http_404; proxy_pass https://rgwstream443; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #允许客户端请求的最大单个文件字节数 client_max_body_size 10m; #缓冲区代理缓冲用户端请求的最大字节数,可以理解为先保存到本再传给用户 client_body_buffer_size 256k; #跟后端服务器连接的超时时间_发起握手等候响应超时时间 proxy_connect_timeout 6m; #连接成功后_等候后端服务器响应时间_其实已经进入后端的排队之等候处理 proxy_read_timeout 6m; #后端服务器数据回传时间_就是在规定时间内后端服务器必须传完所有的数据 proxy_send_timeout 6m; #代理请求缓存区_这个缓存区间会保存用户的头信息以供Nginx进行则处理_一般只要能保存下头信息即可 proxy_buffer_size 64k; #同上 告诉Nginx保存单个用的几个Buffer 最大用多大空间 proxy_buffers 4 256k; #如果系统很忙的时候可以申请更大的proxy_buffers 官方推荐*2 proxy_busy_buffers_size 256k; #proxy缓存临时文件的大小 proxy_temp_file_write_size 256k; error_page 502 503 504 /502.html; } } 外围主机需要使用s3cmd调用存储网关上传下载文件,操作步骤如下:安装软件包:yum install mod_ssl openssl python-boto s3cmd -y生成配置文件:vim ~/.s3cfg[default]access_key = 6FIZEZBT3LUBTPC60Z33access_token = add_encoding_exts = add_headers = bucket_location = USca_certs_file = cache_file = check_ssl_certificate = Truecheck_ssl_hostname = Truecloudfront_host = rgw.ptengine.cndefault_mime_type = binary/octet-streamdelay_updates = Falsedelete_after = Falsedelete_after_fetch = Falsedelete_removed = Falsedry_run = Falseenable_multipart = Trueencoding = UTF-8encrypt = Falseexpiry_date = expiry_days = expiry_prefix = follow_symlinks = Falseforce = Falseget_continue = Falsegpg_command = /usr/bin/gpggpg_decrypt = %(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)sgpg_encrypt = %(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)sgpg_passphrase = guess_mime_type = Truehost_base = rgw.ptengine.cnhost_bucket = %(*)s.rgw.ptengine.cnhuman_readable_sizes = Falseinvalidate_default_index_on_cf = Falseinvalidate_default_index_root_on_cf = Trueinvalidate_on_cf = Falsekms_key = limitrate = 0list_md5 = Falselog_target_prefix = long_listing = Falsemax_delete = -1mime_type = multipart_chunk_size_mb = 15preserve_attrs = Trueprogress_meter = Trueproxy_host = proxy_port = 0put_continue = Falserecursive = Falserecv_chunk = 4096reduced_redundancy = Falserequester_pays = Falserestore_days = 1secret_key = pTh23YAx8aXFBdFlhPV4lTTrQweYNprDyQj0Ff3nsend_chunk = 4096server_side_encryption = Falsesignature_v2 = Falsesimpledb_host = rgw.ptengine.cnskip_existing = Falsesocket_timeout = 10stop_on_error = Falsestorage_class = urlencoding_mode = normaluse_https = Falseuse_mime_magic = Trueverbosity = WARNINGwebsite_endpoint = http://rgw.ptengine.cn/website_error = website_index = index.html测试是否配置成功:s3cmd --configure将会问你一系列问题: AWS S3的访问密钥和安全密钥 对AWS S3双向传输的加密密码和加密数据 为加密数据设定GPG程序的路径(例如,/usr/bin/gpg) 是否使用https协议 如果使用http代理,设定名字和端口配置将以保存普通文本格式保存在 ~/.s3cfg.一路选确定,因为我们已经配置过了,直到最后一步Test选y:最终验证:[root@lvs-3-65 tmp]# s3cmd ls正常返回结果为ok;2015-12-28 09:23 s3://rgw2016-01-04 10:49 s3://synctest2016-01-04 09:55 s3://test.bucketYou have new mail in /var/spool/mail/root参考文档:http://docs.ceph.com/docs/master/man/8/radosgw/http://www.ithao123.cn/content-8387956.htmlhttp://my.oschina.net/myspaceNUAA/blog/515261my.oschina.net/myspaceNUAA/blog/515261