# Can I install ELastic Search twice as a windows service?

**URL:** <https://discuss.elastic.co/t/can-i-install-elastic-search-twice-as-a-windows-service/280022>\
**Category:** Elasticsearch\
**Created:** [July 30, 2021, 2:22am UTC](https://discuss.elastic.co/t/can-i-install-elastic-search-twice-as-a-windows-service/280022 "2021-07-30T02:22:19Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhare](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mhare/32/52213_2.png) [@mhare](https://discuss.elastic.co/u/mhare)\
**Post date:** [July 30, 2021, 2:22am UTC](https://discuss.elastic.co/t/can-i-install-elastic-search-twice-as-a-windows-service/280022/1 "2021-07-30T02:22:19Z")

</div>

For reasons that may be uninteresting to many, I find myself needing to run two instances of ElasticSearch on the same Windows machine. I have unzipped the 7.13.4 archive into two separate directories and set them up and they run just fine as BAT files. However, when I install them as Windows services using NSSM (with unique names), they install but once I run the second one the first one pauses, then the second one pauses.  
I am not a Windows guy, so the service thing is not completely understood. Any threads I can pull to figure out why they won't both run?

Thanks!

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [July 30, 2021, 3:31am UTC](https://discuss.elastic.co/t/can-i-install-elastic-search-twice-as-a-windows-service/280022/2 "2021-07-30T03:31:10Z")

</div>

What is the configuration of each one of your instance? Share the `elasticsearch.yml` of each one.

Also, what do you have in the logs when you start and when the instance stops?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 30, 2021, 5:24am UTC](https://discuss.elastic.co/t/can-i-install-elastic-search-twice-as-a-windows-service/280022/3 "2021-07-30T05:24:18Z")

</div>

> [@mhare](#):
>
> For reasons that may be uninteresting to many, I find myself needing to run two instances of Elasticsearch on the same Windows machine.

Could you share why you need this? How much RAM do you have on your machine?

---

<div class="post-metadata">

**Author:** ![mhare](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mhare/32/52213_2.png) [@mhare](https://discuss.elastic.co/u/mhare)\
**Post date:** [July 30, 2021, 12:57pm UTC](https://discuss.elastic.co/t/can-i-install-elastic-search-twice-as-a-windows-service/280022/4 "2021-07-30T12:57:39Z")

</div>

It is a legacy installation setup. The machine has 32G of ram on a XEON processor. The reason is they want an ILM policy for Hot / Warm. The Hot node is installed on the C drive (SDD) and the Warm node is installed on the D drive (spinning disk) I have explained the idea of hot/warm is not as dependent on the type of drive it is installed on, but that it is sharing the OS and processors. I suggested they run a single instance and they will get better performance but they are having none of that. So, I need to run two instances.

---

<div class="post-metadata">

**Author:** ![mhare](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mhare/32/52213_2.png) [@mhare](https://discuss.elastic.co/u/mhare)\
**Post date:** [July 30, 2021, 4:46pm UTC](https://discuss.elastic.co/t/can-i-install-elastic-search-twice-as-a-windows-service/280022/5 "2021-07-30T16:46:16Z")

</div>

My bad. 2.1 GHz Xeon, but only 16 GB Ram and it running Windows Server 2016 (64bit)

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [July 30, 2021, 4:57pm UTC](https://discuss.elastic.co/t/can-i-install-elastic-search-twice-as-a-windows-service/280022/6 "2021-07-30T16:57:37Z")

</div>

You can run multiple instances on the same server, but you need to have completely separated configurations and services, you need to share your configurations.

Anyway, with 16 GB you could use 8 GB for your instances each one with 4 GB, but I would not recommend that, and neither using a hot/warm architecture in this configuration, the performance will be better using a single instance with 8 GB of HEAP.

---

<div class="post-metadata">

**Author:** ![mhare](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mhare/32/52213_2.png) [@mhare](https://discuss.elastic.co/u/mhare)\
**Post date:** [July 30, 2021, 6:11pm UTC](https://discuss.elastic.co/t/can-i-install-elastic-search-twice-as-a-windows-service/280022/7 "2021-07-30T18:11:37Z")

</div>

### Hot Node

```auto
# -----------------------------------------------------------
#
cluster.name: my-cluster
node.name: node-hot
path.data: /ELK/data-hot
network.host: 0.0.0.0
http.port: 9200
transport.port: 9300
cluster.initial_master_nodes: ["node-hot"]
node.roles: [master, data, ingest, remote_cluster_client]
node.attr.data: "hot"

## License
xpack.license.self_generated.type: basic

# Security
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12

```

## Warm Node

```auto
# -----------------------------------------------------------
cluster.name: my-cluster
node.name: node-warm
path.data: /ELK/data-warm
network.host: 0.0.0.0
http.port: 9201
cluster.initial_master_nodes: ["node-hot"]
node.roles: [data]
node.attr.data: "warm"

## License
xpack.license.self_generated.type: basic

# Security
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12

```

---

<div class="post-metadata">

**Author:** ![mhare](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mhare/32/52213_2.png) [@mhare](https://discuss.elastic.co/u/mhare)\
**Post date:** [July 31, 2021, 12:08am UTC](https://discuss.elastic.co/t/can-i-install-elastic-search-twice-as-a-windows-service/280022/8 "2021-07-31T00:08:34Z")

</div>

When I run ES as a BAT file, I get the various logs in the 'log' directory. Once I start ES as a Windows Service, I no longer see the logs in the 'log' directory. Are they being written somewhere else?

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [July 31, 2021, 1:24am UTC](https://discuss.elastic.co/t/can-i-install-elastic-search-twice-as-a-windows-service/280022/9 "2021-07-31T01:24:57Z")

</div>

I would recommend that you follow this part of the [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/zip-windows.html#windows-service) and use the mentioned `.bat.` file to create your services and see if it works.

Also, you need to set everything in your `elasticsearch.yml` file, you are not setting the `path.logs` and your warm not are not setting the `transport.tcp` port, in this scenario if for some reason the warm node starts first it will try to bind to the port `9300` and your hot node will not be able to start as it will also try to bind to the same port.

You are also missing the `discovery.seed_hosts` config.

The first part of your hot node configuration should look like this:

```auto
cluster.name: my-cluster
node.name: node-hot
path.data: /path/to/hot-data
path.logs: /path/to/hot-logs
network.host: 0.0.0.0
http.port: 9200
transport.port: 9300
cluster.initial_master_nodes: ["node-hot"]
discovery.seed_hosts: ["hostname-of-your-node:9300"]
node.roles: [master, data, ingest, remote_cluster_client]
node.attr.data: "hot" 

```

And your warm node should have a configuration like this:

```auto
cluster.name: my-cluster
node.name: node-warm
path.data: /path/to/warm-data
path.logs: /path/to/warm-logs
network.host: 0.0.0.0
http.port: 9201
transport.port: 9301
cluster.initial_master_nodes: ["node-hot"]
discovery.seed_hosts: ["hostname-of-your-node:9300"]
node.roles: [data]
node.attr.data: "warm" 

```

You also have limited resources, you should configure the `jvm.options` of each node and set the `Xms` and `Xmx` options to no more than 4 GB for each node.

I rarely use windows, but the above configuration should help to isolate the nodes datas and logs.

---

<div class="post-metadata">

**Author:** ![mhare](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mhare/32/52213_2.png) [@mhare](https://discuss.elastic.co/u/mhare)\
**Post date:** [July 31, 2021, 12:32pm UTC](https://discuss.elastic.co/t/can-i-install-elastic-search-twice-as-a-windows-service/280022/10 "2021-07-31T12:32:06Z")

</div>

Nice! Will give that a try today. As for the discovery.seed\_hosts value, though. Since these are both running on the same machine with one ip address, is the 'hostname-of-your-node' just 'localhost' or the ip address of the machine?

---

<div class="post-metadata">

**Author:** ![mhare](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mhare/32/52213_2.png) [@mhare](https://discuss.elastic.co/u/mhare)\
**Post date:** [August 8, 2021, 3:22pm UTC](https://discuss.elastic.co/t/can-i-install-elastic-search-twice-as-a-windows-service/280022/11 "2021-08-08T15:22:00Z")

</div>

As a follow up, I was able to install ElasticSearch twice as a windows service. I did need to use the supplied scripts instead of NSSM. I’m sure NSSM can do it, but would need more configuration like environment variables to make it work. Thanks for all the help,

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 5, 2021, 3:22pm UTC](https://discuss.elastic.co/t/can-i-install-elastic-search-twice-as-a-windows-service/280022/12 "2021-09-05T15:22:38Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
