From b07b96cf3241aecb7f4a4384a0c6e5f1cfaf040f Mon Sep 17 00:00:00 2001 From: Phillip Steinbachs Date: Thu, 10 Dec 2020 09:26:38 -0800 Subject: [PATCH 1/5] fix: Improve v2 packaging --- scripts/influxdb.service | 2 +- scripts/influxdb2-upgrade.sh | 38 ++++++++++++++++++++ scripts/post-install.sh | 68 +++++++++++++++++++++++------------- 3 files changed, 82 insertions(+), 26 deletions(-) create mode 100755 scripts/influxdb2-upgrade.sh 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 From f896a49ec5fc39f77044017a9e43be64aaca408f Mon Sep 17 00:00:00 2001 From: Phillip Steinbachs Date: Fri, 11 Dec 2020 15:09:42 -0800 Subject: [PATCH 2/5] fix: Improve v2 packaging --- CHANGELOG.md | 6 ++++- scripts/influxdb2-upgrade.sh | 46 +++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bad3a4ee5a..b3574c83ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,10 @@ want to use the default. 1. [20155](https://github.com/influxdata/influxdb/pull/20155): Respect the `--name` option in `influx setup` whether configs already exist or not. 1. [20155](https://github.com/influxdata/influxdb/pull/20155): Allow for 0 (infinite) values for `--retention` in `influx setup`. +### Packaging Improvements + +1. [20305](https://github.com/influxdata/influxdb/pull/20305): Set sane defaults and provide upgrade helper scripts + ## v2.0.2 [2020-11-19] ### Features @@ -117,7 +121,7 @@ want to use the default. 1. [19819](https://github.com/influxdata/influxdb/pull/19819): Isolate telegraf config service and remove URM interactions 1. [19853](https://github.com/influxdata/influxdb/pull/19853): Use updated HTTP client for authorization service 1. [19856](https://github.com/influxdata/influxdb/pull/19856): Make tagKeys and tagValues work for edge cases involving fields -1. [19870](https://github.com/influxdata/influxdb/pull/19870): Correctly parse float as 64-bits +1. [19870](https://github.com/influxdata/influxdb/pull/19870): Correctly parse float as 64-bits 1. [19873](https://github.com/influxdata/influxdb/pull/19873): Add simple metrics related to installed templates 1. [19885](https://github.com/influxdata/influxdb/pull/19885): Remove extra multiplication of retention policies in onboarding 1. [19887](https://github.com/influxdata/influxdb/pull/19887): Use fluxinit package to init flux library instead of builtin diff --git a/scripts/influxdb2-upgrade.sh b/scripts/influxdb2-upgrade.sh index a7fe519b7a..784434033a 100755 --- a/scripts/influxdb2-upgrade.sh +++ b/scripts/influxdb2-upgrade.sh @@ -21,18 +21,62 @@ done # Perform upgrade sudo /usr/bin/influxd upgrade \ --config-file=/etc/influxdb/influxdb.conf \ + --log-path=/var/log/influxdb/upgrade.log \ + --continuous-query-export-path=/var/lib/influxdb/continuous_queries.txt \ --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 + +A complete copy of v1 data was created as part of the upgrade process. +After confirming v2 is functioning as intended, removal of v1 data can be +performed by executing: + +sudo /var/tmp/influxdbv1-remove.sh + +NOTE: This script will erase all previous v1 data and config files! + EOF -fi + +cat << EOF > /var/tmp/influxdbv1-remove.sh +#!/bin/bash +sudo rm /etc/influxdb/influxdb.conf +sudo rm -rf /var/lib/influxdb/data +sudo rm -rf /var/lib/influxdb/wal +sudo rm -rf /var/lib/influxdb/meta +EOF +sudo chmod +x /var/tmp/influxdbv1-remove.sh 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 + +else + +cat << EOF + +The upgrade encountered an error. Please review the +/var/log/influxdb/upgrade.log file for more information. Before attempting +another upgrade, removal of v2 data should be performed by executing: + +sudo /var/tmp/influxdbv2-remove.sh + +NOTE: This script will erase all previous v2 data and config files! + +EOF + +cat << EOF > /var/tmp/influxdbv2-remove.sh +#!/bin/bash +sudo rm /etc/influxdb/config.toml /var/lib/influxdb/influxd.bolt +sudo rm /var/lib/influxdb/configs /root/.influxdbv2/configs +sudo rm -rf /var/lib/influxdb/engine +EOF +sudo chmod +x /var/tmp/influxdbv2-remove.sh + +fi From e7e90e20ece6b460870265c4419190355caf62d2 Mon Sep 17 00:00:00 2001 From: Phillip Steinbachs Date: Mon, 14 Dec 2020 13:31:00 -0800 Subject: [PATCH 3/5] fix: Improve v2 packaging --- scripts/influxdb2-upgrade.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/influxdb2-upgrade.sh b/scripts/influxdb2-upgrade.sh index 784434033a..adf6210aea 100755 --- a/scripts/influxdb2-upgrade.sh +++ b/scripts/influxdb2-upgrade.sh @@ -73,8 +73,9 @@ EOF cat << EOF > /var/tmp/influxdbv2-remove.sh #!/bin/bash -sudo rm /etc/influxdb/config.toml /var/lib/influxdb/influxd.bolt -sudo rm /var/lib/influxdb/configs /root/.influxdbv2/configs +sudo rm -f /etc/influxdb/config.toml /var/lib/influxdb/influxd.bolt +sudo rm -f /var/lib/influxdb/configs /root/.influxdbv2/configs +sudo rm -f /var/lib/influxdb/continuous_queries.txt sudo rm -rf /var/lib/influxdb/engine EOF sudo chmod +x /var/tmp/influxdbv2-remove.sh From be1e7a429b2bd9887512982bed91c9e18041edfd Mon Sep 17 00:00:00 2001 From: Phillip Steinbachs Date: Mon, 14 Dec 2020 13:52:51 -0800 Subject: [PATCH 4/5] fix: Improve v2 packaging --- CHANGELOG.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3574c83ae..3e2e5a995b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ This release includes our initial ARM64 "preview" build. ### Breaking Changes +#### influxd upgrade Previously, `influxd upgrade` would attempt to write upgraded `config.toml` files into the same directory as the source `influxdb.conf` file. If this failed, a warning would be logged and `config.toml` would be written into the `HOME` directory. @@ -16,6 +17,11 @@ This release breaks this behavior in two ways: Users can use the new `--v2-config-path` option to override the output path for upgraded config if they can't or don't want to use the default. +#### v2 packaging +Based on community feedback, the v2 deb and rpm packaging has been improved to avoid confusion between versions. The package +name is now influxdb2 and conflicts with any previous influxdb package (including initial 2.0.0, 2.0.1, and 2.0.2 packages). +Additionally, v2 specific path defaults are now defined and helper scripts are provided for `influxd upgrade` and cleanup cases. + ### Features 1. [20123](https://github.com/influxdata/influxdb/pull/20123): Allow password to be specified as a CLI option in `influx v1 auth create`. @@ -36,10 +42,7 @@ want to use the default. 1. [20201](https://github.com/influxdata/influxdb/pull/20201): Optimize shard lookup in groups containing only one shard. Thanks @StoneYunZhao! 1. [20155](https://github.com/influxdata/influxdb/pull/20155): Respect the `--name` option in `influx setup` whether configs already exist or not. 1. [20155](https://github.com/influxdata/influxdb/pull/20155): Allow for 0 (infinite) values for `--retention` in `influx setup`. - -### Packaging Improvements - -1. [20305](https://github.com/influxdata/influxdb/pull/20305): Set sane defaults and provide upgrade helper scripts +1. [20305](https://github.com/influxdata/influxdb/pull/20305): Set v2 default paths and provide upgrade helper scripts in release packages ## v2.0.2 [2020-11-19] From e67de6938299f3bee46ad2dd1d90122cb680ad6e Mon Sep 17 00:00:00 2001 From: Phillip Steinbachs Date: Mon, 14 Dec 2020 14:26:50 -0800 Subject: [PATCH 5/5] fix: Improve v2 packaging --- scripts/influxdb2-upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/influxdb2-upgrade.sh b/scripts/influxdb2-upgrade.sh index adf6210aea..0eb639ab5c 100755 --- a/scripts/influxdb2-upgrade.sh +++ b/scripts/influxdb2-upgrade.sh @@ -46,7 +46,7 @@ EOF cat << EOF > /var/tmp/influxdbv1-remove.sh #!/bin/bash -sudo rm /etc/influxdb/influxdb.conf +sudo rm -f /etc/influxdb/influxdb.conf sudo rm -rf /var/lib/influxdb/data sudo rm -rf /var/lib/influxdb/wal sudo rm -rf /var/lib/influxdb/meta