Puppet Class: profile::analytics::database::meta::backup_dest

Defined in:
modules/profile/manifests/analytics/database/meta/backup_dest.pp

Overview

Class profile::analytics::database::meta::backup_dest

Target host to store the analytics meta database snapshot, taken by the role running profile::analytics::database::meta::backup.

Parameters:

  • hive_metastore_host (Any) (defaults to: hiera('profile::analytics::database::meta::backup_dest::hive::metastore_host'))
  • oozie_host (Any) (defaults to: hiera('profile::analytics::database::meta::backup_dest::oozie_host'))
  • enable_backup (Any) (defaults to: hiera('profile::analytics::database::meta::backup_dest::enable_backup', false))


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'modules/profile/manifests/analytics/database/meta/backup_dest.pp', line 6

class profile::analytics::database::meta::backup_dest(
    $hive_metastore_host = hiera('profile::analytics::database::meta::backup_dest::hive::metastore_host'),
    $oozie_host          = hiera('profile::analytics::database::meta::backup_dest::oozie_host'),
    $enable_backup       = hiera('profile::analytics::database::meta::backup_dest::enable_backup', false),
) {

    $backup_dir_group = $::realm ? {
        'production' => 'analytics-admins',
        'labs'       => "project-${::labsproject}",
    }

    if !defined(File['/srv/backup']) {
        file { '/srv/backup':
            ensure => 'directory',
            owner  => 'root',
            group  => $backup_dir_group,
            mode   => '0755',
        }
    }


    $analytics_meta_backup_dir = '/srv/backup/mysql/analytics-meta'
    file { [
            '/srv/backup/mysql',
            $analytics_meta_backup_dir,
        ]:
        ensure => 'directory',
        owner  => 'root',
        group  => $backup_dir_group,
        mode   => '0750',
    }

    # Bacula backups for /srv/backup/mysql/analytics-meta
    if $enable_backup {
        include ::profile::backup::host
        backup::set { 'analytics-meta-mysql-lvm-backup': }
    }

    class { '::rsync::server': }

    # These are probably the same host, but in case they
    # aren't, allow either use of this rsync server module.
    $hosts_allow = unique([$hive_metastore_host, $oozie_host])

    # This will allow $hosts_allow to host public data files
    # generated by the analytics cluster.
    # Note that this requires that cdh::hadoop::mount
    # be present and mounted at /mnt/hdfs
    rsync::server::module { 'backup':
        path        => '/srv/backup',
        read_only   => 'no',
        list        => 'no',
        hosts_allow => $hosts_allow,
        auto_ferm   => true,
    }

    base::service_auto_restart { 'rsync': }

    if !defined(Sudo::User['nagios_check_newest_file_age']) {
        sudo::user { 'nagios_check_newest_file_age':
            user       => 'nagios',
            privileges => ['ALL = NOPASSWD: /usr/local/lib/nagios/plugins/check_newest_file_age'],
        }
    }

    # Alert if backup gets stale.
    $warning_threshold_hours = 26
    $critical_threshold_hours = 48
    nrpe::monitor_service { 'analytics-database-meta-backup-age':
        description   => 'Age of most recent Analytics meta MySQL database backup files',
        nrpe_command  => "/usr/bin/sudo /usr/local/lib/nagios/plugins/check_newest_file_age -V -C --check-dirs -d ${analytics_meta_backup_dir} -w ${$warning_threshold_hours} -c ${critical_threshold_hours}",
        contact_group => 'analytics',
        notes_url     => 'https://wikitech.wikimedia.org/wiki/Analytics/Systems/Cluster/Mysql_Meta',
    }
}