34
Best Practices for Running PostgreSQL in Production with Ansible Tower Jonathan S. Katz Director of Communications, Crunchy Data

Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

Best Practices for Running PostgreSQL in Production with Ansible TowerJonathan S. KatzDirector of Communications, Crunchy Data

Page 2: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

2

• Director of Communications, Crunchy Data

• Previously: Engineering leadership in startups

• Longtime PostgreSQL community contributor

• Advocacy & various committees for PostgreSQL Global Development Group

• @postgresql + .org content

• Director, PgUS

• Conference organization + speaking

• @jkatz05

About Me

Page 3: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

Market Leading Data Security

Crunchy Data is the leader in PostgreSQL security. Common Criteria certification and essential

security enhancements make Crunchy Certified PostgreSQL the trusted open

source PostgreSQL distribution for the enterprise.

Cloud Ready Data ManagementWhether deploying to public or private clouds, Crunchy Data

provides market leading, open source, Kubernetes-based

technology solutions, giving your team the choice and flexibility for how

you deploy your data.

Leader in Open Source Enterprise PostgreSQLCrunchy Data gives organizations the

technology, support, and confidence to enjoy the power and efficiency of open

source PostgreSQL.

Page 4: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

Share your automation story

1. How did you get started with Ansible?I played around with Ansible many years ago when looking for ways to

automate provisioning development environments as well as managing the deployment tasks of production servers.

2. How long have you been using it?On and off for several years.

3. What's your favorite thing to do when you Ansible?I love taking a playbook designed for deploying a complicated

environment, setting up my inventory file, and then watching it run. It’s like…magic!

Page 5: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

PostgreSQL:An Oldie but a Goodie

Page 6: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

6

• The PostgreSQL relational database is over 30 years old and has been open source since 1996

• Open source like Linux: no single vendor; flexible license; no one can own PostgreSQL

• Recent PostgreSQL releases have brought it to feature parity with popular proprietary databases

• PostgreSQL's extensibility allows it to handle NoSQL workloads, accommodate developer language preferences, and provide full transaction safety and data integrity

• DB-Engines database ranking has PostgreSQL as the #1 growing database in both 2017 & 2018

The Rise of PostgreSQL

Page 7: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's
Page 8: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

8

Running a Database in the Enterprise

Page 9: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

9

What if I said…

…we could build this in one step?

Page 10: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

Show Me

Page 11: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

11

ansible-playbook -i \crunchy-ha-postgresql-active-single-data-center.inventory.yml \crunchy-ha-postgresql-active-single-data-center.playbook.yml

Page 12: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

…this takes a bit of time to provision

We’ll come back later.

Page 13: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

• Stateful workloads have one job: maintain state.• If your lose or corrupt your data, you may suffer severe business

continuity issues, e.g. no business to continue• Specific knowledge is required to perform state modification operations on a

stateful application. For example, with PostgreSQL, what happens when you• …provision a new cluster?• …take a backup?• …restore from a backup?• …promote a new replica?

• How can you ensure you do not corrupt your data?

Motivation: Databases + High-Availability ≠ Simple

Page 14: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

1. Provision an environment

2. Install software

3. Initialize database directory ("initdb")

4. Modify "postgresql.conf" configuration file

5. Start the cluster

6. Add a user to the cluster

7. Add a database to the cluster that the user owns

8. Add authentication rules to "pg_hba.conf" file

9. Reload cluster configuration

Example: Provisioning a PostgreSQL Cluster

Page 15: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

…now do this thousands of times.

Page 16: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

Automation to the Rescue!

Page 17: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

• Uses Ansible Automation to provide essential database-as-a-service functionality:

• Automated deployments

• Automated failover, promotion, & healing

• Advanced disaster recovery capabilities

• Load balancing & connection pooling

• Monitoring & alerting

• Uses all trusted, upstream open source components

Crunchy HA PostgreSQL

Page 18: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

18

Why useCrunchy HA PostgreSQL?

Page 19: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

19

Crunchy HA PostgreSQL: Open Source

Page 20: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

Crunchy HA PostgreSQL:In Depth

Page 21: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

21

Provisioning Workflow

• SELinux• Firewall rules• PostgreSQL• HA components• Disaster Recovery components• Monitoring

Page 22: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

22

Failover & Healing

Page 23: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

23

Disaster Recovery

Page 24: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

24

Monitoring

Page 25: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

Crunchy HA PostgreSQL:Environment Architectures

Page 26: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

26

Single Data Center (or Single AZ)

Crunchy HA PostgreSQL: Built for Scale

Page 27: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

27

Multi Data Center (or Multi-AZ)

Crunchy HA PostgreSQL: Built for Scale

Page 28: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

28Multi-Continent

Crunchy HA PostgreSQL: Built for Scale

Page 29: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

…what about that demo?

Page 30: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

• We saw:

• An example Ansible inventory file for deploying Crunchy HA PostgreSQL

• A PostgreSQL cluster provisioned with one primary instance, two replicas, disaster recovery set up, monitoring set up, firewall rules set

• PostgreSQL operating normally

• A planned PostgreSQL outage where we switched over to a different primary.

• Unplanned downtime of a PostgreSQL primary node, and observed our cluster automatically heal

Crunchy HA PostgreSQL: Demo Recap

Page 31: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

What’s Next?

Page 32: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

• PostgreSQL can be used for mission-critical applications, Crunchy HA PostgreSQL automates this process.

• Come by the Crunchy Data booth (#600)for an in-depth demo! (and a hippo!)

• Come learn about the Crunchy PostgreSQL Platform that lets you deploy PostgreSQL anywhere from a single dashboard!

Crunchy HA PostgreSQL: What’s Next?

Page 33: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's
Page 34: Best Practices for Running PostgreSQL in Production with … ATL Slide Decks... · 2019. 10. 10. · Best Practices for Running PostgreSQL in Production with AnsibleTower ... What's

Thank YouJonathan S. Katz

[email protected] us at Booth #600!