58
Matt Ullmer [email protected] Bootstrapping Made Easy

Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Matt [email protected]

Bootstrapping Made Easy

Page 2: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Yelp’s MissionConnecting people with great

local businesses.

Page 3: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Four DBAs: Jenni, Susanne, Patrick, myself

Hundreds of serversFully managed, configured, and maintained by usPercona Server 5.6Ubuntu 14.04

Who We Are

Page 4: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Basic Architecture

Tying it all together

Global Expansion

Bootstrapping Made Easy

Page 5: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Linux

Apache

MySQL

Python

Basic Architecture

Page 6: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Multiple clusters

Multiple services

Multiple datastores

Basic Architecture: Scaling Out

Page 7: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Time to Automate

Basic Architecture: When To Automate

Page 8: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Basic Architecture

Tying it all together

Global Expansion

Bootstrapping Made Easy

Page 9: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

What is the goal of the system?Self ManagingSelf DeployingSelf TestingSelf Healing

Bootstrapping Made Easy: Tying it all together

Page 10: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

New hosts automaticallyPick a source host in their clusterPull a backup in real timeReparent to an intermediate master databaseService Discovery

Bootstrapping Made Easy: Tying it all together

Page 11: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

New hosts automaticallyPick a source host in their clusterPull a backup in real timeReparent to an intermediate master databaseService Discovery

Bootstrapping Made Easy: Tying it all together

Page 12: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Pick a source host in their clusterPuppet Clusters and RolesSnapshot ServerSmartstack

Bootstrapping Made Easy: Tying it all together

Page 13: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

ClusterMainMonitoring

RolesMasterReportingRead

Bootstrapping Made Easy: Puppet Clusters and Roles

Page 14: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

profile_mysql::instance::valid_roles: - master - read - reporting

profile_mysql::instance::backup_roles: - master - read - reporting

profile_mysql::read_only::master: '0'profile_mysql::read_only::read: '1'profile_mysql::read_only::reporting: '1'

Page 15: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

How we classify environments

EcosystemSuperregionRegionHabitat

Bootstrapping Made Easy: Puppet Clusters and Roles

Page 16: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Pick a source host in their clusterPuppet Clusters and RolesSnapshot ServerSmartstack

Bootstrapping Made Easy: Tying it all together

Page 17: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Snapshot ServerListens on a portCompares incoming connections to expected clusterTriggers an xtrabackup_to_stream encrypted with KMS

Bootstrapping Made Easy: Tying it all together

Page 18: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

class BackupStreamingRequestHandler(BaseRequestHandler): def handle(self): cluster_name = self.request.recv(4096).rstrip() if cluster_name != get_cluster(): return

os.nice(10)

self.request.setsockopt(socket.SOL_SOCKET, SO_PRIORITY, 1)

fileno = self.request.fileno()

os.dup2(fileno, sys.stdin.fileno()) os.dup2(fileno, sys.stdout.fileno())

try: os.execv('/usr/bin/xtrabackup_to_stream', ['xtrabackup_to_stream', '3306']) except ProcessExecutionError as e: if e.returncode == 255: print("This error typically occurs when qpress is called with a blank or corrupted stream") print("Try netcatting the snapshot server on the remote host to debug further") raise

Page 19: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Pick a source host in their clusterPuppet Clusters and RolesSnapshot ServerSmartstack

Bootstrapping Made Easy: Tying it all together

Page 20: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

SmartstackZookeeper, Nerve, SynapseAdvertise thing 'X' at port 'Y' across the infrastructure on a common IP

Susanne is speaking about smartstack later today @ 3:50 in Ballroom D

Bootstrapping Made Easy: Tying it all together

Page 21: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

New hosts automatically Pick a source host in their clusterPull a backup in real timeReparent to an intermediate master databaseService Discovery

Bootstrapping Made Easy: Tying it all together

Page 22: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Pull a backup in real time BackupsBackup TestingStreaming

Bootstrapping Made Easy: Tying it all together

Page 23: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Xtrabackup

Low impact

Compression

Streaming

Backups

Page 24: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

xtrabackup.cnf:port = 3306socket = /mysqld/mysqld.sockdatadir = /mysqld/data/innodb_log_group_home_dir = /mysqld/data/open_files_limit = 2048

Wrapping innobackupex:/usr/bin/innobackupex --defaults-extra-file=xtrabackup.cnf --stream=xbstream --parallel=1 /xtrabackup/tmp --slave-info | nice pigz -p 4 > $OUTFILE

Crontab:45 0 * * * root local_backup_wrapper_script45 10 2-30/2 * * root encryption_and_s3_offsite_script

Page 25: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Pull a backup in real time BackupsBackup TestingStreaming

Bootstrapping Made Easy: Tying it all together

Page 26: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Scan for backups, restore, and verify restorability

Backup Testing

Page 27: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Pull a backup in real time BackupsBackup TestingStreaming

Bootstrapping Made Easy: Tying it all together

Page 28: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

ssh -A db1 "sudo -H /usr/bin/innobackupex --stream=xbstream --parallel=1 --no-version-check --slave-info /databases/tmp | pigz -p 10" 2> xtrabackup.err | pv --name input -c | pigz -d | pv --name output -c | sudo xbstream -C /databases/mysql -x

Page 29: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Xtrabackup_to_streamAutomated version of the previous streamingAdvertises itself with a snapshot server

Streaming Xtrabackup

Page 30: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

compressed_contents() { set +e innobackupex \ --defaults-file='/nail/etc/xtrabackup.cnf' \ --user xtrabackup \ --parallel=8 \ --stream=xbstream \ --slave-info \ --no-version-check \ --tmpdir "$tempdir" \ "$tempdir" 2> innobackupex_stderr innobackupex_retcode="$?" set -e echo "$innobackupex_retcode" > innobackupex_retcode xbstream -c innobackupex_stderr innobackupex_retcode return "$innobackupex_retcode"}

Page 31: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

2016-07-20 09:41:43,377 INFO:root:Connecting to snapshot server on 192.168.0.12016-07-20 09:41:43,378 INFO:root:Unpacking backup

Page 32: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

New hosts automatically Pick a source host in their clusterPull a backup in real timeReparent to an intermediate master databaseService Discovery

Bootstrapping Made Easy: Tying it all together

Page 33: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Reparent to an intermediate master databaseIntermediate MasterReparenting

Bootstrapping Made Easy: Tying it all together

Page 34: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Intermediate MasterSmartstack DiscoverySaves BandwidthEases ReparentingDon't bootstrap from this host

Bootstrapping Made Easy: Tying it all together

Page 35: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Reparent to an intermediate master database Intermediate MasterReparenting

Bootstrapping Made Easy: Tying it all together

Page 36: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

ReparentingDowntime sensu alertingCHANGE MASTER TO…

Bootstrapping Made Easy: Tying it all together

Page 37: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

2016-12-15 11:23:27 33529 [Note] Event Scheduler: Loaded 0 events2016-12-15 11:23:27 33529 [Note] /usr/sbin/mysqld: ready for connections.Version: '5.6.32-78.1-log' socket: '/nail/databases/mysql/mysqld.sock' port: 3306 Percona Server (GPL), Yelp Release 12016-12-15 11:30:16 33529 [Note] 'CHANGE MASTER TO executed'.

Page 38: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

New hosts automaticallyPick a source host in their clusterPull a backup in real timeReparent to an intermediate master databaseService Discovery

Bootstrapping Made Easy: Tying it all together

Page 39: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Service DiscoveryHealthchecksAuto TopologyJoin the Load Balancer

Bootstrapping Made Easy: Tying it all together

Page 40: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Service DiscoveryHealthchecksAuto TopologyJoin the Load Balancer

Bootstrapping Made Easy: Tying it all together

Page 41: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Service DiscoveryHealthchecksAuto TopologyJoin the Load Balancer

Bootstrapping Made Easy: Tying it all together

Page 42: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

We now have all the pieces

Bootstrapping Made Easy: Tying it all together

Page 43: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Basic Architecture

Tying it all together

Global Expansion

Bootstrapping Made Easy

Page 44: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Snapshotting in a new region

How do you launch databases

How do you do service discovery

Global Expansion

Page 45: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Snapshotting in a new region

How do you launch databases

How do you do service discovery

Global Expansion

Page 46: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

main: extra_advertise: region:old_region: - region:new_region

Page 47: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Cross region advertising unlocks automatic bootstrapping

Global Expansion

Page 48: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Snapshotting in a new region

How do you launch databases

How do you do service discovery

Global Expansion

Page 49: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

How do you getdatabases setup?

Hand rolled?

Named?

Global Expansion

Page 50: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Advice: no host is special

Global Expansion

Page 51: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Amazon ASG

Schedules

Terraform

Global Expansion

Page 52: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Snapshotting in a new region

How do you launch databases

How do you do service discovery

Global Expansion

Page 53: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Discovery Service

Global Expansion

Page 54: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Jenkins builds new topology

Jenkins checks the topology is valid

Jenkins pushes it to all services

Global Expansion

Page 55: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Four DBAsMatt UllmerSusanne Lehmann (25 April - 3:50 PM - 4:40 PM @ Ballroom D)Patrick King (26 April - 1:00 PM - 1:50 PM @ Ballroom G)Jenni Snyder

Yelp DBAs

Page 56: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

www.yelp.com/careers/

We're Hiring!

Page 57: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

Questions

Page 58: Bootstrapping Made Easy Matt Ullmer · Puppet Clusters and Roles Snapshot Server Smartstack Bootstrapping Made Easy: Tying it all together. Cluster Main Monitoring Roles Master Reporting

@YelpEngineering

fb.com/YelpEngineers

engineeringblog.yelp.com

github.com/yelp