Skip to content

How to configure openSearch cluster?

Chenqi Shan edited this page Jul 8, 2022 · 1 revision

Following are the steps to configure the OpenSearch cluster.

0. Create a user for Linux, set password and grant root privileges to the user

  • a. Add the Username
$adduser <username>
  • b. Grant Root Privileges to the User
$visudo

After the root user line, you will add in your new user with the same format for us to grant admin privileges.

$<username> ALL=(ALL:ALL)ALL

1.Download the tarball from the (OpenSearch downloads page).

$su username
$wget https://artifacts.opensearch.org/releases/bundle/opensearch/1.0.0/opensearch-1.0.0-linux-x64.tar.gz

2.Extract the TAR file to a directory

$tar -zxf opensearch-1.0.0-linux-x64.tar.gz
$cd opensearch-1.0.0

3.Set the vm.max_map_count setting

$sudo vi /etc/sysctl.conf

add this line:

vm.max_map_count=262144

run the following command to reload the new sysctl configuration:

$sudo sysctl -p

4.Edit opensearch configuration file and ensure the following are set:

$cd config/

cluster.name: my-application
node.name: node-1
path.data: /home/opensearch/data
path.logs: /home/opensearch/logs
network.host: 0.0.0.0
http.port: 8200
discovery.seed_hosts: ["host_1", "host_2","host_3"]
cluster.initial_master_nodes: ["host_1_ip","host_2_ip","host_3_ip"]

5.Install OpenSearch

$./opensearch-tar-install.sh

6.Change the access permissions of *.pem file

$cd config
$sudo chmod 400 *.pem

7.Run OpenSearch

$./bin/opensearch -d

8.Perform the same steps on other servers, change node.name, network.host and http.port. Finally, check the cluster status as following:

$https://<opensearch_ip>/_cluster/health?pretty

Return this:

{
  "cluster_name" : "my-application",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 3,
  "number_of_data_nodes" : 3,
  "discovered_master" : true,
  "active_primary_shards" : 12,
  "active_shards" : 25,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}