Elasticsearch 安裝

Install Elasticsearch with Debian Package

  • for Debian, Ubuntu, and other Debian-based systems
  • 需要java環(huán)境适袜,請自行安裝

步驟

  • 下載并安裝公共簽名密鑰

<pre><code>
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
</code></pre>

  • 你可能需要在Debian安裝apt-transport-https:

<pre><code>
sudo apt-get install apt-transport-https
</code></pre>

  • 將 repository 保存到 /etc/apt/sources.list.d/elastic-5.x.list

<pre><code>
echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list
</code></pre>

  • 你可以安裝 Debian package Elasticsearch,命令如下:

<pre><code>
sudo apt-get update && sudo apt-get install elasticsearch
</code></pre>

  • Elasticsearch v5.4.2 Debian 軟件包可以從網(wǎng)站上下載并安裝:

<pre><code>
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.2.deb
sha1sum elasticsearch-5.4.2.deb
sudo dpkg -i elasticsearch-5.4.2.deb
</code></pre>

  • 配置Elasticsearch隨系統(tǒng)啟動洪鸭,運行下面的命令:

<pre><code>
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
</code></pre>

  • Elasticsearch可以按照如下方式啟動和停止:

<pre><code>
sudo systemctl start elasticsearch.service
sudo systemctl stop elasticsearch.service
</code></pre>

當(dāng)系統(tǒng)啟用了日志記錄甚负,日志記錄的信息都可以用journalctl命令:

  • To tail the journal:

<pre><code>
sudo journalctl -f
</code></pre>

  • To list journal entries for the elasticsearch service:

<pre><code>
sudo journalctl --unit elasticsearch
</code></pre>

  • To list journal entries for the elasticsearch service starting from a given time:

<pre><code>
sudo journalctl --unit elasticsearch --since "2016-10-30 18:17:16"
</code></pre>

  • 我的機器是阿里云1c 1G的,啟動的時候就報出如下錯誤

<pre><code>
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot alloc

There is insufficient memory for the Java Runtime Environment to continue.

Native memory allocation (mmap) failed to map 2060255232 bytes for committing reserved memory.

</code></pre>

  • 根據(jù)機器配置不同可以修改相對應(yīng)的參數(shù)

<pre><code>
vi /etc/elasticsearch/jvm.options
</code></pre>

  • 將 -Xms 和 -Xmx 參數(shù)修改一下就可以正常啟動了
    <pre><code>
    -Xms256m
    -Xmx256m
    </code></pre>

  • 默認(rèn)參數(shù)是運行在9200端口下的,可以通過如下命令確認(rèn):
    <pre><code>
    curl -XGET 'localhost:9200/?pretty'
    </code></pre>

  • 返回結(jié)果如下

<pre><code>
{
"name" : "0NcYzNP",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "-QmXkqg6T0uVrUAbNZhggA",
"version" : {
"number" : "5.4.2",
"build_hash" : "929b078",
"build_date" : "2017-06-15T02:29:28.122Z",
"build_snapshot" : false,
"lucene_version" : "6.5.1"
},
"tagline" : "You Know, for Search"
}
</code></pre>

配置Elasticsearch

參數(shù) 注釋
ES_USER The user to run as, defaults to elasticsearch
ES_GROUP The group to run as, defaults to elasticsearch
JAVA_HOME Set a custom Java path to be used
MAX_OPEN_FILES Maximum number of open files, defaults to 65536
MAX_LOCKED_MEMORY Maximum locked memory size. Set to unlimited if you use the bootstrap.memory_lock option in elasticsearch.yml
MAX_MAP_COUNT Maximum number of memory map areas a process may have. If you use mmapfs as index store type, make sure this is set to a high value. For more information, check the linux kernel documentation about max_map_count. This is set via sysctl before starting elasticsearch. Defaults to 262144
LOG_DIR Log directory, defaults to /var/log/elasticsearch
DATA_DIR Data directory, defaults to /var/lib/elasticsearch
CONF_DIR Configuration file directory (which needs to include elasticsearch.yml and log4j2.properties files), defaults to /etc/elasticsearch
ES_JAVA_OPTS Any additional JVM system properties you may want to apply
RESTART_ON_UPGRADE Configure restart on package upgrade, defaults to false. This means you will have to restart your elasticsearch instance after installing a package manually. The reason for this is to ensure, that upgrades in a cluster do not result in a continuous shard reallocation resulting in high network traffic and reducing the response times of your cluster
Type Description Default Location Setting
home Elasticsearch home directory or $ES_HOME /usr/share/elasticsearch
bin Binary scripts including elasticsearch to start a node and elasticsearch-plugin to install plugins /usr/share/elasticsearch/bin
conf Configuration files including elasticsearch.yml /etc/elasticsearch path.conf
conf Environment variables including heap size, file descriptors /etc/default/elasticsearch
data The location of the data files of each index / shard allocated on the node. Can hold multiple locations. /var/lib/elasticsearch path.data
logs Log files location. /var/log/elasticsearch path.logs
plugins Plugin files location. Each plugin will be contained in a subdirectory. /usr/share/elasticsearch/plugins
repo Shared file system repository locations. Can hold multiple locations. A file system repository can be placed in to any subdirectory of any directory specified here. Not configured path.repo
script Location of script files. /etc/elasticsearch/scripts path.scripts
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市摩渺,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖荒吏,帶你破解...
    沈念sama閱讀 223,207評論 6 521
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件沾谜,死亡現(xiàn)場離奇詭異膊毁,居然都是意外死亡,警方通過查閱死者的電腦和手機基跑,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,455評論 3 400
  • 文/潘曉璐 我一進(jìn)店門婚温,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人媳否,你說我怎么就攤上這事栅螟。” “怎么了篱竭?”我有些...
    開封第一講書人閱讀 170,031評論 0 366
  • 文/不壞的土叔 我叫張陵力图,是天一觀的道長。 經(jīng)常有香客問我掺逼,道長吃媒,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 60,334評論 1 300
  • 正文 為了忘掉前任,我火速辦了婚禮赘那,結(jié)果婚禮上刑桑,老公的妹妹穿的比我還像新娘。我一直安慰自己募舟,他們只是感情好祠斧,可當(dāng)我...
    茶點故事閱讀 69,322評論 6 398
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著胃珍,像睡著了一般梁肿。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上觅彰,一...
    開封第一講書人閱讀 52,895評論 1 314
  • 那天吩蔑,我揣著相機與錄音,去河邊找鬼填抬。 笑死烛芬,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的飒责。 我是一名探鬼主播赘娄,決...
    沈念sama閱讀 41,300評論 3 424
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼宏蛉!你這毒婦竟也來了遣臼?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 40,264評論 0 277
  • 序言:老撾萬榮一對情侶失蹤拾并,失蹤者是張志新(化名)和其女友劉穎揍堰,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體嗅义,經(jīng)...
    沈念sama閱讀 46,784評論 1 321
  • 正文 獨居荒郊野嶺守林人離奇死亡屏歹,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,870評論 3 343
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了之碗。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片蝙眶。...
    茶點故事閱讀 40,989評論 1 354
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖褪那,靈堂內(nèi)的尸體忽然破棺而出幽纷,到底是詐尸還是另有隱情,我是刑警寧澤博敬,帶...
    沈念sama閱讀 36,649評論 5 351
  • 正文 年R本政府宣布霹崎,位于F島的核電站,受9級特大地震影響冶忱,放射性物質(zhì)發(fā)生泄漏尾菇。R本人自食惡果不足惜境析,卻給世界環(huán)境...
    茶點故事閱讀 42,331評論 3 336
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望派诬。 院中可真熱鬧劳淆,春花似錦、人聲如沸默赂。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,814評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽缆八。三九已至曲掰,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間奈辰,已是汗流浹背栏妖。 一陣腳步聲響...
    開封第一講書人閱讀 33,940評論 1 275
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留奖恰,地道東北人吊趾。 一個月前我還...
    沈念sama閱讀 49,452評論 3 379
  • 正文 我出身青樓,卻偏偏與公主長得像瑟啃,于是被迫代替她去往敵國和親论泛。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,995評論 2 361

推薦閱讀更多精彩內(nèi)容