Skip to content

Instantly share code, notes, and snippets.

@cyrillkuettel
Last active February 10, 2023 10:37
Show Gist options
  • Save cyrillkuettel/e340f8a36148a49efcae999bcb99049c to your computer and use it in GitHub Desktop.
Save cyrillkuettel/e340f8a36148a49efcae999bcb99049c to your computer and use it in GitHub Desktop.

Java / elasticsearch

First, remove all existing java installations:

sudo apt-get purge openjdk-\*
sudo rm -rf /usr/lib/jvm/*

Install Java 8, same version as on build server:

sudo apt-get install openjdk-8-jre-headless

Update JAVA_HOME:

sudo vim /etc/profile

Add the following two lines

export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"
export PATH=$JAVA_HOME/bin:$PATH

create symbolic link:

sudo rm /usr/libexec/java_home
sudo ln -s /usr/lib/jvm/java-8-openjdk-amd64 /usr/libexec/java_home

reboot the system.

(Important)

Ensure JAVA_HOME:

running this:

java -version

Should return:

openjdk version "1.8.0_352" OpenJDK Runtime Environment (build 1.8.0_352-8u352-ga-1~22.04-b08) OpenJDK 64-Bit Server VM (build 25.352-b08, mixed mode)

install elasticsearch

curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elastic.gpg
echo "deb [signed-by=/usr/share/keyrings/elastic.gpg] https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
sudo apt update
sudo apt install elasticsearch

Use your preferred text editor to edit Elasticsearch’s configuration file:

sudo vim /etc/elasticsearch/elasticsearch.yml

set the following:

network.host: localhost	
http.port: 9200

start elasticsearch:

sudo systemctl start elasticsearch

run the following command to enable Elasticsearch to start up every time your system boots:

sudo systemctl enable elasticsearch

Run the test

source /etc/profile # important part
pytest tests/onegov/org/test_views_search.py -k 'test_basic_search' 

For some reason, it works with source /etc/profile, but not with sourcing ~/.bashrc ...

Sources:

[1] https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-elasticsearch-on-ubuntu-22-04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment