将Elasticsearch安装到虚拟机中
关于
因为什么都说不上来,所以决定试一试。
环境
-
- vagrantで立てたbento/centos-7.2
7.3はなぞのエラーに見舞われたのでパス
安装
只需按照官方指南的基本指示。由于rpm似乎更方便,选择使用rpm进行安装。
安装JRE
由于需要Java运行环境,因此安装openjdk。
$ sudo yum install java-1.8.0-openjdk
$ java -version
openjdk version "1.8.0_111"
OpenJDK Runtime Environment (build 1.8.0_111-b15)
OpenJDK 64-Bit Server VM (build 25.111-b15, mixed mode)
导入GPG密钥
$ sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
手动添加并安装 Elasticsearch 存储库
$ sudo vi /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-5.x]
name=Elasticsearch repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
$ sudo yum install elasticsearch -y
### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd
sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
### You can start elasticsearch service by executing
sudo systemctl start elasticsearch.service
検証中 : elasticsearch-5.1.1-1.noarch 1/1
インストール:
elasticsearch.noarch 0:5.1.1-1
完了しました!
因此,我暂时使用systemd启动。
$ sudo systemctl start elasticsearch
$ sudo systemctl status elasticsearch
错误发生了…
Jan 07 11:40:52 localhost.localdomain elasticsearch[3409]: OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
Jan 07 11:40:52 localhost.localdomain elasticsearch[3409]: OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)
Jan 07 11:40:52 localhost.localdomain elasticsearch[3409]: #
Jan 07 11:40:52 localhost.localdomain elasticsearch[3409]: # There is insufficient memory for the Java Runtime Environment to continue.
Jan 07 11:40:52 localhost.localdomain elasticsearch[3409]: # Native memory allocation (mmap) failed to map 2060255232 bytes for committing reserved memory.
Jan 07 11:40:52 localhost.localdomain elasticsearch[3409]: # An error report file with more information is saved as:
Jan 07 11:40:52 localhost.localdomain elasticsearch[3409]: # /tmp/hs_err_pid3409.log
Jan 07 11:40:52 localhost.localdomain systemd[1]: elasticsearch.service: main process exited, code=exited, status=1/FAILURE
听说内存不够了。(虚拟机内存只有512MB。感觉太小了,所以后来增加到了1GB。)
据说默认情况下需要近2GB的存储空间。
改变内存大小
要更改设定,请修改以下文件。
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
#-Xms2g
#-Xmx2g
-Xms1g
-Xmx1g
当您尝试启动时
$ sudo systemctl start elasticsearch
$ sudo systemctl status elasticsearch
[vagrant@localhost etc]$ sudo systemctl status elasticsearch
● elasticsearch.service - Elasticsearch
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
Active: active (running) since 土 2017-01-07 11:53:24 UTC; 44s ago
启动了!安装完成!
请根据以下信息提供一个适当的中文翻译:
参考:
- http://qiita.com/jooex/items/21a26e70f995e91a4e36