在Liunx服务器上运行

为了在您的操作系统运行elasticsearch服务,所提供的包尽量使其尽可能容易在重启和升级过程中启动和停止elasticsearch。

Linux

目前,我们会自动创建一个Debian软件包和RPM包,这是可用的下载页面上。包本身不具有任何相关性,但你必须确保你安装了JDK。

每个包设有一个配置文件,它允许你设置以下参数


ES_USER

The user to run as, defaults to elasticsearch

ES_GROUP

The group to run as, defaults to elasticsearch

ES_HEAP_SIZE

The heap size to start with

ES_HEAP_NEWSIZE

The size of the new generation heap

ES_DIRECT_SIZE

The maximum size of the direct memory

MAX_OPEN_FILES

Maximum number of open files, defaults to 65535

MAX_LOCKED_MEMORY

Maximum locked memory size. Set to "unlimited" if you use the bootstrap.mlockall option in elasticsearch.yml. You must also set ES_HEAP_SIZE.

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 65535

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 logging.yml files), defaults to /etc/elasticsearch

ES_JAVA_OPTS

Any additional java options you may want to apply. This may be useful, if you need to set the node.name property, but do not want to change the elasticsearch.yml configuration file, because it is distributed via a provisioning system like puppet or chef. Example: ES_JAVA_OPTS="-Des.node.name=search-01"

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.

ES_GC_LOG_FILE

The absolute log file path for creating a garbage collection logfile, which is done by the JVM. Note that this logfile can grow pretty quick and thus is disabled by default.

Debian/Ubuntu

你需要Debian软件包附带的一切,因为它使用标准的Debian工具,如更新update-rc.d来定义其上运行的运行级别。初始化脚本放在/etc/init.d/elasticsearch正如你所期望的。该配置文件被放置在在/etc/default/elasticsearch。

Debian软件包默认不启动该服务。这样做的原因是为了防止该实例没有被适当地配置就意外加入集群。使用安装后的dpkg -i可以使用下面的命令来保证,elasticsearch启动时系统启动,然后启动elasticsearch:


sudo update-rc.d elasticsearch defaults 95 10
sudo /etc/init.d/elasticsearch start

运行Debian 8或Ubuntu 14或更高版本的用户可能需要systemd的配置,而不是update-rc.d。在这些情况下,请参考称为“使用systemd”部分。

安装oracle JDK

通常的建议是Oracle JDK与elasticsearch一起运行。但是Ubuntu和Debian只能运行在OpenJDK,由于许可证问题。您可以轻松地安装Oracle安装程序包。以防你错过了add-apt-repository命令在 Debian GNU / Linux上,请确保至少有Debian的python-software-properties安装。


sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
java -version

最后一个命令应该验证Oracle JDK的安装成功。

基于RPM分布

使用命令行工具

一些基于RPM的发行版使用的chkconfig启用和禁用服务。初始化脚本位于/etc/init.d/elasticsearch,那里的配置文件被放置在/etc/sysconfig/elasticsearch。像Debian软件包的RPM包没有被安装后默认启动,你必须通过输入以下命令手动执行此操作。


sudo /sbin/chkconfig --add elasticsearch
sudo service elasticsearch start

使用 systemd

分布如Debian Jessie,Ubuntu 14,而许多SUSE衍生物不使用的chkconfig的工具注册服务,而是systemd和其命令/bin/systemctl启动和停止服务(至少在新的版本,否则使用的chkconfig上面的命令)。配置文件也被放置在的/etc/sysconfig/elasticsearch如果系统是基于转速和/etc/default/elasticsearch如果它是DEB。安装RPM之后,你必须改变systemd配置,然后启动elasticsearch


sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
sudo /bin/systemctl start elasticsearch.service

还要注意的是改变MAX_MAP_COUNT设置中的/etc/sysconfig/elasticsearch没有任何效果,你将不得不改变它/usr/lib/sysctl.d/elasticsearch.conf才能有把它应用在启动时。

results matching ""

    No results matching ""