ElasticSearch is a powerful and fast search engine that can be used to process large amounts of data. In this article, we will look at how to set up authorization in ElasticSearch on an Ubuntu server.
Java must be installed before installing ElasticSearch. To do this, run the following commands:
sudo apt update
sudo apt install default jdk
After Java is installed, you can start installing ElasticSearch. To do this, run the following commands:
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/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
sudo apt update
sudo apt install elasticsearch
To set up authorization in ElasticSearch, you need to create users and assign them the appropriate roles. To create a user, run the following command:
sudo /usr/share/elasticsearch/bin/elasticsearch-users useradd -p -r
Replace
To set up roles, follow these steps:
Open the ElasticSearch configuration file:
sudo nano /etc/elasticsearch/elasticsearch.yml
Add the following lines to the file:
xpack.security.enabled: true
xpack.security.authc:
realms:
native:
native1:
order: 0
Create a roles.yml file:
sudo nano /etc/elasticsearch/roles.yml
Add the roles and their permissions to the file. For example:
read_only:
cluster:
- 'monitor'
indices:
- names: '*'
privileges:
- 'read'
- 'view_index_metadata'
After setting authorization, you need to restart ElasticSearch:
sudo systemctl restart elasticsearch
In this article, we looked at how to set up authorization in ElasticSearch on an Ubuntu server. This will protect your search engine and prevent unauthorized access to your data.
menuclose
Спасибо! Заявка отправлена. Свяжемся с вами в течении часа!