Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Downgrading Elastic Search from 7 to 6?

I am trying to downgrade Elastic Search from 7 to 6 as the application I am using only works on 6.

When I install 6 I get boosted to 7 for some reason:

{
  "name" : "activecollab-v6",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "D7qs_zqTTX6Rv8AiE_ioqw",
  "version" : {
    "number" : "7.1.0",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "606a173",
    "build_date" : "2019-05-16T00:43:15.323135Z",
    "build_snapshot" : false,
    "lucene_version" : "8.0.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

How do I ensure I am downgraded? The following is my install recipe and below that is the recipe report which shows that elastic search is installed too.

# Install Elastic Search

echo ">> Installing Elastic GPG Key"
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

echo ">> Install apt-transport-https"
apt install apt-transport-https

echo ">> Adding deb package"
echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list

echo ">> Updating apt"
apt update

echo ">> Installing Java and Elastic Search"
apt -y install default-jre elasticsearch

echo ">> Java Installed"
echo ">> Elastic Search Installed"

echo ">> Scheduling Elasticsearch"
/bin/systemctl daemon-reload
/bin/systemctl enable elasticsearch.service

echo ">> Starting Elasticsearch"
systemctl start elasticsearch.service

echo ">> Running on port 9200. Make sure to add a firewall rule if you need external access."
echo ">> You can check the status by running 'curl 'http://localhost:9200'. Note: may take a few seconds before elasticsearch is fully started."

Recipe Report

>> Installing Elastic GPG Key
Warning: apt-key output should not be parsed (stdout is not a terminal)
OK
>> Install apt-transport-https

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
apt-transport-https is already the newest version (1.6.10).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
>> Adding deb package
deb https://artifacts.elastic.co/packages/6.x/apt stable main
>> Updating apt

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Get:1 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu bionic InRelease [15.4 kB]
Get:2 http://mirrors.digitalocean.com/ubuntu bionic InRelease [242 kB]
Get:3 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
Get:5 http://ppa.launchpad.net/nginx/development/ubuntu bionic InRelease [15.4 kB]
Get:6 http://ppa.launchpad.net/ondrej/apache2/ubuntu bionic InRelease [20.7 kB]
Get:7 http://ppa.launchpad.net/ondrej/php/ubuntu bionic InRelease [20.8 kB]
Get:8 http://ppa.launchpad.net/webupd8team/java/ubuntu bionic InRelease [15.4 kB]
Get:9 https://deb.nodesource.com/node_10.x bionic InRelease [4584 B]
Hit:10 https://repos.sonar.digitalocean.com/apt main InRelease
Get:11 http://mirrors.digitalocean.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:12 http://mirrors.digitalocean.com/ubuntu bionic-backports InRelease [74.6 kB]
Ign:13 https://artifacts.elastic.co/packages/6.x/apt stable InRelease
Get:14 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu bionic/main amd64 Packages [1004 B]
Get:15 http://ppa.launchpad.net/chris-lea/redis-server/ubuntu bionic/main Translation-en [584 B]
Ign:16 https://artifacts.elastic.co/packages/7.x/apt stable InRelease
Get:17 https://artifacts.elastic.co/packages/6.x/apt stable Release [5116 B]
Get:18 https://artifacts.elastic.co/packages/7.x/apt stable Release [5116 B]
Get:19 https://artifacts.elastic.co/packages/6.x/apt stable Release.gpg [473 B]
Get:20 https://artifacts.elastic.co/packages/7.x/apt stable Release.gpg [473 B]
Get:21 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [349 kB]
Get:22 http://security.ubuntu.com/ubuntu bionic-security/main Translation-en [125 kB]
Get:23 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [4296 B]
Get:24 http://security.ubuntu.com/ubuntu bionic-security/restricted Translation-en [2192 B]
Get:25 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [245 kB]
Get:26 http://security.ubuntu.com/ubuntu bionic-security/universe Translation-en [140 kB]
Get:27 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [4004 B]
Get:28 http://security.ubuntu.com/ubuntu bionic-security/multiverse Translation-en [2060 B]
Get:29 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [8570 kB]
Get:30 http://archive.ubuntu.com/ubuntu bionic/universe Translation-en [4941 kB]
Get:31 http://ppa.launchpad.net/nginx/development/ubuntu bionic/main amd64 Packages [4264 B]
Get:32 http://ppa.launchpad.net/nginx/development/ubuntu bionic/main Translation-en [4328 B]
Get:33 http://ppa.launchpad.net/ondrej/apache2/ubuntu bionic/main amd64 Packages [8528 B]
Get:34 http://ppa.launchpad.net/ondrej/apache2/ubuntu bionic/main Translation-en [4052 B]
Get:35 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 Packages [45.1 kB]
Get:36 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main Translation-en [22.1 kB]
Get:37 http://mirrors.digitalocean.com/ubuntu bionic/main amd64 Packages [1019 kB]
Get:38 http://mirrors.digitalocean.com/ubuntu bionic/main Translation-en [516 kB]
Get:39 http://mirrors.digitalocean.com/ubuntu bionic/restricted amd64 Packages [9184 B]
Get:40 http://mirrors.digitalocean.com/ubuntu bionic/restricted Translation-en [3584 B]
Get:41 http://mirrors.digitalocean.com/ubuntu bionic/universe amd64 Packages [8570 kB]
Get:42 https://deb.nodesource.com/node_10.x bionic/main amd64 Packages [767 B]
Get:43 http://mirrors.digitalocean.com/ubuntu bionic/universe Translation-en [4941 kB]
Get:44 http://mirrors.digitalocean.com/ubuntu bionic/multiverse amd64 Packages [151 kB]
Get:45 http://mirrors.digitalocean.com/ubuntu bionic/multiverse Translation-en [108 kB]
Get:46 http://mirrors.digitalocean.com/ubuntu bionic-updates/main amd64 Packages [618 kB]
Get:47 http://mirrors.digitalocean.com/ubuntu bionic-updates/main Translation-en [229 kB]
Get:48 http://mirrors.digitalocean.com/ubuntu bionic-updates/restricted amd64 Packages [6996 B]
Get:49 http://mirrors.digitalocean.com/ubuntu bionic-updates/restricted Translation-en [3076 B]
Get:50 http://mirrors.digitalocean.com/ubuntu bionic-updates/universe amd64 Packages [937 kB]
Get:51 http://mirrors.digitalocean.com/ubuntu bionic-updates/universe Translation-en [274 kB]
Get:52 http://mirrors.digitalocean.com/ubuntu bionic-updates/multiverse amd64 Packages [6644 B]
Get:53 http://mirrors.digitalocean.com/ubuntu bionic-updates/multiverse Translation-en [3556 B]
Get:54 http://mirrors.digitalocean.com/ubuntu bionic-backports/main amd64 Packages [1024 B]
Get:55 http://mirrors.digitalocean.com/ubuntu bionic-backports/main Translation-en [448 B]
Get:56 http://mirrors.digitalocean.com/ubuntu bionic-backports/universe amd64 Packages [3496 B]
Get:57 http://mirrors.digitalocean.com/ubuntu bionic-backports/universe Translation-en [1604 B]
Get:58 https://artifacts.elastic.co/packages/6.x/apt stable/main amd64 Packages [49.1 kB]
Get:59 https://artifacts.elastic.co/packages/7.x/apt stable/main amd64 Packages [6534 B]
Fetched 32.8 MB in 8s (4196 kB/s)
Reading package lists...
Building dependency tree...
Reading state information...
7 packages can be upgraded. Run 'apt list --upgradable' to see them.
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:2
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:2
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:2
W: Target CNF (main/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:2
W: Target CNF (main/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:2
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:3
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:3
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:3
W: Target CNF (main/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:3
W: Target CNF (main/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:3
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:4
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:4
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:4
W: Target CNF (main/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:4
W: Target CNF (main/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:4
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:2
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:2
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:2
W: Target CNF (main/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:2
W: Target CNF (main/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:2
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:3
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:3
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:3
W: Target CNF (main/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:3
W: Target CNF (main/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:3
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:4
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:4
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:4
W: Target CNF (main/cnf/Commands-amd64) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:4
W: Target CNF (main/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list.d/elastic-6.x.list:1 and /etc/apt/sources.list.d/elastic-6.x.list:4
>> Installing Java and Elastic Search

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
default-jre is already the newest version (2:1.11-68ubuntu1~18.04.1).
The following NEW packages will be installed:
  elasticsearch
0 upgraded, 1 newly installed, 0 to remove and 7 not upgraded.
Need to get 347 MB of archives.
After this operation, 572 MB of additional disk space will be used.
Get:1 https://artifacts.elastic.co/packages/7.x/apt stable/main amd64 elasticsearch amd64 7.1.0 [347 MB]
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin: 
Fetched 347 MB in 6s (57.1 MB/s)
Selecting previously unselected package elasticsearch.
(Reading database ... 
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 91269 files and directories currently installed.)
Preparing to unpack .../elasticsearch_7.1.0_amd64.deb ...
Creating elasticsearch group... OK
Creating elasticsearch user... OK
Unpacking elasticsearch (7.1.0) ...
Processing triggers for ureadahead (0.100.0-21) ...
Setting up elasticsearch (7.1.0) ...
Created elasticsearch keystore in /etc/elasticsearch
Processing triggers for systemd (237-3ubuntu10.21) ...
Processing triggers for ureadahead (0.100.0-21) ...
>> Java Installed
>> Elastic Search Installed
>> Scheduling Elasticsearch
Synchronizing state of elasticsearch.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable elasticsearch
Created symlink /etc/systemd/system/multi-user.target.wants/elasticsearch.service → /usr/lib/systemd/system/elasticsearch.service.
>> Starting Elasticsearch
>> Running on port 9200. Make sure to add a firewall rule if you need external access.
>> You can check the status by running 'curl 'http://localhost:9200'. Note: may take a few seconds before elasticsearch is fully started.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
like image 884
Dan Lee Avatar asked Jan 26 '23 06:01

Dan Lee


2 Answers

  1. There is no downgrade. Purge the install and start over.
  2. The DEB repository looks correct. Have you always had it like that? Because this cannot get you version 7.x.

Update:

I can see the line Get:59 https://artifacts.elastic.co/packages/7.x/apt stable/main amd64 Packages [6534 B] in your output, so you have added both the 6.x and the 7.x repository. Remove the 7.x repo (/etc/apt/sources.list.d/elastic-7.x.list), purge, and install again.

Alternatively you could purge elasticsearch and specify the version to install: sudo apt-get install elasticsearch=6.8.0. I think this is the version number you could pick, but you can verify what is available with apt-cache policy elasticsearch.

like image 157
xeraa Avatar answered Jan 28 '23 19:01

xeraa


I was in the same position to downgrade the elasticsearch from 7 to 6 without losing the data. The easy trick I did was, removed the existing elasticsearch, and installed a new one. It worked for me. I would like to give you steps to downgrade. I was using ubuntu server. Hence,

  1. Stop the running server. sudo service elasticsearch stop
  2. Remove the elasticsearch: sudo apt-get remove elasticsearch
  3. Install the elasticsearch version 6.x

Installation reference link: Install elasticsearch in ubuntu

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list
sudo apt-get update && sudo apt-get install elasticsearch

Elasticsearch may start automatically. You can check the status: sudo service elasticsearch status. If it says failed then you can restart it with: sudo service elasticsearch restart or sudo systemctl restart elasticsearch. It should restart the elasticsearch server.

Done.

Warning!

I can't guarantee that the data will be there. Hence, make sure to backup your data before doing this step. Yes, it is true that I didn't lose my data.

like image 41
Yubaraj Avatar answered Jan 28 '23 19:01

Yubaraj