Quantcast
Channel: CodeSection,代码区,数据库(综合) - CodeSec
Viewing all articles
Browse latest Browse all 6262

Miles to go ... - Arun Gupta: Stateful Containers using Portworx and Couchbase

$
0
0

Miles to go ... - Arun Gupta: Stateful Containers using Portworx and Couchbase
Miles to go ... - Arun Gupta: Stateful Containers using Portworx and Couchbase

Containers are meant to be ephemeral and so scale prettywell for stateless applications. Stateful containers, such as Couchbase, need to be treated differently. Managing Persistence for Docker Containers provide a great overview of how to manage persistence for stateful containers.

This blog willexplain how to use Docker Volume Plugins and Portworx to create astateful container.

Why Portworx?

Portworx is an easy-to-deploy container data services that provide persistence, replication, snapshots, encryption, secure RBAC and much more. Some of the benefitsare:

Container granular volumes Portworx can take multiple EBS volumes per host and aggregate the capacity and derive container granular virtual (soft) volumes per container. Cross Availability Zone HA Portworx will protect the data, at block level, across multiple compute instances across availability zones. As replication controllers restart pods on different nodes, the data will still be highly available on those nodes. Support for enterprise data operations Portworx implements container granular snapshots, class of service, tiering on top of the available physical volumes. Ease of deployment and provisioning Portworx itself is deployed as a container and integrated with the orchestration tools. DevOps can programmatically provision container granular storage with any property such as size, class of service, encryption key etc. Setup AWS EC2 Instance

Portworx runs only on linux or CoreOS. Setup an Ubuntu instance on AWS EC2:

Start Ubuntu 14.04 instancewith m3.medium instance type. Make sure toadd port 8091 to inbound security rules. This allows Couchbase Web Console to be accessible afterwards. Login to the EC2 instance using the command: ssh -i ~/.ssh/arun-cb-west1.pem ubuntu@<public-ip> Update the Ubuntu instance: sudo apt-get update Install Docker: curl -sSL https://get.docker.com/ | sh . More detailed instructions are available at Get Docker for Ubuntu . Enable non-root access for the docker command: sudo usermod -aG docker ubuntu Logout from the EC2 instance and log back in Create AWS EBS Volume Create an EBS volume for 10GB using EC2 console as explained in docs . Get the instance id from the EC2 console. Attach this volume to EC2 instance using this instance id, use the default device name /dev/sdf.
Miles to go ... - Arun Gupta: Stateful Containers using Portworx and Couchbase
Use lsblk command in EC2 instance to verify that the volume is attached to the instance:
NAMEMAJ:MINRMSIZEROTYPEMOUNTPOINT xvda202:008G0 disk └─xvda1 202:108G0 part / xvdb202:16030G0 disk /mnt xvdf202:80010G0 disk Portworx Container Physical storage makeup of each node, all the provisioned volumes in the cluster as well as their container mappings is stored in an etcd cluster. Start an etcd cluster:
dockerrun -v \ /data/varlib/etcd \ -p 4001:4001 \ -d \ portworx/etcd:latest By default root mounted volumes are not allowed to be shared. Enable this using the command:
sudomount --make-shared / This is explained more at Ubuntu Configuration and Shared Mounts . PX-Developer (px-dev)container on a server with Docker Engine turns that server into a scale-out storage node. PX-Enterprise, on the other hand, provides multi-cluster and multi-cloud support, where storage under management can be on-premise or in a public cloud like AWS.
For this blog, we’ll start a px-dev container:
dockerrun --restart=always --namepx -d --net=host \ --privileged=true\ -v /run/docker/plugins:/run/docker/plugins\ -v /var/lib/osd:/var/lib/osd:shared\ -v /dev:/dev\ -v /etc/pwx:/etc/pwx\ -v /opt/pwx/bin:/export_bin:shared\ -v /var/run/docker.sock:/var/run/docker.sock\ -v /var/cores:/var/cores\ -v /usr/src:/usr/src\ --ipc=host\ portworx/px-dev -daemon -k etcd://localhost:4001 -c cluster1 -s /dev/xvdf Complete details about this command are available at Run PX with Docker . Look for logs using docker container logs -f px and watch out for the following statements:
time="2017-02-16T05:33:26Z" level=infomsg="Initialize the scheduler client and the scheduler watch" time="2017-02-16T05:33:26Z" level=infomsg="Started a kvdb watch on key : scheduler/containers" time="2017-02-16T05:33:26Z" level=infomsg="Started a kvdb watch on key : scheduler/volumes" time="2017-02-16T05:33:26Z" level=infomsg="Started a kvdb watch on key : scheduler/nodes/list" Check the status of attached volumes that are available to Portworx using sudo /opt/pwx/bin/pxctl status to see the output:
Status: PXis operational NodeID: 679b79b1-f4c3-413e-a8e0-c527348647c9 IP: 172.31.25.21 LocalStoragePool: 1 pool PoolIO_PrioritySizeUsedStatusZoneRegion 0LOW10 GiB266 MiBOnlineaus-west-1 LocalStorageDevices: 1 device DevicePathMediaTypeSizeLast-Scan 0:1/dev/xvdfSTORAGE_MEDIUM_SSD10 GiB16 Feb 17 05:33 UTC total-10 GiB ClusterSummary ClusterID: cluster1 NodeIP: 172.31.25.21 - Capacity: 266 MiB/10 GiBOnline (This node) Global StoragePool TotalUsed:266 MiB TotalCapacity:10 GiB It shows the total capacity available and used. Docker Volume Let’s create a Docker volume:
dockervolumecreate -d pxd -o size=10G -o fs=ext4 --namecbvol More details about this command are at CreateVolumes with Docker . Check the list of volumes availableusing docker volume ls command:
DRIVERVOLUMENAME local70f7b9a356df4c1f0c08e13a4e813f1ef3e174a91001f277a63b62d683a27159 pxdcbvol localf7bc5fa455a88638c106881f1bce98244b670e094d5fdc47917b53a88e46c073 As shown,

Viewing all articles
Browse latest Browse all 6262

Trending Articles