diff --git a/scripts/influxdb.service b/scripts/influxdb.service index cbcdde335a..063d7034a5 100644 --- a/scripts/influxdb.service +++ b/scripts/influxdb.service @@ -9,7 +9,7 @@ After=network-online.target User=influxdb Group=influxdb LimitNOFILE=65536 -EnvironmentFile=-/etc/default/influxdb +EnvironmentFile=-/etc/default/influxdb2 ExecStart=/usr/bin/influxd KillMode=control-group Restart=on-failure diff --git a/scripts/influxdb2-upgrade.sh b/scripts/influxdb2-upgrade.sh new file mode 100755 index 0000000000..a7fe519b7a --- /dev/null +++ b/scripts/influxdb2-upgrade.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Environment defaults +INFLUXD_CONFIG_PATH=/etc/influxdb/config.toml +INFLUXD_BOLT_PATH=/var/lib/influxdb/influxd.bolt +INFLUXD_ENGINE_PATH=/var/lib/influxdb/engine + +export INFLUXD_CONFIG_PATH INFLUXD_BOLT_PATH INFLUXD_ENGINE_PATH + +# Check upgrade status +bolt_dir="/root/.influxdbv2 /var/lib/influxdb/.influxdbv2 /var/lib/influxdb" +for bolt in $bolt_dir +do + if [[ -s ${bolt}/influxd.bolt ]]; then + echo "An existing ${bolt}/influxd.bolt file was found indicating InfluxDB is" + echo "already upgraded to v2. Exiting." + exit 1 + fi +done + +# Perform upgrade +sudo /usr/bin/influxd upgrade \ + --config-file=/etc/influxdb/influxdb.conf \ + --v2-config-path=${INFLUXD_CONFIG_PATH} \ + -m $INFLUXD_BOLT_PATH -e $INFLUXD_ENGINE_PATH + +if [[ $? -eq 0 ]]; then +cat << EOF + +The upgrade completed successfully. Execute the following to start InfluxDB: + +sudo systemctl start influxdb +EOF +fi + +sudo cp /root/.influxdbv2/configs /var/lib/influxdb +sudo chown influxdb:influxdb /var/lib/influxdb/influxd.bolt /var/lib/influxdb/configs +sudo chown -R influxdb:influxdb /var/lib/influxdb/engine diff --git a/scripts/post-install.sh b/scripts/post-install.sh index a714aeaee9..c27b78b927 100644 --- a/scripts/post-install.sh +++ b/scripts/post-install.sh @@ -5,6 +5,7 @@ DATA_DIR=/var/lib/influxdb LOG_DIR=/var/log/influxdb SCRIPT_DIR=/usr/lib/influxdb/scripts LOGROTATE_DIR=/etc/logrotate.d +INFLUXD_CONFIG_PATH=/etc/influxdb/config.toml function install_init { cp -f $SCRIPT_DIR/init.sh /etc/init.d/influxdb @@ -24,9 +25,39 @@ function install_chkconfig { chkconfig --add influxdb } +function upgrade_notice { +cat << EOF + +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +! Important 1.x to 2.x Upgrade Notice ! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +Thank you for installing InfluxDB v2. Due to significant changes between +the v1 and v2 versions, upgrading to v2 requires additional steps. If +upgrading to v2 was not intended, simply re-install the v1 package now. + +An upgrade helper script is available that should be reviewed and executed +prior to starting the influxdb systemd service. In order to start the v2 +upgrade, execute the following: + +sudo /usr/share/influxdb/influxdb2-upgrade.sh + +Visit our website for complete details on the v1 to v2 upgrade process: +https://docs.influxdata.com/influxdb/v2.0/upgrade/v1-to-v2/ + +For new or upgrade installations, please review the getting started guide: +https://docs.influxdata.com/influxdb/v2.0/get-started/ + +EOF +} + # Add defaults file, if it doesn't exist -if [[ ! -f /etc/default/influxdb ]]; then - touch /etc/default/influxdb +if [[ ! -s /etc/default/influxdb2 ]]; then +cat << EOF > /etc/default/influxdb2 +INFLUXD_CONFIG_PATH=/etc/influxdb/config.toml +INFLUXD_BOLT_PATH=/var/lib/influxdb/influxd.bolt +INFLUXD_ENGINE_PATH=/var/lib/influxdb/engine +EOF fi # Remove legacy symlink, if it exists @@ -73,27 +104,14 @@ elif [[ -f /etc/os-release ]]; then fi fi -# Upgrade notice -cat << EOF -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -! Important 1.x to 2.x Upgrade Notice ! -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +# Check upgrade status +bolt_dir="/root/.influxdbv2 /var/lib/influxdb/.influxdbv2 /var/lib/influxdb" +for bolt in $bolt_dir +do + if [[ -s ${bolt}/influxd.bolt ]]; then + # Found a bolt file, assume previous v2 upgrade + exit 0 + fi +done -Thank you for installing InfluxDB v2. Due to significant changes between -the v1 and v2 versions, upgrading to v2 requires additional steps. If -upgrading to v2 was not intended, please simply re-install the v1 package now. - -Please review the complete upgrade procedure: - -https://docs.influxdata.com/influxdb/v2.0/upgrade/v1-to-v2/ - -Minimally, the following steps will be necessary: - -* Make a copy of all underlying v1 data (typically under /var/lib/influxdb) -* Run the 'influxd upgrade' command -* Follow the prompts to complete the upgrade process - -For new or upgrade installations, please also review the getting started guide: - -https://docs.influxdata.com/influxdb/v2.0/get-started/ -EOF \ No newline at end of file +upgrade_notice