elasticsearch 单机多实例

elasticsearch 配置单机器多实例

host:
127.0.0.1:9201 - 9301 
127.0.0.1:9202 - 9302

path data:

/opt/elasticsearch/data/node1
/opt/elasticsearch/data/node2

path logs:

/opt/elasticsearch/logs/node1
/opt/elasticsearch/logs/node2

path config:

/opt/elasticsearch/config/node1
/opt/elasticsearch/config/node2

elasticsearch 配置绝对路径 :

[root@es]$ cat config/node2/elasticsearch.yml |grep -v ^#
cluster.name: test-cluster
node.name: node2
node.box_type: M
node.master: false
node.data: true
path.data: /opt/elasticsearch-2.4.2/data/node2
path.logs: /opt/elasticsearch-2.4.2/logs/node2
bootstrap.mlockall: false
network.host: 127.0.0.1
http.port: 9202
transport.tcp.port: 9302
discovery.zen.ping.unicast.hosts: ["172.0.0.1:9301","127.0.0.1:9302"]
node.max_local_storage_nodes: 2

[root@es]$ cat config/node1/elasticsearch.yml |grep -v ^#

cluster.name: test-cluster
node.name: node1
node.box_type: M
node.master: true
node.data: true
path.data: /opt/elasticsearch-2.4.2/data/node1
path.logs: /opt/elasticsearch-2.4.2/logs/node1
bootstrap.mlockall: false
network.host: 127.0.0.1
http.port: 9201
transport.tcp.port: 9301
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9301","127.0.0.1:9302"]
node.max_local_storage_nodes: 2

非root 启动:
绝对路径下:

#cd /opt/elasticsearch/
sh bin/elasticsearch -Des.path.conf=config/node1 -d
sh bin/elasticsearch -Des.path.conf=config/node2 -d

es 插件

安装head插件
./bin/plugin install mobz/elasticsearch-head
或下载离线安装
sh bin/plugin install file:/文件路径
安装hq插件 ./bin/plugin install royrusso/elasticsearch-HQ 或下载离线安装 sh bin/plugin install file:/文件路径

安装Marvel

Marvel是Elasticsearch的管理和监控工具,在开发环境下免费使用。它包含了一个叫做Sense的交互式控制台,使用户方便的通过浏览器直接与Elasticsearch进行交互。
Elasticsearch线上文档中的很多示例代码都附带一个View in Sense的链接。点击进去,就会在Sense控制台打开相应的实例。安装Marvel不是必须的,但是它可以通过在你本地Elasticsearch集群中运行示例代码而增加与此书的互动性。

Marvel是一个插件,可在Elasticsearch目录中运行以下命令来下载和安装:
./bin/plugin -i elasticsearch/marvel/latest
你可能想要禁用监控,你可以通过以下命令关闭Marvel:
echo 'marvel.agent.enabled: false' >> ./config/elasticsearch.yml

使用非管理员权限启动;

# chown -R root /opt/elasticsearch 
# su deploy -c bin/elasticsearch -d

测试:curl http://localhost:9200/

 注:

Elasticsearch 5.0 之前启动:
 ./bin/elasticsearch -Des.path.conf=/path/to/your/config

ElasticSearch 5.0.0 版本之后启动:
 .bin/elasticsearch -Epath.conf=/path/to/your/config

单机多示例 "elastic" 账户 "-d" 后台启动:
su elastic -c "sh /elasticsearch/bin/elasticsearch -Epath.conf=/elasticsearch/config/node1 -d"

 

posted @ 2017-11-20 11:38  01234567  阅读(787)  评论(0编辑  收藏  举报