OpenStack Swiftã®ä»£ããã«Riak-CSã使ã£ã¦ã¿ã
OpenStackã§ã¯ãªãã¸ã§ã¯ãã¹ãã¬ã¼ã¸ãµã¼ãã¹ã¨ãã¦Swiftã使ãã¾ãããAPIã¬ã¤ã¤ã§å·®ãæãå¯è½ãªã³ã³ãã¼ãã³ãã¨ãã¦SwiftStackãRiak-CSãªã©ãããã¾ããä»åã®è¨äºã§ã¯ãåæ£ãªãã¸ã§ã¯ãã¹ãã¬ã¼ã¸ Riak-CS ãOpenStackã¨çµã¿åãããæ¹æ³ã«ã¤ãã¦ã¾ã¨ãã¦ã¿ã¾ãã
Riak-CSã§åºæ¥ããã¨
Riak-CS㯠Basho Technologies社ãéçºããAmazon S3ã®APIãæã¤åæ£ãªãã¸ã§ã¯ãã¹ãã¬ã¼ã¸ã®ã½ããã¦ã§ã¢ã§ã2013å¹´3æã«ãªã¼ãã³ã½ã¼ã¹åããã¾ãããRiak-CSã¯åæ£ãã¼ã¿ãã¼ã¹ Riak ã®ä¸ã§åä½ããã¢ã¼ããã¯ãã£ãåã£ã¦ãããããRiakã®ç¹é·ã§ããé«ãAvailabilityãScalabilityãå®ç¾ããã¦ãã¾ãã
Swiftã§ã¯é£½ã足ããªã人ãRiakã大好ããªäººã¯ãæ¯éãã®è¨äºãåèã« OpenStack ã®ãªãã¸ã§ã¯ãã¹ãã¬ã¼ã¸ã Riak-CS ã«ãã¦ã楽ãã¿ãã ããã
æ å ±æº
Riak-CSã対å¿ãã¦ããèªè¨¼æ¹å¼
Riak-CSãOpenStack KeyStoneã¨é£ä¿ãããéã«å©ç¨ã§ããèªè¨¼æ¹å¼ã¯ä»¥ä¸ã®2ã¤ãããã¾ãã
Riak-CSã対å¿ãã¦ãã SwiftäºæAPI
Riak-CSã§å©ç¨ã§ãã SwiftäºæAPIã¯ä»¥ä¸ã®éãã§ãã
- List Containers(lists all buckets for authenticated user)
- List Objects
- Create Container
- Delete Container
- Get Object
- Create or Update Object
- Delete Object
ã¤ã³ã¹ãã¼ã«æ¹æ³
æ¬è¨äºã§ã¯ãã½ã¼ã¹ã³ã¼ããããã«ãããå½¢ã§ã®ã¤ã³ã¹ãã¼ã«æ¹æ³ã解説ãã¾ããkeystoneã«ã¤ãã¦ã¯ãdevstackãç¨ãã¦ã¤ã³ã¹ãã¼ã«ãã¾ãã
riak, riak-csåã³stanchionã®ã½ã¼ã¹ã³ã¼ãããã¦ã³ãã¼ããã
$ git clone https://github.com/basho/riak $ git clone https://github.com/basho/riak_cs $ git clone https://github.com/basho/stanchion
riakããã«ããã
$ cd riak $ git branch -b 1.4.2 refs/tags/1.4.2 $ make stagedevrel $ cd ..
riak-csããã«ããã
$ cd riak_cs $ git branch -b 1.4.3 refs/tags/1.4.3 $ make stagedevrel $ cd ..
stanchionããã«ããã
$ cd stanchion $ git branch -b 1.4.3 refs/tags/1.4.3 $ make devrel $ cd ..
riakã®è¨å®ãriak-csåãã«ä¿®æ£ããriakããã»ã¹ãèµ·åãã
$ cd riak $ vi dev/dev1/etc/app.conf
(riak_kv storage_backend ã®ç®æãã³ã¡ã³ãããä¸è¨ã追å ) {add_paths, ["/home/foobar/src-github/riak-swift-test/riak_cs/dev/dev1/lib/riak_cs/ebin"]}, {storage_backend, riak_cs_kv_multi_backend}, {multi_backend_prefix_list, [{<<"0b:">>, be_blocks}]}, {multi_backend_default, be_default}, {multi_backend, [ {be_default, riak_kv_eleveldb_backend, [ {max_open_files, 50}, {data_root, "./data/leveldb"} ]}, {be_blocks, riak_kv_bitcask_backend, [ {data_root, "./data/bitcask"} ]} ]}, (riak_core ä¸è¨ã®é ç®ã追å ) {default_bucket_props, [{allow_mult, true}]},
$ ulimit -n 4096 $ dev/dev1/bin/riak start $ cd ..
riak-csã®è¨å®ãä¿®æ£ããriak-csããã»ã¹ãèµ·åãã
$ cd ../riak_cs $ vi dev/dev1/etc/app.config
(adminã¢ã«ã¦ã³ããä½æãããããä¸æçã«èªè¨¼ç¡ãã®è¨å®ã«ãã) {anonymous_user_creation, true}, (riakã®ãã¼ãè¨å®ãå¤æ´ãã) riak_cs, ... {riak_pb_port, 10017 } ,
$ dev/dev1/bin/riak-cs start
stanchionããã»ã¹ãèµ·åãã
$ vi dev/stanchion/etc/app.config
(stanchion riakãã¼ããå¤æ´ãã) {stanchion,... {riak_pb_port, 10017 },
admin userãä½æãã
$ curl -H 'Content-Type: application/json' \ -X POST http://localhost:8071/riak-cs/user \ --data '{"email":"[email protected]", "name":"admin user"}'
以ä¸ã®ãããªã¡ãã»ã¼ã¸ãè¿ã£ã¦ãã
{ "email" : "[email protected]", "status" : "enabled", "key_id" : "KDGRAVNHTYYF8XNTD7CD", "name" : "admin user", "id" : "e52d4a6ee043848fceecbfeee10f48076924ef2a758d03d9554ecec05d6d1233", "display_name" : "admin", "key_secret" : "9IucFpt32qbAltZb_kEWa5N3bD_N9kbSB5mxsg==" }
riak-cs, stanchionã® Admin User Credentialè¨å®ãä¸è¨ã§ä½æãããã®ã«å¤æ´ãã¦ãanonymous user creation ã disable ã«æ»ã
$ vi dev/stanchion/etc/app.config $ dev/stanchion/bin/stanchion restart $ cd ../riak_cs $ vi dev/dev1/etc/app.config $ dev/dev1/bin/riak-cs restart
s3cmdã§åä½ãã¹ã (ã¾ã㯠Riak-CSåä½ã®åä½ãã¹ã)
$ sudo apt-get install s3cmd $ vi 00s3.cfg
(00s3.cfg) [default] access_key = KDGRAVNHTYYF8XNTD7CD bucket_location = US cloudfront_host = cloudfront.amazonaws.com cloudfront_resource = /2010-07-15/distribution default_mime_type = binary/octet-stream delete_removed = False dry_run = False enable_multipart = False encoding = UTF-8 encrypt = False follow_symlinks = False force = False get_continue = False gpg_command = /usr/local/bin/gpg gpg_decrypt = %(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s gpg_encrypt = %(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s gpg_passphrase = password guess_mime_type = True host_base = s3.amazonaws.com host_bucket = %(bucket)s.s3.amazonaws.com human_readable_sizes = False list_md5 = False log_target_prefix = preserve_attrs = True progress_meter = True proxy_host = localhost proxy_port = 8071 recursive = False recv_chunk = 4096 reduced_redundancy = False secret_key = 9IucFpt32qbAltZb_kEWa5N3bD_N9kbSB5mxsg== send_chunk = 4096 simpledb_host = sdb.amazonaws.com skip_existing = False socket_timeout = 300 urlencoding_mode = normal use_https = True verbosity = WARNING
$ s3cmd -c 00s3.cfg ls $ s3cmd -c 00s3.cfg mb s3://test $ s3cmd -c 00s3.cfg put LICENSE s3://test/obj1 $ s3cmd -c 00s3.cfg ls s3://test/ $ s3cmd -c 00s3.cfg get s3://test/obj1 -
OpenStack Keystoneã®ã¤ã³ã¹ãã¼ã«ãããã»ã¹èµ·å
$ cd .. $ git clone https://github.com/openstack-dev/devstack $ cd devstack $ cp samples/localrc . $ vi localrc
(localrcã®ä¿®æ£) (Swiftåã³Keystoneã®ã¿ãåä½ããããããä¸è¨ã³ã³ãã£ã°ãä»ã足ã) KEYSTONE_BRANCH=stable/havana SERVICE_TOKEN=$ADMIN_PASSWORD disable_all_services enable_service key mysql
$ ./stack.sh $ source openrc admin admin $ keystone service-create --name=swift --type="object-store" \ --description="Swift Service" $ keystone endpoint-create \ --region RegionOne \ --service_id (service id) \ --publicurl "http://localhost:8071/v1/AUTH_\$(tenant_id)s" \ --adminurl "http://localhost:8071" \ --internalurl "http://localhost:8071/v1/AUTH_\$(tenant_id)s" $ keystone catalog
S3 APIã®è¨å®ããã¹ã
$ cd ../riak_cs $ vi dev/dev1/etc/app.config
(app.config) - devstackã®ã³ã³ãã£ã°ã§æå®ãã token ã追å {os_admin_token, "nomoresecrete"}, (Auth URL ãæå®ãã) {os_auth_url, "http://(host or ip address):35357/v2.0/"}, {rewrite_module, riak_cs_s3_rewrite }, {auth_module, riak_cs_keystone_auth },
$ dev/dev1/bin/riak-cs restart $ keystone user-create --name testuser --pass test --email [email protected] --tenant-id (demo tenant id) --enabled true $ keystone role-create --name swiftoperator $ keystone user-role-add --user-id (user-id) --role-id (role-id) --tenant-id (tenant-id) $ keystone ec2-credentials-create --user_id (uid) --tenant_id (tenant-id) $ vi 01s3.cfg (access_key, secret_key ã ec2-credentials-create ã§çæããããã®ã«å¤ãã) $ s3cmd -c 01s3.cfg mb s3://bucket2 $ s3cmd -c 01s3.cfg ls $ echo "ilovechickenilovelivermeowmixmeowmixwilldeliver" > upload.txt $ s3cmd -c 01s3.cfg put upload.txt s3://bucket2 $ s3cmd -c 01s3.cfg get s3://bucket2/upload.txt download.txt $ s3cmd -c 01s3.cfg del s3://bucket2/upload.txt $ s3cmd -c 01s3.cfg rb s3://bucket2
OpenStack(Swift) APIã®è¨å®ããã¹ã
$ vi dev/dev1/etc/app.config
(app.config) {rewrite_module, riak_cs_oos_rewrite }, (API ã Swift API ã«å¤æ´ãã)
$ dev/dev1/bin/riak-cs restart $ curl -s -d '{"auth": {"tenantName": "demo", "passwordCredentials": {"username": "testuser", "password": "test"}}}' -H 'Content-type: application/json' http://localhost:5000/v2.0/tokens | json_pp
$ export ID=... (tokené ç®ã®ä¸ã®idã X-Auth-Tokenã¨ãã¦ä½¿ã) $ export URL=... (object-store service ã® serviceCatalogãããpublicURLã®æ å ±ãå¾ã) $ curl -X PUT -H 'X-Auth-Token: '$ID $URL/bucket1 $ curl -H 'X-Auth-Token: '$ID $URL $ curl -X PUT --data 'abcdefghi123456789' -H 'X-Auth-Token: '$ID $URL/bucket1/object1