Configuring Misc Zoning in OpenSearch

End-to-end configuration of a Misc zone node: nomad job, YAML, Consul keys, firewall, and startup.

4 min read Updated SS

Follow the steps to configure misc zoning in an OpenSearch deployment:

1. Create the Nomad file for OpenSearch Misc Node 1.

For example:

job "opensearch-misc-node1" {
region = "India"
datacenters = ["dc1"]
group "opensearch-misc-node1" {
network {
port "opensearch_data_port" {
static = "9212"
to = 9212
}
port "opensearch_transport_port" {
static = "9312"
to = 9312
}
}
task "opensearch-misc-node1" {
driver = "docker"
constraint {
attribute = "${attr.unique.network.ip-address}"
value = "198.51.100.5"
}
template {
data=<<EOH
OPENSEARCH_USER_ID="{{ key "service/users/userid" }}"
OPENSEARCH_GROUP_ID="{{ key "service/users/groupid" }}"
MEMORY_PERCENTAGE="{{key "service/opensearch/memorypercentage"}}"
#TZ="{{ key "service/heal/timezone" }}"
EOH
destination = "local/file.env"
env = true
}
template {
source = "/opt/Heal/Appsone_Service/opensearch/config/opensearch-misc-node1.yml.tpl"
destination = "local/opensearch.yml"
change_mode = "restart"
}
template {
source = "/opt/Heal/Appsone_Service/opensearch/config/log4j2.properties.tpl"
destination = "local/log4j2.properties"
change_mode = "restart"
}
config {
image = "registry.example:8091/opensearch:1.3.14"
network_mode="host"
cap_add = [ "all" ]
volumes = [
"/opt/Heal/Appsone_Service/opensearch/data-misc:/usr/share/opensearch/data",
"/opt/Heal/Appsone_Service/opensearch/config-misc:/usr/share/opensearch/config",
"/opt/Heal/Appsone_Service/data/cert/opensearch.key:/usr/share/opensearch/config/opensearch.
key",
"/opt/Heal/Appsone_Service/data/cert/opensearch.crt:/usr/share/opensearch/config/opensearch.c
rt",
"/opt/Heal/Appsone_Service/data/cert/appnomic-
rootca.crt:/usr/share/opensearch/config/appnomic-rootca.crt",
"local/opensearch.yml:/usr/share/opensearch/config/opensearch.yml",
"local/log4j2.properties:/usr/share/opensearch/config/log4j2.properties",
"/opt/Heal/Appsone_Service/data/cert/cacerts:/usr/share/opensearch/jdk/lib/security/cacerts",
"/opt/Heal/centralized_logs/opensearch-misc-node1:/usr/share/opensearch/logs"
]
ports = [ "opensearch_data_port", "opensearch_transport_port" ]
}
resources {
cpu = 1500
memory = 2048
}
service {
name = "opensearch-misc-node1"
tags = ["opensearch-misc-node1"]
port = "opensearch_data_port"
check {
type = "tcp"
port = "opensearch_data_port"
interval = "60s"
timeout = "5s"
initial_status = "passing"
check_restart {
limit = 10
grace = "90s"
ignore_warnings = false
}
}
}
}
}
}

a. For Node 2 and Node 3 nomad files, replace all Node 1-specific values with the corresponding values for Node 2 and Node 3, respectively.

2. Create the corresponding YAML configuration file for Misc Node 1.

For example:

cluster.name: Heal-OpenSearch-<cluster name>
node.name: opensearch-misc-node1
discovery.seed_hosts: [ {{key "service/opensearch/nodesarray"}} ]
cluster.initial_master_nodes: [ {{key "service/opensearch/master/nodesarray"}} ]
http.port: {{ key "service/opensearch/port/misc/http" }}
transport.port: {{ key "service/opensearch/port/misc/transport" }}
# Bind to all interfaces because we don't know what IP address Docker will assign to us.
network.host: 0.0.0.0
network.publish_host : {{ key "service/opensearch/node1/ip" }}
# # minimum_master_nodes need to be explicitly set when bound on a public IP
# # set to 1 to allow single node clusters
# discovery.zen.minimum_master_nodes: 1
# Setting network.host to a non-loopback address enables the annoying bootstrap checks. "Single-
node" mode disables them again.
#discovery.type: single-node
######## Start OpenSearch Security Demo Configuration ########
# WARNING: revise all the lines below before you go into production
plugins.security.ssl.transport.pemcert_filepath: opensearch.crt
plugins.security.ssl.transport.pemkey_filepath: opensearch.key
plugins.security.ssl.transport.pemtrustedcas_filepath: appnomic-rootca.crt
plugins.security.ssl.transport.enforce_hostname_verification: false
plugins.security.ssl.http.enabled: true
plugins.security.disabled: false
plugins.security.ssl.http.pemcert_filepath: opensearch.crt
plugins.security.ssl.http.pemkey_filepath: opensearch.key
plugins.security.ssl.http.pemtrustedcas_filepath: appnomic-rootca.crt
plugins.security.allow_unsafe_democertificates: true
plugins.security.allow_default_init_securityindex: true
plugins.security.authcz.admin_dn:
- "CN=*.example,OU=Engg,O=Appnomic,L=Bangalore,ST=Karnataka,C=IN"
plugins.security.nodes_dn:
- "CN=*.example,OU=Engg,O=Appnomic,L=Bangalore,ST=Karnataka,C=IN"
#plugins.security.audit.type: internal_opensearch
plugins.security.enable_snapshot_restore_privilege: true
plugins.security.check_snapshot_restore_write_privileges: true
plugins.security.restapi.roles_enabled: ["all_access", "security_rest_api_access"]
plugins.security.system_indices.enabled: true
plugins.security.system_indices.indices: [".opendistro-alerting-config", ".opendistro-alerting-alert*",
".opendistro-anomaly-results*", ".opendistro-anomaly-detector*", ".opendistro-anomaly-
checkpoints", ".opendistro-anomaly-detection-state", ".opendistro-reports-*", ".opendistro-
notifications-*", ".opendistro-notebooks", ".opendistro-asynchronous-search-response*"]
node.max_local_storage_nodes: 1
compatibility.override_main_response_version: true
######## End OpenSearch Security Demo Configuration ########
node.ingest: true
node.master: false
node.data: true
node.attr.zone: heal-misc
node.remote_cluster_client: true
######## Added this value for opensearch snapshot ########
path.repo: ["/usr/share/opensearch/opensearchsnapshot"]
plugins.security.ssl.http.enabled_ciphers:
- "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"
- "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
- "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384"
- "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"
- "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256"
plugins.security.ssl.http.enabled_protocols:
- "TLSv1.2"
plugins.security.ssl.transport.enabled_ciphers:
- "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"
- "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
- "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384"
- "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"
- "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256"
plugins.security.ssl.transport.enabled_protocols:
- "TLSv1.2"

a. For the Node 2 and Node 3 YAML configuration files, replace all Node 1-specific values with the corresponding values for Node 2 and Node 3, respectively.

3. If the OpenSearch deployment is configured for High Availability (HA):

a. Create two additional Nomad and YAML files for Node 2 and Node 3.

b. Copy the created YAML files to the following directory on all nodes:

<a1home>/Appsone_Service/opensearch/config

4. Update the file permissions so they match the permissions of existing OpenSearch configuration files.

5. Update Consul Keys.

a. Add the misc node’s IP address and its transport port to the Consul key:

service/opensearch/nodesarray

For example:

service/opensearch/nodesarray
"192.0.2.24:9310","192.0.2.24:9311","192.0.2.24:9300","192.0.2.24:9350","191.166.
15.30:9325",
"192.0.2.25:9310","192.0.2.25:9311","192.0.2.25:9300","192.0.2.25:9350","191.166.
15.31:9325",
"192.0.2.26:9310","192.0.2.26:9311","192.0.2.26:9300","192.0.2.26:9350","191.166.
15.32:9325"

b. If the cluster has 3 OpenSearch nodes:

consul kv put service/opensearch/nodesarray \
"$(consul kv get
service/opensearch/nodesarray),\"192.0.2.24:9312\",\"192.0.2.25:9312\",\"203.0.113.5:9
312\""

c. If the cluster has a single OpenSearch node:

consul kv put service/opensearch/nodesarray \
"$(consul kv get service/opensearch/nodesarray),\"192.0.2.27:9311\""

d. Set the HTTP port for the Misc Node:

consul kv put service/opensearch/port/misc/http 9212

e. Set the transport port for the Misc Node:

consul kv put service/opensearch/port/misc/transport 9312

6. Ensure the following firewall ports are open:

  • 9212 (HTTP data port): Bidirectional access for App and DB servers.
  • 9312 (Transport port): Bidirectional access for DB-to-DB node communication.

7. Add rules for ports 9212 and 9312 in the firewall configuration.

8. Create the configuration and data directories for misc nodes in the path below:

<a1home>/Appsone_Service/opensearch/

a. For config-misc folder:

mkdir config-misc

b. For data-misc folder:

mkdir data-misc

c. Ensure these directories match the ownership and permissions of other OpenSearch config and data directories.

9. Copy the following from the config-kpi directory to the config-misc directory:

  • Certificates
  • jvm.options

10. Stop all OpenSearch nodes before applying zoning updates.

./stopService.sh OPENSEARCH

11. Update the values for required zoning keys as below:

consul kv put service/opensearch/zoning/enabled yes
consul kv put service/opensearch/templateloadStatus false

12. Start OpenSearch Services by executing the following command:

./startServices.sh OPENSEARCH

13. After all nodes have started, validate that the following criteria are met:

  • Verify cluster health.
  • Confirm that Misc Zone nodes are added to the cluster.
  • Ensure the Misc Zoning Template is loaded:
_template/heal_misc_zoning_template