MongoDB Management & Ansible

46
MongoDB Management Pain Relief Michael Lynn Sr. Solutions Architect, MongoDB @mlynn, @phillyMUG [email protected] OpsManager OpsManager

Transcript of MongoDB Management & Ansible

Page 1: MongoDB Management & Ansible

MongoDB Management

Pain Relief

Michael LynnSr. Solutions Architect, MongoDB

@mlynn, @[email protected]

OpsManager

OpsManager

Page 2: MongoDB Management & Ansible

Goals● Ops Manager, Cloud Manager, Atlas

○ What are they?○ How do they differ?○ Why do I need them?

● Ansible○ What is it and how can I use these tools to relieve some

pain in my life?

00:00:01

Page 3: MongoDB Management & Ansible

Show of Hands

● Who’s Here?○ DevOps/Ops?○ Site Reliability?○ Engineer?○ DBA?○ Developer?

Page 4: MongoDB Management & Ansible

Admin Evolution

3. Puppet, Salt, Ansible

Leveraging automated solution for config mgt, some cloud deployment.

1. Manual

Download by hand, build server from CD, Manually Start and Config Services.

2. Scripting

Write scripts to maintain configurations, copy those to servers and run them.

4. Cloud/Hybrid Automation

Full Cloud-based pro- visioning and management

Page 5: MongoDB Management & Ansible

Managing databases manually can be...

● Painful● Risky● Complex● Susceptible to

human error*● Unnecessary...

* 80% of all downtime due to people/process error (Gartner)

Page 6: MongoDB Management & Ansible

What’s involved in managing MongoDB?

● Provision / Deploy

● Install/Upgrade Binaries

● Configure Database

● Administer Database

● Maintain OS - Mongod

Deploying 42

42

Upgrading 35

70

Maintaining 23

100

Play Top 3 Things DBA’s Hate to Do Manually?

Page 7: MongoDB Management & Ansible

So… what does it take (at scale)?It can take a lot of manual effort to care for a MongoDB system in production

● Install + Configure○ 150+ steps

● Scale out, move servers, resize oplog, etc○ 10 - 180+ steps

● Upgrades, downgrades○ 100+ stepsUpgrade

Deploy

Maintain

Up to 95% Reduction in Operational Overhead

Page 8: MongoDB Management & Ansible

• Single-click provisioning, scaling & upgrades, admin tasks!

• Monitoring, with charts, dashboards and alerts on 100+ metrics

• Backup and restore, with point-in-time recovery, support for sharded clusters

MongoDB Ops ManagerThe Best Way to Manage MongoDB In Your Data Center

Up to 95% Reduction in Operational Overhead

Page 9: MongoDB Management & Ansible

1

2

Group/RBAC

Logical/Physical

3 Replica Set Members

3 MongoDB Version

Page 10: MongoDB Management & Ansible

1Add Replica Set

Page 11: MongoDB Management & Ansible

1Repset Name

2Version of MongoDB

3Server Pool Hostnames

4Port to Run MongoDB

Page 12: MongoDB Management & Ansible

1Member Roles

2DB Path on Server

3Advanced Options Settings

4CLICK APPLY

Page 13: MongoDB Management & Ansible

Activity

Deploy Server Instance

Upgrade (Done For You)

Configure

Administer Database

Maintain OS - Mongod

Maintain OS - OpsMgr

Activity

Deploy Server Instance

Upgrade MongoDB

Configure MongoDB

Administer Database

Maintain OS - Mongod

Maintain OS - OpsMgr

Activity

Deploy Server Instance

Upgrade MongoDB

Configure MongoDB

Administer Database

Maintain OS - Mongod

Maintain OS - OpsMgr

Ops Manager

Cloud Manager Atlas

CONTROL CONVENIENCE

Page 14: MongoDB Management & Ansible

Ops Manager

Cloud Manager Atlas

Where are my servers?

AWS

Where are my servers?

Your Data CenterAWSAzureGCP

Where are my servers?

Your Data CenterAWSAzureGCP

MongoDB Versions?

CommunityOnly Most Recent

MongoDB Versions?

Community, Enterprise

MongoDB Versions?

Community, Enterprise

CONTROL CONVENIENCE

Page 15: MongoDB Management & Ansible

Replica Set Architecture (w/ Ops Manager)

15

APP SERVER

APPLICATION

DRIVER

OPS MANAGER

OM APP

APP BACKUP

REPLICA SET

PRIMARY

SECONDARY SECONDARY

OM AGENT

OM AGENT

OM AGENT

Page 16: MongoDB Management & Ansible

MongoDB Deployment - Ops Manager

Configure Host

Provision Host Configure Agent

1. AWS 2. New Host 3. Ops Manager

Install OM Agent

Restart Agent

Install MongoDB

Configure Monitoring

Configure Backups

Configure Host

Provision Host Configure Agent

Install OM Agent

Restart Agent

Install MongoDB

Configure Monitoring

Configure Backups

2. New Host 3. Ops Manager 1. AWS

Page 17: MongoDB Management & Ansible

MongoDB Deployment - Cloud Manager & Atlas

Configure Host

Provision Host Configure Agent

Install OM Agent

Restart Agent

Provision New Hosts

Configure Monitoring

Configure Backups

AWS New Host Ops Manager

Provision New Hosts

Configure Monitoring

Configure Backups

1. Cloud / Atlas

Page 18: MongoDB Management & Ansible

MongoDB Deployment - Ops Manager

Configure Host

Provision Host Configure Agent

1. AWS 2. New Host 3. Ops Manager

Install OW Agent

Restart Agent

Install MongoDB

Configure Monitoring

Configure Backups

Configure Host

Provision Host Configure Agent

Install OW Agent

Restart Agent

Install MongoDB

Configure Monitoring

Configure Backups

2. New Host 3. Ops Manager 1. AWS

Candidate for

Automation?

Page 19: MongoDB Management & Ansible
Page 20: MongoDB Management & Ansible

20

WHAT IS ANSIBLE?

Confidential

It’s a simple automation language that can perfectly describe an IT application infrastructure in Ansible Playbooks.

It’s an automation engine that runsAnsible Playbooks.

Ansible Tower is an enterprise framework for controlling, securing and managing your Ansible automation with a UI and RESTful API.

Page 21: MongoDB Management & Ansible

21

SIMPLE POWERFUL AGENTLESS

App deployment

Configuration management

Workflow orchestration

Orchestrate the app lifecycle

Human readable automation

No special coding skills needed

Tasks executed in order

Get productive quickly

Agentless architecture

Uses OpenSSH & WinRM

No agents to exploit or update

More efficient & more secure

Confidential

Page 22: MongoDB Management & Ansible

22

ANSIBLE TOWER

CONTROL

SIMPLE POWERFUL AGENTLESS

KNOWLEDGE DELEGATION

TOWER EMPOWERS TEAMS TO AUTOMATE

AT ANSIBLE’S CORE IS AN OPEN-SOURCE AUTOMATION ENGINE

Scheduled andcentralized jobs

Visibility and compliance

Role-based access and self-service

Everyone speaks thesame language

Designed for multi-tier deployments

Predictable, reliable,and secure

Confidential

Page 23: MongoDB Management & Ansible

MongoDB Deployment - Ops Manager

Configure Host

Provision Host Configure Agent

1. AWS 2. New Host 3. Ops Manager

Install OW Agent

Restart Agent

Install MongoDB

Configure Monitoring

Configure Backups

Configure Host

Provision Host Configure Agent

Install OW Agent

Restart Agent

Install MongoDB

Configure Monitoring

Configure Backups

2. New Host 3. Ops Manager 1. AWS

Use Ansible

Page 24: MongoDB Management & Ansible

Getting Started with Ansible - Lexicon● Commands

○ ansible, ansible-playbook

● Configuration○ ansible.cfg

● Modules○ Hundreds of stand-alone scripts to solve common requirements

● Plays, Playbooks○ The execution tools to carry out your management tasks

● Tasks○ The components that connect ansible to the servers

Page 25: MongoDB Management & Ansible

Why Ansible?● Simple● Human Readable● Agentless (uses SSH)● Popular - Lots of Modules● Used by Twitter, NASA, Spotify

Page 26: MongoDB Management & Ansible

Getting Started with Ansible

ansible -m ping -i ansible-hosts opsManager

Here I’m telling ansible to use the ping module against the opsManager group in my ansible-hosts file.

Page 27: MongoDB Management & Ansible

Demo of Ansible

Page 28: MongoDB Management & Ansible

1 - Ansible Configuration Files

Page 29: MongoDB Management & Ansible

2 - Ansible Hosts File

Page 30: MongoDB Management & Ansible

3 - Ansible Modules - Ping

Page 31: MongoDB Management & Ansible

4 - Ansible Environment Variables

Page 32: MongoDB Management & Ansible

5 - Ansible Modules - Script

Page 33: MongoDB Management & Ansible

6 - Ansible Playbooks

Page 34: MongoDB Management & Ansible

7 - Deploying O/M in Playbooks

Page 35: MongoDB Management & Ansible

MongoDB Enterprise Server

MongoDB Enterprise Advanced2

4 x

7 S

uppo

rtC

omm

ercial License

Platform Certifications

Emergency Patches

On-Demand Online Training

Customer Success Program

MongoDB CompassMongoDB Ops Manager

Monitoring & Alerting

Query Optimization

Backup & Recovery

Automation & Configuration

Schema Visualization

Data Exploration

Ad-Hoc Queries

MongoDB Connector for BI

Visualization

Analysis

Reporting

LDAP & Kerberos Auditing FIPS 140-2Encryption at Rest

REST API

Page 36: MongoDB Management & Ansible

Post-Demo Check-in● Atlas

○ DBaaS○ Deploys new MongoDB Clusters from zero to cluster in minutes.

● Ops Manager ○ Automation for all the things you do with MongoDB - except deploying the agent.

● Ansible○ Automation for configs, deployment and more - especially deploying O/M Agents

I hope you learned some ways you can relieve the pain associated with manually configuring, deploying and maintaining your database environment.

Page 37: MongoDB Management & Ansible

Questions?

Get These Scripts and Slides:http://github.com/mrlynn/ansible-demo

Page 38: MongoDB Management & Ansible

BONUS SLIDES!

● Slides probably not used in the presentation.

Page 39: MongoDB Management & Ansible

Demonstration SetupCommand Description

ansible -m ping -i ansible-hosts all Using the ping module and the hosts file ansible-hosts in the current directory, ping all hosts

export ANSIBLE_HOSTS=./ansible_hosts Save some time - ansible uses environment variables extensivel

ansible -m ping all Same as before - but now ansible leverages the env var to find the ansible hosts file.

Page 40: MongoDB Management & Ansible

Demonstration Command Description

ansible -m script test.sh all Here, we take a local script and execute it across all of our hosts. Ansible takes that script and delivers it via scp to the hosts, executes it and captures the output.

export ANSIBLE_HOSTS=./ansible_hosts Save some time - ansible uses environment variables extensivel

ansible -m ping all Same as before - but now ansible leverages the env var to find the ansible hosts file.

Page 41: MongoDB Management & Ansible

Appendix A - /etc/ansible/hosts sample[opsManager]

ec2-54-93-114-205.eu-central-1.compute.amazonaws.com ansible_user=ec2-user

[amlReplicaSet]

ec2-54-93-79-122.eu-central-1.compute.amazonaws.com ansible_user=ec2-user

ec2-54-93-176-246.eu-central-1.compute.amazonaws.com ansible_user=ec2-user

ec2-54-93-207-148.eu-central-1.compute.amazonaws.com ansible_user=ec2-user

[amlReplicaSet:vars]

opsmanagerurl=http://ec2-54-93-114-205.eu-central-1.compute.amazonaws.com:8080

opsmanager=ec2-54-93-114-205.eu-central-1.compute.amazonaws.com

Page 42: MongoDB Management & Ansible

Appendix B - ansible.cfg[defaults]

host_key_checking = False

private_key_file = PATH/TO/AWS/KEY.FILE

[ssh_connection]

control_path = %(directory)s/%%C

Page 43: MongoDB Management & Ansible

Appendix A: Setup

Page 44: MongoDB Management & Ansible

Setup Step 1 - Configure KeysMichaels-MBP-3:setup mlynn$ cat ansible.cfg[defaults]host_key_checking = Falseprivate_key_file = /Users/mlynn/.ssh/michael.lynn.pem

● Create or identify your AWS key.● Locate the ansible.cfg file in the setup directory

of this repo.● Modify ansible.cfg to point to your AWS Key.

Page 45: MongoDB Management & Ansible

Setup Step 1 - EC2 Hosts

Start with:- 1 running m3.xlarge - Ops

Manager- 3 running t2.small - Replica Set

Members

Take note of the Public DNS - add these to ansible-hosts as shown here.

[opsManager]ec2-107-23-40-226.compute-1.amazonaws.com ansible_user=ec2-user

[ReplicaSet]ec2-54-159-211-126.compute-1.amazonaws.com ansible_user=ec2-userec2-54-84-243-170.compute-1.amazonaws.com ansible_user=ec2-userec2-52-90-15-175.compute-1.amazonaws.com ansible_user=ec2-user

[ReplicaSet:vars]opsmanagerurl=http://ec2-107-23-40-226.compute-1.amazonaws.com:8080opsmanager=ec2-107-23-40-226.compute-1.amazonaws.com

Page 46: MongoDB Management & Ansible

Setup Step 2 - Install OpsManager Package

Start with:- 1 running m3.xlarge - Ops

Manager- 3 running t2.small - Replica Set

Members

Take note of the Public DNS - add these to ansible-hosts as shown here.

[opsManager]ec2-54-209-123-125.compute-1.amazonaws.com ansible_user=ec2-user

[ReplicaSet]ec2-107-23-249-134.compute-1.amazonaws.com ansible_user=ec2-userec2-174-129-139-203.compute-1.amazonaws.com ansible_user=ec2-userec2-52-91-79-187.compute-1.amazonaws.com ansible_user=ec2-user

[ReplicaSet:vars]opsmanagerurl=http://ec2-54-209-123-125.compute-1.amazonaws.com:8080opsmanager=ec2-54-209-123-125.compute-1.amazonaws.com