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
< DEFAULT=/etc/default/$NAME --- > DEFAULT=/etc/default/$NEWNAME
< PID_FILE=/var/run/$NAME.pid --- > PID_FILE=/var/run/$NEWNAME.pid
# diff /etc/default/elasticsearch /etc/default/elasticsearch2
< LOG_DIR=/var/log/elasticsearch/elastic1 --- > LOG_DIR=/var/log/elasticsearch/elastic2
< DATA_DIR=/home/elasticsearch/elastic1 --- > DATA_DIR=/home/elasticsearch/elastic2
< WORK_DIR=/tmp/elasticsearch/elastic1 --- > WORK_DIR=/tmp/elasticsearch/elastic2
< CONF_FILE=/etc/elasticsearch/elasticsearch.yml --- > CONF_FILE=/etc/elasticsearch/elasticsearch2.yml
# diff /etc/elasticsearch/elasticsearch.yml /etc/elasticsearch/elasticsearch2.yml
< node.name: "db1" --- > node.name: "db1-2"
Easy enough. It seems to work just fine