Skip to main content

Generic clustering package for EC2, suitable for redis/postgresql etc.

This package makes it easier to deploy clustered applications such as PostgreSQL and Redis on EC2 by handling generic logic, including:

* Deciding which role the instance should assume
* Creating and updating DNS records
* Preparing the instance for its role (e.g. writing a recovery.conf file for postgres)

Basic Usage:

The default ec2cluster classes assume your EC2 instances have JSON-encoded user data containing some specific attributes. The following attributes are required:

* cluster - the name of the cluster, e.g. maindb

Install ec2cluster with pip:

pip install ec2cluster

Create a configuration file:

MASTER_CNAME = 'master.%(cluster)s.example.com'
SLAVE_CNAME = 'slave.%(cluster)s.example.com'
INIT_MASTER_SCRIPT = '/path/to/some_script.py'
INIT_SLAVE_SCRIPT = '/path/to/another_script.py'

Run ec2cluster, specifying the path to the config file:

ec2cluster init # initialise the cluster service
ec2cluster promote # promote a slave to the master role

PostgreSQL cluster:

When starting a postgres read-slave, a file named recovery.conf must be written to the postgres configuration directory. A template file is used to make it easy to customise your recovery options.

Config file:

MASTER_CNAME = 'master.%(cluster)s.example.com'
SLAVE_CNAME = 'slave.%(cluster)s.example.com'
RECOVERY_TEMPLATE = '/path/to/template.conf'
RECOVERY_FILENAME = '/var/lib/postgresql/9.1/main/recovery.conf'

In the recovery template file, specify the options required for your read-slaves. Instance metadata and userdata can be used for string replacement. For example:

standby_mode = on
recovery_target_timeline = latest
pause_at_recovery_target = false
restore_command = '/usr/bin/s3cmd --config=/var/lib/postgresql/.s3cfg get s3://%(cluster)s/archive/wal/%%f %%p'
primary_conninfo = 'host=%(master_cname) port=5432 user=postgres password=secret sslmode=disable

Note the use of “%%f” - because we are using string formatting we need to escape the percentage sign in order to end up with “%f” as required by postgres.

Metadata

Release files for ec2cluster 0.28

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ec2cluster 0.28
File Size Uploaded Provenance Actions
ec2cluster-0.28.tar.gz 8.5 kB Without provenance Details for ec2cluster-0.28.tar.gz

Release files / ec2cluster-0.28.tar.gz

Download URL ec2cluster-0.28.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
896ad3d1578b796c7a1eae9cb0d0e0b709fd9ca93c9cf1479722f9605a5bb947
BLAKE2b-256 checksum
How to use checksums
3c2e6371928bc5abecc57a188b59aa91a33db70f47e49a3cf0afe41f71c30924
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for ec2cluster 0.28

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page