首先我們看看Elasticsearch的啟動(dòng)腳本:
- [root@bicloud77 bin]# ./elasticsearch --help
- Usage: ./elasticsearch [-vdh] [-p pidfile] [-D prop] [-X prop]
- Start elasticsearch.
- -d daemonize (run in background)
- -p pidfile write PID to <pidfile>
- -h
- --help print command line options
- -v print elasticsearch version, then exit
- -D prop set JAVA system property
- -X prop set non-standard JAVA system property
- --prop=val
- --prop val set elasticsearch property (i.e. -Des.<prop>=<val>)
只能后臺(tái)啟動(dòng),沒有啟動(dòng),,停止,,重啟,查看狀態(tài)等命令,,非常不方面管理,。
安裝servicewrapper我們?cè)诜?wù)器環(huán)境下可以使用elasticsearch-servicewrapper這個(gè)ES插件。下載地址是:https://github.com/elastic/elasticsearch-servicewrapper 下載完成后,,將下來的項(xiàng)目的service目錄拷貝到elasticsearch的bin目錄中,,并且設(shè)置service目錄下的elasticsearch文件的權(quán)限: 如下就是${ES_HOME}/bin/service/elasticsearch的使用說明: - [root@bicloud77 service]# ./elasticsearch --help
- Unexpected command: --help
-
- Usage: ./elasticsearch [ console | start | stop | restart | condrestart | status | install | remove | dump ]
-
- Commands:
- console Launch in the current console.#控制臺(tái)啟動(dòng)
- start Start in the background as a daemon process.#后臺(tái)啟動(dòng)
- stop Stop if running as a daemon or in another console.#停止
- restart Stop if running and then start.#重啟
- condrestart Restart only if already running.#僅僅在已經(jīng)運(yùn)行的情況下啟動(dòng)
- status Query the current status.#查看狀態(tài)
- install Install to start automatically when system boots.
- remove Uninstall.
- dump Request a Java thread dump if running.
servicewrapper配置文件
- [root@bicloud75 service]# pwd
- /home/elasticsearch-1.4.0/bin/service
- [root@bicloud75 service]# vi elasticsearch.conf
-
- set.default.ES_HOME=<Path to Elasticsearch Home>
- set.default.ES_HEAP_SIZE=2048 //因?yàn)槭菧y(cè)試機(jī)器,設(shè)置的內(nèi)存比較少,,服務(wù)器好的話,,可以設(shè)置大一些
- set.default.ES_MIN_SIZE=2048
- set.default.ES_MAX_SIZE=2048
-
- #Fish
- #JVM參數(shù)Elasticsearch默認(rèn)值Environment變量:
- #-Xms 256m ES_MIN_MEM
- #-Xmx 1g ES_MAX_MEM
- #-Xms and -Xmx ES_HEAP_SIZE
- #-Xmn ES_HEAP_NEWSIZE
- #-XX:MaxDirectMemorySize ES_DIRECT_SIZE
-
- #********************************************************************
- # Wrapper Timeout Properties
- #********************************************************************
- # How long to wait for the JVM to start (in seconds)
- wrapper.startup.timeout=300
- # How long to wait for the JVM to stop (in seconds)
- wrapper.shutdown.timeout=300
- # When a ping will timeout to consider the JVM hung (in seconds)
- wrapper.ping.timeout=300
-
- #********************************************************************
- # Wrapper Java Properties
- #********************************************************************
- # Java Application
- wrapper.java.command=java
-
- # Tell the Wrapper to log the full generated Java command line.
- #wrapper.java.command.loglevel=INFO
-
- wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
-
- wrapper.working.dir=%ES_HOME%
-
- # Java Classpath (include wrapper.jar) Add class path elements as
- # needed starting from 1
- wrapper.java.classpath.1=%ES_HOME%/bin/service/lib/wrapper.jar
- wrapper.java.classpath.2=%ES_HOME%/lib/elasticsearch*.jar
- wrapper.java.classpath.3=%ES_HOME%/lib/*.jar
- wrapper.java.classpath.4=%ES_HOME%/lib/sigar/*.jar
-
- # Java Library Path (location of Wrapper.DLL or libwrapper.so)
- wrapper.java.library.path.1=%ES_HOME%/bin/service/lib
-
- # Java Bits. On applicable platforms, tells the JVM to run in 32 or 64-bit mode.
- wrapper.java.additional.auto_bits=TRUE
-
- # Java Additional Parameters
- wrapper.java.additional.1=-Delasticsearch-service
- wrapper.java.additional.2=-Des.path.home=%ES_HOME%
- wrapper.java.additional.3=-Xss256k
- wrapper.java.additional.4=-XX:+UseParNewGC
- wrapper.java.additional.5=-XX:+UseConcMarkSweepGC
-
- # Initial Java Heap Size (in MB)
- wrapper.java.initmemory=%ES_HEAP_SIZE%
-
- # Maximum Java Heap Size (in MB)
- wrapper.java.maxmemory=%ES_HEAP_SIZE%
- ...(更多)
安裝問題總匯
[root@bicloud75 service]# sh ./elasticsearch start
: command not foundne 2:
: command not foundne 4:
: command not foundne 6:
'/elasticsearch: line 138: syntax error near unexpected token `in
'/elasticsearch: line 138: `case $0 in
或者
[root@bicloud75service]# ./elasticsearch start -bash: bin/service/elasticsearch: /bin/sh^M: bad interpreter: 沒有那個(gè)文件或目錄
在Linux中執(zhí)行.sh腳本,異常/bin/sh^M: bad interpreter: No such file or directory,。
分析:這是不同系統(tǒng)編碼格式引起的:在windows系統(tǒng)中編輯的.sh文件可能有不可見字符,,所以在Linux系統(tǒng)下執(zhí)行會(huì)報(bào)以上異常信息。
解決:1)在windows下轉(zhuǎn)換: 利用一些編輯器如UltraEdit或EditPlus等工具先將腳本編碼轉(zhuǎn)換,再放到Linux中執(zhí)行,。轉(zhuǎn)換方式如下(UltraEdit):File-->Conversions-->DOS->UNIX即可,。 如果是 Notepad++ 則是在: 編輯 -> EOL Conversion -> 轉(zhuǎn)換為 UNIX 格式 中。
2)也可在Linux中轉(zhuǎn)換: 首先要確保文件有可執(zhí)行權(quán)限 #sh>chmod a+x filename
然后修改文件格式 #sh>vi filename
利用如下命令查看文件格式 :set ff 或 :set fileformat
可以看到如下信息 fileformat=dos 或 fileformat=unix
利用如下命令修改文件格式 :set ff=unix 或 :set fileformat=unix
:wq (存盤退出)
最后再執(zhí)行文件 #sh>./filename
修改步驟:
vi elasticsearch
按esc
輸入(:set ff=unix)
再按esc
再輸入(:wq)
|