During some installation planning, I needed to get two elasticsearch nodes running on a single machine. Various reasons. I don’t think I’d ever do this in a production capacity (although I can think of a reason or two that I might want to), but essentially what I did was create separate configuration, and startup scripts for reach node.
The startup script points to a new ‘defaults’ script, and that points to a new elasticsearch.yml file.

Pretty straight forward, here are the diffs:

# diff /etc/init.d/elasticsearch /etc/init.d/elasticsearch2
23a24
> NEWNAME=elasticsearch2
25c26
< DEFAULT=/etc/default/$NAME --- > DEFAULT=/etc/default/$NEWNAME
104c105
< PID_FILE=/var/run/$NAME.pid --- > PID_FILE=/var/run/$NEWNAME.pid

# diff /etc/default/elasticsearch /etc/default/elasticsearch2
26c26
< LOG_DIR=/var/log/elasticsearch/elastic1 --- > LOG_DIR=/var/log/elasticsearch/elastic2
29c29
< DATA_DIR=/home/elasticsearch/elastic1 --- > DATA_DIR=/home/elasticsearch/elastic2
32c32
< WORK_DIR=/tmp/elasticsearch/elastic1 --- > WORK_DIR=/tmp/elasticsearch/elastic2
38c38
< CONF_FILE=/etc/elasticsearch/elasticsearch.yml --- > CONF_FILE=/etc/elasticsearch/elasticsearch2.yml

# diff /etc/elasticsearch/elasticsearch.yml /etc/elasticsearch/elasticsearch2.yml
40c40
< node.name: "db1" --- > node.name: "db1-2"

Easy enough. It seems to work just fine

Short URL: http://bit.ly/28ZmJbl