From 9b84bc5b1d4904a5519e35f0e4411c7ece9f7b54 Mon Sep 17 00:00:00 2001 From: Guillaume Thouvenin Date: Wed, 16 Dec 2015 11:26:29 +0100 Subject: [PATCH] Upgrade InfluxDB to version 0.9.6.1 InfluxDB uses the /var/lib/influxdb directory to store its data instead of /opt/influxdb previously. Implements: blueprint influxdb-clustering Change-Id: I090298bcbd37e5bd0be876d39525a995f08c2b78 --- .../puppet/modules/influxdb/files/init.sh | 218 ------------------ .../modules/influxdb/manifests/configure.pp | 7 + .../puppet/modules/influxdb/manifests/init.pp | 8 +- .../modules/influxdb/manifests/install.pp | 16 -- .../modules/influxdb/manifests/params.pp | 10 +- .../modules/influxdb/manifests/service.pp | 1 - .../manifests/influxdb.pp | 1 + .../manifests/params.pp | 12 +- .../templates/grafana_dashboards/LMA.json | 22 +- environment_config.yaml | 2 +- pre_build_hook | 2 +- volumes.yaml | 2 +- 12 files changed, 39 insertions(+), 262 deletions(-) delete mode 100644 deployment_scripts/puppet/modules/influxdb/files/init.sh diff --git a/deployment_scripts/puppet/modules/influxdb/files/init.sh b/deployment_scripts/puppet/modules/influxdb/files/init.sh deleted file mode 100644 index cbee4ce3..00000000 --- a/deployment_scripts/puppet/modules/influxdb/files/init.sh +++ /dev/null @@ -1,218 +0,0 @@ -#! /usr/bin/env bash - -### BEGIN INIT INFO -# Provides: influxd -# Required-Start: $all -# Required-Stop: $remote_fs $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Start influxd at boot time -### END INIT INFO - -# If you modify this, please make sure to also edit influxdb.service -# this init script supports three different variations: -# 1. New lsb that define start-stop-daemon -# 2. Old lsb that don't have start-stop-daemon but define, log, pidofproc and killproc -# 3. Centos installations without lsb-core installed -# -# In the third case we have to define our own functions which are very dumb -# and expect the args to be positioned correctly. - -# Command-line options that can be set in /etc/default/influxdb. These will override -# any config file values. Example: "-join http://1.2.3.4:8086" -DEFAULT=/etc/default/influxdb - -# Daemon options -INFLUXD_OPTS= - -# Process name ( For display ) -NAME=influxdb - -# User and group -USER=influxdb -GROUP=influxdb - -# Daemon name, where is the actual executable -# If the daemon is not there, then exit. -DAEMON=/opt/influxdb/influxd -[ -x $DAEMON ] || exit 5 - -# Configuration file -CONFIG=/etc/opt/influxdb/influxdb.conf - -# PID file for the daemon -PIDFILE=/var/run/influxdb/influxd.pid -PIDDIR=`dirname $PIDFILE` -if [ ! -d "$PIDDIR" ]; then - mkdir -p $PIDDIR - chown $USER:$GROUP $PIDDIR -fi - -# Max open files -OPEN_FILE_LIMIT=65536 - -if [ -r /lib/lsb/init-functions ]; then - source /lib/lsb/init-functions -fi - -# Logging -if [ -z "$STDOUT" ]; then - STDOUT=/dev/null -fi - -if [ ! -f "$STDOUT" ]; then - mkdir -p $(dirname $STDOUT) -fi - -if [ -z "$STDERR" ]; then - STDERR=/var/log/influxdb/influxd.log -fi - -if [ ! -f "$STDERR" ]; then - mkdir -p $(dirname $STDERR) -fi - -# Overwrite init script variables with /etc/default/influxdb values -if [ -r $DEFAULT ]; then - source $DEFAULT -fi - -function pidofproc() { - if [ $# -ne 3 ]; then - echo "Expected three arguments, e.g. $0 -p pidfile daemon-name" - fi - - PID=`pgrep -f $3` - local PIDFILE=`cat $2` - - if [ "x$PIDFILE" == "x" ]; then - return 1 - fi - - if [ "x$PID" != "x" -a "$PIDFILE" == "$PID" ]; then - return 0 - fi - - return 1 -} - -function killproc() { - if [ $# -ne 3 ]; then - echo "Expected three arguments, e.g. $0 -p pidfile signal" - fi - - PID=`cat $2` - - /bin/kill -s $3 $PID - while true; do - pidof `basename $DAEMON` >/dev/null - if [ $? -ne 0 ]; then - return 0 - fi - - sleep 1 - n=$(expr $n + 1) - if [ $n -eq 30 ]; then - /bin/kill -s SIGKILL $PID - return 0 - fi - done -} - -function log_failure_msg() { - echo "$@" "[ FAILED ]" -} - -function log_success_msg() { - echo "$@" "[ OK ]" -} - -case $1 in - start) - # Check if config file exist - if [ ! -r $CONFIG ]; then - log_failure_msg "config file doesn't exists" - exit 4 - fi - - # Checked the PID file exists and check the actual status of process - if [ -e $PIDFILE ]; then - pidofproc -p $PIDFILE $DAEMON > /dev/null 2>&1 && STATUS="0" || STATUS="$?" - # If the status is SUCCESS then don't need to start again. - if [ "x$STATUS" = "x0" ]; then - log_failure_msg "$NAME process is running" - exit 0 # Exit - fi - # if PID file does not exist, check if writable - else - su -s /bin/sh -c "touch $PIDFILE" $USER > /dev/null 2>&1 - if [ $? -ne 0 ]; then - log_failure_msg "$PIDFILE not writable, check permissions" - exit 5 - fi - fi - - # Bump the file limits, before launching the daemon. These will carry over to - # launched processes. - ulimit -n $OPEN_FILE_LIMIT - if [ $? -ne 0 ]; then - log_failure_msg "set open file limit to $OPEN_FILE_LIMIT" - exit 1 - fi - - log_success_msg "Starting the process" "$NAME" - if which start-stop-daemon > /dev/null 2>&1; then - start-stop-daemon --chuid $GROUP:$USER --start --quiet --pidfile $PIDFILE --exec $DAEMON -- -pidfile $PIDFILE -config $CONFIG $INFLUXD_OPTS >>$STDOUT 2>>$STDERR & - else - su -s /bin/sh -c "nohup $DAEMON -pidfile $PIDFILE -config $CONFIG $INFLUXD_OPTS >>$STDOUT 2>>$STDERR &" $USER - fi - log_success_msg "$NAME process was started" - ;; - - stop) - # Stop the daemon. - if [ -e $PIDFILE ]; then - pidofproc -p $PIDFILE $DAEMON > /dev/null 2>&1 && STATUS="0" || STATUS="$?" - if [ "$STATUS" = 0 ]; then - if killproc -p $PIDFILE SIGTERM && /bin/rm -rf $PIDFILE; then - log_success_msg "$NAME process was stopped" - else - log_failure_msg "$NAME failed to stop service" - fi - fi - else - log_failure_msg "$NAME process is not running" - fi - ;; - - restart) - # Restart the daemon. - $0 stop && sleep 2 && $0 start - ;; - - status) - # Check the status of the process. - if [ -e $PIDFILE ]; then - if pidofproc -p $PIDFILE $DAEMON > /dev/null; then - log_success_msg "$NAME Process is running" - exit 0 - else - log_failure_msg "$NAME Process is not running" - exit 1 - fi - else - log_failure_msg "$NAME Process is not running" - exit 3 - fi - ;; - - version) - $DAEMON version - ;; - - *) - # For invalid arguments, print the usage message. - echo "Usage: $0 {start|stop|restart|status|version}" - exit 2 - ;; -esac diff --git a/deployment_scripts/puppet/modules/influxdb/manifests/configure.pp b/deployment_scripts/puppet/modules/influxdb/manifests/configure.pp index 5a1f90e4..0a71c2aa 100644 --- a/deployment_scripts/puppet/modules/influxdb/manifests/configure.pp +++ b/deployment_scripts/puppet/modules/influxdb/manifests/configure.pp @@ -19,6 +19,7 @@ class influxdb::configure ( $config_file = undef, $data_dir = undef, $meta_dir = undef, + $wal_dir = undef, $hh_dir = undef, ) { @@ -40,6 +41,12 @@ class influxdb::configure ( value => "\"${data_dir}\"", } + ini_setting { 'wal_dir': + section => 'data', + setting => 'wal-dir', + value => "\"${wal_dir}\"", + } + ini_setting { 'hh_dir': section => 'hinted-handoff', setting => 'dir', diff --git a/deployment_scripts/puppet/modules/influxdb/manifests/init.pp b/deployment_scripts/puppet/modules/influxdb/manifests/init.pp index 702c71ec..cbd4945f 100644 --- a/deployment_scripts/puppet/modules/influxdb/manifests/init.pp +++ b/deployment_scripts/puppet/modules/influxdb/manifests/init.pp @@ -15,9 +15,10 @@ # == Class: influxdb class influxdb ( - $data_dir = $influxdb::params::data_dir, - $hh_dir = $influxdb::params::hh_dir, - $meta_dir = $influxdb::params::meta_dir, + $data_dir = $influxdb::params::data_dir, + $hh_dir = $influxdb::params::hh_dir, + $meta_dir = $influxdb::params::meta_dir, + $wal_dir = $influxdb::params::wal_dir, ) inherits influxdb::params { class {'influxdb::install': } @@ -32,6 +33,7 @@ class influxdb ( data_dir => $data_dir, hh_dir => $hh_dir, meta_dir => $meta_dir, + wal_dir => $wal_dir, notify => Class['influxdb::service'], } } diff --git a/deployment_scripts/puppet/modules/influxdb/manifests/install.pp b/deployment_scripts/puppet/modules/influxdb/manifests/install.pp index d39f5530..cfcab7c9 100644 --- a/deployment_scripts/puppet/modules/influxdb/manifests/install.pp +++ b/deployment_scripts/puppet/modules/influxdb/manifests/install.pp @@ -20,20 +20,4 @@ class influxdb::install { ensure => installed, } - # The init script shipped by InfluxDB 0.9.4 fails because it tries to create - # the PID file using 'su' without specifying /bin/sh while the influxdb user - # has /sbin/nologin as the shell. - file { '/etc/init.d/influxdb': - ensure => present, - source => 'puppet:///modules/influxdb/init.sh', - owner => 'root', - group => 'root', - mode => '0755', - require => Package['influxdb'], - } - - file { '/etc/logrotate.d/influxdb': - ensure => present, - source => 'puppet:///modules/influxdb/logrotate.conf', - } } diff --git a/deployment_scripts/puppet/modules/influxdb/manifests/params.pp b/deployment_scripts/puppet/modules/influxdb/manifests/params.pp index 1062ca97..d3c62da3 100644 --- a/deployment_scripts/puppet/modules/influxdb/manifests/params.pp +++ b/deployment_scripts/puppet/modules/influxdb/manifests/params.pp @@ -17,9 +17,11 @@ class influxdb::params { $auth_enabled = true - $config_file = '/etc/opt/influxdb/influxdb.conf' + $config_file = '/etc/influxdb/influxdb.conf' - $data_dir = '/opt/influxdb/data' - $hh_dir = '/opt/influxdb/hh' - $meta_dir = '/opt/influxdb/meta' + $base_dir = '/var/lib/influxdb' + $data_dir = "${base_dir}/data" + $hh_dir = "${base_dir}/hh" + $meta_dir = "${base_dir}/meta" + $wal_dir = "${base_dir}/wal" } diff --git a/deployment_scripts/puppet/modules/influxdb/manifests/service.pp b/deployment_scripts/puppet/modules/influxdb/manifests/service.pp index ca62f094..fea8bb9f 100644 --- a/deployment_scripts/puppet/modules/influxdb/manifests/service.pp +++ b/deployment_scripts/puppet/modules/influxdb/manifests/service.pp @@ -19,6 +19,5 @@ class influxdb::service { ensure => running, enable => true, hasrestart => true, - status => '/usr/bin/pgrep -u influxdb -f "/opt/influxdb/influxd "' } } diff --git a/deployment_scripts/puppet/modules/lma_monitoring_analytics/manifests/influxdb.pp b/deployment_scripts/puppet/modules/lma_monitoring_analytics/manifests/influxdb.pp index 97a2fa41..ebe16873 100644 --- a/deployment_scripts/puppet/modules/lma_monitoring_analytics/manifests/influxdb.pp +++ b/deployment_scripts/puppet/modules/lma_monitoring_analytics/manifests/influxdb.pp @@ -35,6 +35,7 @@ class lma_monitoring_analytics::influxdb ( data_dir => "${influxdb_dir}/data", meta_dir => "${influxdb_dir}/meta", hh_dir => "${influxdb_dir}/hh", + wal_dir => "${influxdb_dir}/wal", } file { $configure_influxdb: diff --git a/deployment_scripts/puppet/modules/lma_monitoring_analytics/manifests/params.pp b/deployment_scripts/puppet/modules/lma_monitoring_analytics/manifests/params.pp index d215eb15..06b91239 100644 --- a/deployment_scripts/puppet/modules/lma_monitoring_analytics/manifests/params.pp +++ b/deployment_scripts/puppet/modules/lma_monitoring_analytics/manifests/params.pp @@ -15,11 +15,11 @@ # == Class lma_monitoring_analytics::params class lma_monitoring_analytics::params { - $listen_port = 8000 - $influxdb_url = 'http://localhost:8086' - $influxdb_script = '/usr/local/bin/configure_influxdb.sh' - $influxdb_dir = '/opt/influxdb' - $influxdb_retention_period = 0 + $listen_port = 8000 + $influxdb_url = 'http://localhost:8086' + $influxdb_script = '/usr/local/bin/configure_influxdb.sh' + $influxdb_dir = '/var/lib/influxdb' + $influxdb_retention_period = 0 $influxdb_replication_factor = 1 - $grafana_domain = 'localhost' + $grafana_domain = 'localhost' } diff --git a/deployment_scripts/puppet/modules/lma_monitoring_analytics/templates/grafana_dashboards/LMA.json b/deployment_scripts/puppet/modules/lma_monitoring_analytics/templates/grafana_dashboards/LMA.json index 64630ee5..b2323d12 100644 --- a/deployment_scripts/puppet/modules/lma_monitoring_analytics/templates/grafana_dashboards/LMA.json +++ b/deployment_scripts/puppet/modules/lma_monitoring_analytics/templates/grafana_dashboards/LMA.json @@ -1674,7 +1674,7 @@ "tags": [ { "operator": "=", - "value": "/opt/influxdb", + "value": "/var/lib/influxdb", "key": "fs" } ], @@ -1691,14 +1691,14 @@ } ], "measurement": "fs_space_percent_free", - "query": "SELECT mean(\"value\") AS \"value\" FROM \"fs_space_percent_free\" WHERE \"fs\" = '/opt/influxdb' AND $timeFilter GROUP BY time($interval)", + "query": "SELECT mean(\"value\") AS \"value\" FROM \"fs_space_percent_free\" WHERE \"fs\" = '/var/lib/influxdb' AND $timeFilter GROUP BY time($interval)", "refId": "A" } ], "maxDataPoints": 100, "span": 2, "colorBackground": false, - "title": "Free space on /opt/influxdb", + "title": "Free space on /var/lib/influxdb", "sparkline": { "full": false, "fillColor": "rgba(31, 118, 189, 0.18)", @@ -1738,7 +1738,7 @@ "id": 53, "fill": 1, "span": 10, - "title": "Disk usage on /opt/influxdb", + "title": "Disk usage on /var/lib/influxdb", "tooltip": { "shared": true, "value_type": "individual" @@ -1758,7 +1758,7 @@ "tags": [ { "operator": "=", - "value": "/opt/influxdb", + "value": "/var/lib/influxdb", "key": "fs" } ], @@ -1771,7 +1771,7 @@ "refId": "A", "alias": "free", "measurement": "fs_space_free", - "query": "SELECT mean(\"value\") AS \"value\" FROM \"fs_space_free\" WHERE \"fs\" = '/opt/influxdb' AND $timeFilter GROUP BY time($interval) fill(0)", + "query": "SELECT mean(\"value\") AS \"value\" FROM \"fs_space_free\" WHERE \"fs\" = '/var/lib/influxdb' AND $timeFilter GROUP BY time($interval) fill(0)", "groupBy": [ { "interval": "auto", @@ -1785,7 +1785,7 @@ "tags": [ { "operator": "=", - "value": "/opt/influxdb", + "value": "/var/lib/influxdb", "key": "fs" } ], @@ -1798,7 +1798,7 @@ "refId": "B", "alias": "used", "measurement": "fs_space_used", - "query": "SELECT mean(\"value\") AS \"value\" FROM \"fs_space_used\" WHERE \"fs\" = '/opt/influxdb' AND $timeFilter GROUP BY time($interval) fill(0)", + "query": "SELECT mean(\"value\") AS \"value\" FROM \"fs_space_used\" WHERE \"fs\" = '/var/lib/influxdb' AND $timeFilter GROUP BY time($interval) fill(0)", "groupBy": [ { "interval": "auto", @@ -1812,7 +1812,7 @@ "tags": [ { "operator": "=", - "value": "/opt/influxdb", + "value": "/var/lib/influxdb", "key": "fs" } ], @@ -1825,7 +1825,7 @@ "refId": "C", "alias": "reserved", "measurement": "fs_space_reserved", - "query": "SELECT mean(\"value\") AS \"value\" FROM \"fs_space_reserved\" WHERE \"fs\" = '/opt/influxdb' AND $timeFilter GROUP BY time($interval) fill(0)", + "query": "SELECT mean(\"value\") AS \"value\" FROM \"fs_space_reserved\" WHERE \"fs\" = '/var/lib/influxdb' AND $timeFilter GROUP BY time($interval) fill(0)", "groupBy": [ { "interval": "auto", @@ -2946,4 +2946,4 @@ "annotations": { "list": [] } -} \ No newline at end of file +} diff --git a/environment_config.yaml b/environment_config.yaml index cdb9c6c1..25563dbb 100644 --- a/environment_config.yaml +++ b/environment_config.yaml @@ -85,7 +85,7 @@ attributes: # Parameter hidden in the UI on purpose # this directory must match the mount point set in volumes.yaml data_dir: - value: '/opt/influxdb' + value: '/var/lib/influxdb' label: 'InfluxDB storage directory' description: 'Directory used by InfluxDB to store data' weight: 70 diff --git a/pre_build_hook b/pre_build_hook index c8873ab5..d8c4063d 100755 --- a/pre_build_hook +++ b/pre_build_hook @@ -12,7 +12,7 @@ GRAFANA_TARBALL_URL="https://forgeapi.puppetlabs.com/v3/files/bfraser-grafana-2. FUEL_LIB_COMMIT="7.0" FUEL_LIB_TARBALL_URL="https://github.com/openstack/fuel-library/archive/${FUEL_LIB_COMMIT}.tar.gz" -download_package https://s3.amazonaws.com/influxdb/influxdb_0.9.4.2_amd64.deb +download_package https://s3.amazonaws.com/influxdb/influxdb_0.9.6.1_amd64.deb download_package https://grafanarel.s3.amazonaws.com/builds/grafana_2.5.0_amd64.deb diff --git a/volumes.yaml b/volumes.yaml index 32b3c109..218aa21f 100644 --- a/volumes.yaml +++ b/volumes.yaml @@ -6,7 +6,7 @@ volumes: generator_args: [30] label: "InfluxDB database" volumes: - - mount: "/opt/influxdb" + - mount: "/var/lib/influxdb" type: "lv" name: "influxdb" file_system: "ext4"