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
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
sudo rm /usr/libexec/java_home
sudo ln -s /usr/lib/jvm/java-8-openjdk-amd64 /usr/libexec/java_home
(Important)
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)
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
...