check_ssl_certificate = False
enable_multipart = True
encoding = UTF-8
encrypt = False
host_base = s3.example.com
host_bucket = %(bucket)s.s3.example.com
proxy_host = 104.197.27.250
proxy_port = 8080
server_side_encryption = True
signature_v2 = True
use_https = False
verbosity =
WARNING
Replace the
proxy_host
with the IP that you obtained from the Pithos service external
load-balancer.
This example uses an unencrypted proxy. Moreover, the access and
secret keys are
the default stored in the
Dockerfile
; change them.
With this configuration in place, you are ready to use
s3cmd
and create buckets to
store content:
$ s3cmd mb s3://foobar
Bucket 's3://foobar/'
created
$ s3cmd ls
2015-06-09 11:19 s3://foobar
If you wanted to use
Boto
in Python, this would work as well:
#!/usr/bin/env python
from
boto.s3.key
import
Key
from
boto.s3.connection
import
S3Connection
from
boto.s3.connection
import
OrdinaryCallingFormat
apikey
=
'AKIAIOSFODNN7EXAMPLE'
secretkey
=
'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'
cf
=
OrdinaryCallingFormat
()
conn
=
S3Connection
(
aws_access_key_id
=
apikey
,
aws_secret_access_key
=
secretkey
,
is_secure
=
False
,
host
=
'104.197.27.250'
,
port
=
8080
,
calling_format
=
cf
)
conn
.
create_bucket
(
'foobar'
)
318 | Chapter 10: Application Use Cases
And that’s it. All of these steps may sound like a lot, but it
has never been that easy to
run an S3 object store. Docker truly makes running distributed applications a breeze.
10.5 DATA: Building a MySQL Galera Cluster on
a Docker Network
Problem
You would like to deploy a MySQL Galera cluster on two Docker hosts, taking advan‐
tage of the new Docker Network feature (see
Recipe 3.14
). Galera is a multimaster
high-availability MySQL database solution.
Solution
Docker Network, which you saw in
Recipe 3.14
, can be used to build a network over‐
lay using the VXLAN protocol across multiple Docker hosts.
The overlay is useful as
it gives containers IP addresses in the same routable subnet and also manages name
resolution by updating
/etc/hosts
on each container. Therefore,
every container
started in the same overlay can reach the other ones by using their container names.
This significantly simplifies networking across hosts, and makes a lot of solutions that
have been built for single hosts also valid for a multiple-hosts setup.
At time of this writing Docker Network is in preview in the experi‐
mental Docker binaries (i.e., 1.8.0-dev). It should be available in
Docker 1.9. The use of a Consul server
may not be needed in the
future.
To build your
Galera
cluster on two Docker hosts, you will start by setting up the
hosts with the experimental Docker binary. You will
then follow the instructions
described in
a blog post
. The setup of this recipe is the same as the one depicted in
Recipe 3.14
. You will start several containers on each node by using the
erkules/
galera:basic
image from Docker Hub.
As always, let’s use a Vagrant box from the repository accompanying this book:
$ git clone https://github.com/how2dock/dockbook.git
$ cd dockbook/ch10/mysqlgalera
$ vagrant up
$
vagrant status
Current machine states:
consul-server running (virtualbox)
mysql-1 running (virtualbox)
mysql-2 running (virtualbox)
Do'stlaringiz bilan baham: