@lottie
To install and run Elasticsearch in Vagrant, follow these steps:
- Create a Vagrantfile in your project directory by running the following command in your terminal:
- Update the Vagrantfile to include the following configuration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
Vagrant.configure("2") do |config|
config.vm.box = "bento/centos-7"
config.vm.network "forwarded_port", guest: 9200, host: 9200
config.vm.provision "shell", inline: <<-SHELL
sudo yum update -y
sudo yum install java-1.8.0-openjdk -y
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
sudo rpm --checksig https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.14.1-x86_64.rpm
sudo rpm -ivh https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.14.1-x86_64.rpm
sudo systemctl enable elasticsearch
sudo systemctl start elasticsearch
SHELL
end
|
- Run the following command to start the Vagrant VM:
- SSH into the VM by running:
- Once inside the VM, you can verify that Elasticsearch is running by checking its status:
1
|
sudo systemctl status elasticsearch
|
- You can access Elasticsearch on your host machine by opening a web browser and navigating to http://localhost:9200.
That's it! You have now successfully installed and run Elasticsearch in a Vagrant VM.