2014-10-02 110 views
5

我有一台运行Ubuntu 14.04的服务器,其中有220 GB的ram,我希望运行elasticsearch。根据文档,一个节点不应该有超过32 GB的RAM,所以我想我必须在这台机器上运行几个节点才能使用所有的RAM。我正在考虑运行4个节点,每个节点有28 GB的内存。在一台Ubuntu服务器上运行多个elasticsearch节点作为服务

如何将其设置为Ubuntu服务,以便所有节点在系统重启后自动恢复,例如?我想我必须以某种方式编辑/etc/init.d/elasticsearch - 任何人都可以帮我解决吗?

谢谢你们这么多!

+0

可能我建议运行N(4?)虚拟机并将它们设置为节点?例如,你可以制造10台20Gb的机器,我不确定你是否受到内存或CPU的瓶颈。 – 2014-10-02 15:12:29

+0

感谢您的想法!然而,我不确定我是否不会因虚拟机设置的开销而损失太多计算能力和存储容量......服务器有8个1TB SSD设置为RAID 10,并且愿意充分利用那太... – user167172 2014-10-02 16:31:27

回答

3

我放弃了一段时间后,取消了elasticsearch repo-installation并下载了zip文件。然后,我创造了两个新贵,迄今为止所有事情都顺利进行。

  1. 包装

    description "Start several ES-instances at once (this is a wrapper)." 

    start on (local-filesystems and net-device-up IFACE!=lo) 
    stop on runlevel [06] 
    respawn 

    # Give up respawn if restart occurs 5 times in 120 seconds 
    respawn limit 5 120 

    env NUM_INSTANCES=4 

    pre-start script 
     for i in $(seq 1 $NUM_INSTANCES) 
     do 
      start elasticsearch-instance ID=$i 
     done 
    end script 

    pre-stop script 
     curl -XPOST "http://localhost:9200/_cluster/nodes/_local/_shutdown" 
    end script 

  • 实例
  • 
        description "starts up an elasticsearch instance (node)" 
    
        stop on stopping elasticsearch 
        respawn 
    
        instance $ID 
    
        limit nofile 64000 64000 
    
        setuid elasticsearch 
        setgid elasticsearch 
    
        env JAVA_OPTS="-XX:+UseCompressedOops" 
        env ES_HEAP_SIZE=28G 
        exec /data/elasticsearch/bin/elasticsearch -Des.config=/data/elasticsearch/config/elasticsearch.yml 
    
    +1

    我想你应该也看看设置cluster.routing.allocation.same_shard.host。 http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/heap-sizing.html#compressed_oops – slawek 2015-01-16 10:37:31

    2

    假设你的rpm或DEB创建的init.d脚本,在同一台机器上启动第二个节点,操作如下:

    cd /etc/init.d 
    cp --preserve elasticsearch elasticsearch2 
    

    编辑elasticsearch2脚本:

    1. 变化#elasticsearch至#elasticsearch2
    2. 添加节点= “2” 后线PROG = “elasticsearch”
    3. 变化了pidfile =的/ var /运行/ elasticsearch/$ {prog} .pid到pidfile =/var/run/elasticsearch/$ {prog} $ {node} .pid
    4. change lockfile =/var/lock/subsys/$ prog to lockfile =/var/lock/subsys/$ prog $ node
    5. change echo -n $“Starting $ prog:”to echo -n $“Starting $ prog:(node $ node)”
    6. change echo -n $“Stopping $ prog:”to echo -n $“Stopping $ prog:(node $ node)“

    保存文件。执行

    chkconfig --add elasticsearch2 
    service elasticsearch2 start 
    
    +1

    我还必须添加-Des.config = <路径到第二个配置文件>到让它工作 – JBernhardt 2015-06-24 15:46:27

    相关问题