linux下Elasticsearch安装设置Elasticsearch教程
设置Elasticsearch
本节包含有关如何设置Elasticsearch并使其运行的信息,其中包括:
下载 安装 开始 配置
支持的平台
正式支持的操作系统和JVM的矩阵可在此处获得: 支持矩阵。Elasticsearch在列出的平台上进行了测试,但它也可能在其他平台上工作。
Java(JVM)版本编辑
Elasticsearch是使用Java构建的,并且至少需要 Java 8 才能运行。只有Oracle的Java和OpenJDK被支持。所有Elasticsearch节点和客户端都应该使用相同的JVM版本。
我们建议在Java 8发行版系列中安装Java版本1.8.0_131或更高版本。我们建议使用 受支持的 LTS版本的Java。如果使用已知的Java版本,Elasticsearch将拒绝启动。
Elasticsearch将使用的Java版本可以通过设置JAVA_HOME环境变量进行配置。
安装Elasticsearch 编辑
Elasticsearch以下列软件包格式提供:
zip/tar.gz |
在zip和tar.gz包适合安装在任何系统上,并且是入门Elasticsearch在大多数系统中最容易的选择。 使用.zip或.tar.gz安装Elasticsearch或在Windows上安装Elasticsearch.zip |
deb |
该deb软件包适用于Debian,Ubuntu和其他基于Debian的系统。Debian软件包可以从Elasticsearch网站下载,也可以从我们的Debian仓库下载。 用Debian软件包安装Elasticsearch |
rpm |
该rpm软件包适合安装在Red Hat,Centos,SLES,OpenSuSE和其他基于RPM的系统上。RPM可以从Elasticsearch网站或从我们的RPM存储库下载。 用RPM安装Elasticsearch |
msi |
该msi软件包适用于安装至少安装了.NET 4.5框架的Windows 64位系统,是Windows上Elasticsearch入门的最简单的选择。MSI可以从Elasticsearch网站下载。 使用Windows MSI安装程序安装Elasticsearch |
docker |
图像可用于运行Elasticsearch作为Docker容器。它们可以从Elastic Docker Registry中下载。默认图像附带 预装的X-Pack。 用Docker安装Elasticsearch |
Puppet |
puppet-elasticsearch |
Chef |
cookbook-elasticsearch |
Ansible |
ansible-elasticsearch |
使用.zip 或者.tar.gz安装Elasticsearch
Elasticsearch是.zip作为一个.tar.gz包装提供的。这些软件包可用于在任何系统上安装Elasticsearch,并且是试用Elasticsearch时最简单的软件包格式。
Elasticsearch的最新稳定版本可以在 下载Elasticsearch页面找到。其他版本可以在“ 过去的版本”页面找到。
注意
Elasticsearch需要Java 8或更高版本。使用 官方的Oracle发行版 或OpenJDK等开源发行版。
下载并安装.zip软件包编辑
.zipElasticsearch v6.2.0 的存档可以下载并安装,如下所示:
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.0.zip wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.0.zip.sha512 shasum -a 512 -c elasticsearch-6.2.0.zip.sha512 unzip elasticsearch-6.2.0.zip cd elasticsearch-6.2.0/
比较下载的.zip存档的SHA 和应该输出的发布的校验和 elasticsearch-{version}.zip: OK。
这个目录被称为$ES_HOME。
下载并安装.tar.gz软件包
.tar.gzElasticsearch v6.2.0 的存档可以下载并安装,如下所示:
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.0.tar.gz wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.0.tar.gz.sha512 shasum -a 512 -c elasticsearch-6.2.0.tar.gz.sha512 tar -xzf elasticsearch-6.2.0.tar.gz cd elasticsearch-6.2.0/
比较下载的.tar.gz存档的SHA 和应该输出的发布的校验和 elasticsearch-{version}.tar.gz: OK。
这个目录被称为$ES_HOME。
我是下载后离线安装
我是root用户:
tar -zxvf elasticsearch-6.2.0.tar.gz -C /opt/moudles/
[2018-02-08T14:31:43,598][ERROR][o.e.b.Bootstrap ] Exception java.lang.RuntimeException: can not run elasticsearch as root at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:105) ~[elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172) ~[elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:323) [elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) [elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) [elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) [elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) [elasticsearch-cli-6.2.0.jar:6.2.0] at org.elasticsearch.cli.Command.main(Command.java:90) [elasticsearch-cli-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) [elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:85) [elasticsearch-6.2.0.jar:6.2.0] [2018-02-08T14:31:43,610][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main] org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:125) ~[elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.2.0.jar:6.2.0] at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:85) ~[elasticsearch-6.2.0.jar:6.2.0] Caused by: java.lang.RuntimeException: can not run elasticsearch as root at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:105) ~[elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172) ~[elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:323) ~[elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-6.2.0.jar:6.2.0] ... 6 more
解决1:(未成功)
1.启动 elasticsearch 如出现异常 can not run elasticsearch as root
解决方法:创建ES 账户,修改文件夹 文件 所属用户 组
删除掉刚刚的es
# rm -rf /opt/moudles/elasticsearch-6.2.0 # groupadd ES # useradd ES -g ES # tar -zxvf elasticsearch-6.2.0.tar.gz -C /opt/moudles/ # chgrp -R ES elasticsearch-6.2.0/ # chown -R ES elasticsearch-6.2.0/ # bin/elasticsearch 仍然报错
解决2:(未成功)
下载ES安装包elasticsearch-5.6.3.zip 在usr 目录下创建了es文件夹,将安装包上传到里面,解压 unzip elasticsearch-5.6.3.zip cd 进入 elasticsearch-5.6.3 文件里面
创建ES用户和组(创建elsearch用户组及elsearch用户),因为使用root用户执行ES程序,将会出现错误;所以这里需要创建单独的用户去执行ES 文件;命令如下:
命令一:groupadd elsearch 命令二:useradd elsearch -g elsearch 命令三: tar -zxvf elasticsearch-6.2.0.tar.gz -C /opt/moudles/ 命令四:chown -R elsearch:elsearch elasticsearch-5.6.3
该命令是更改该文件夹下所属的用户组的权限
创建ES数据文件和日志文件,直接在root用户根目录一下创建就可以了
命令一:mkdir /opt/moudles/elasticsearch-6.2.0_data 命令二:chown -R elsearch:elsearch /opt/moudles/elasticsearch-6.2.0_data/ 命令三:su - elsearch 命令四:mkdir -p /opt/moudles/elasticsearch-6.2.0_data/data 命令五:mkdir -p /opt/moudles/elasticsearch-6.2.0_data/logs
修改ES配置文件,使用cd命令进入到config 文件下,执行 vi elasticsearch.yml 命令,如图所示,本人没有配置集群,只是简单的配置了一下;详细说明可以参考官网
# ======================== Elasticsearch Configuration ========================= # # NOTE: Elasticsearch comes with reasonable defaults for most settings. # Before you set out to tweak and tune the configuration, make sure you # understand what are you trying to accomplish and the consequences. # # The primary way of configuring a node is via this file. This template lists # the most important settings you may want to configure for a production cluster. # # Please consult the documentation for further information on configuration options: # https://www.elastic.co/guide/en/elasticsearch/reference/index.html # # ---------------------------------- Cluster ----------------------------------- # # Use a descriptive name for your cluster: # #cluster.name: my-application cluster.name: myapplication # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # #node.name: node-1 node.name: my_lcc_node_one # # Add custom attributes to the node: # #node.attr.rack: r1 # # ----------------------------------- Paths ------------------------------------ # # Path to directory where to store the data (separate multiple locations by comma): # #path.data: /path/to/data path.data: /opt/moudles/elasticsearch-6.2.0_data/es/data/ # Path to log files: # #path.logs: /path/to/logs # path.logs: /opt/moudles/elasticsearch-6.2.0_data/es/data/ # ----------------------------------- Memory ----------------------------------- # # Lock the memory on startup: # #bootstrap.memory_lock: true bootstrap.memory_lock: false bootstrap.system_call_filter: false # Make sure that the heap size is set to about half the memory available # on the system and that the owner of the process is allowed to use this # limit. # # Elasticsearch performs poorly when the system is swapping the memory. # # ---------------------------------- Network ----------------------------------- # # Set the bind address to a specific IP (IPv4 or IPv6): # #network.host: 192.168.0.1 network.host: 192.168.10.173 # # Set a custom port for HTTP: # #http.port: 9200 http.port: 9200 # # For more information, consult the network module documentation. # # --------------------------------- Discovery ---------------------------------- # # Pass an initial list of hosts to perform discovery when new node is started: # The default list of hosts is ["127.0.0.1", "[::1]"] # #discovery.zen.ping.unicast.hosts: ["host1", "host2"] # # Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1): # #discovery.zen.minimum_master_nodes: # # For more information, consult the zen discovery module documentation. # # ---------------------------------- Gateway ----------------------------------- # # Block initial recovery after a full cluster restart until N nodes are started: # #gateway.recover_after_nodes: 3 # # For more information, consult the gateway module documentation. # # ---------------------------------- Various ----------------------------------- # # Require explicit names when deleting indices: # #action.destructive_requires_name: true执行ES文件,进入到bin 目录下执行 ./elasticsearch 命令就可以了,执行 ./elasticesrarch -d 是后台运行 , 如果没有什么问题话,就可以安全生成了;然后执行curl ‘https://自己配置的IP地址:9200/’ 命令,就出现下面的结果
# curl -X GET https://localhost:9200 { "name" : "dRoj17S", "cluster_name" : "elasticsearch", "cluster_uuid" : "kN_fnGlHTkSY4wjpRCqNNA", "version" : { "number" : "6.2.0", "build_hash" : "37cdac1", "build_date" : "2018-02-01T17:31:12.527918Z", "build_snapshot" : false, "lucene_version" : "7.2.1", "minimum_wire_compatibility_version" : "5.6.0", "minimum_index_compatibility_version" : "5.0.0" }, "tagline" : "You Know, for Search" }
但是我的报错
解决3:(未成功)
异常描述为不能以root权限运行Elasticsearch.解决办法是运行时加上参数:
bin/elasticsearch -Des.insecure.allow.root=true
或者修改bin/elasticsearch,加上ES_JAVA_OPTS属性:
ES_JAVA_OPTS="-Des.insecure.allow.root=true"
保存之后重启Elasticsearch。
解决4:(成功)
root# useradd es root# passwd es root# mkdir /home/es root# chown es:es /home/es root# cd /home/es/ root# mkdir elasticsearch root# tar -zxvf /opt/software/elasticsearch-6.2.0.tar.gz -C /home/es/elasticsearch/ root# chown -R es:es /home/es/elasticsearch/ root# su es es# cd /home/es/elasticsearch/elasticsearch-6.2.0/ es# bin/elasticsearch
运行如下
[2018-02-08T18:07:35,077][WARN ][o.e.b.JNANatives ] unable to install syscall filter: java.lang.UnsupportedOperationException: seccomp unavailable: requires kernel 3.5+ with CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER compiled in at org.elasticsearch.bootstrap.SystemCallFilter.linuxImpl(SystemCallFilter.java:328) ~[elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.SystemCallFilter.init(SystemCallFilter.java:616) ~[elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.JNANatives.tryInstallSystemCallFilter(JNANatives.java:258) [elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.Natives.tryInstallSystemCallFilter(Natives.java:113) [elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:110) [elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172) [elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:323) [elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) [elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) [elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) [elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) [elasticsearch-cli-6.2.0.jar:6.2.0] at org.elasticsearch.cli.Command.main(Command.java:90) [elasticsearch-cli-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) [elasticsearch-6.2.0.jar:6.2.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:85) [elasticsearch-6.2.0.jar:6.2.0] [2018-02-08T18:07:35,493][INFO ][o.e.n.Node ] [] initializing ... [2018-02-08T18:07:35,724][INFO ][o.e.e.NodeEnvironment ] [dRoj17S] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [7.4gb], net total_space [25.4gb], types [rootfs] [2018-02-08T18:07:35,724][INFO ][o.e.e.NodeEnvironment ] [dRoj17S] heap size [1007.3mb], compressed ordinary object pointers [true] [2018-02-08T18:07:35,728][INFO ][o.e.n.Node ] node name [dRoj17S] derived from node ID [dRoj17SdQ12H6bAgF_jfLw]; set [node.name] to override [2018-02-08T18:07:35,729][INFO ][o.e.n.Node ] version[6.2.0], pid[21222], build[37cdac1/2018-02-01T17:31:12.527918Z], OS[Linux/2.6.32-504.el6.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_121/25.121-b13] [2018-02-08T18:07:35,729][INFO ][o.e.n.Node ] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.io.tmpdir=/tmp/elasticsearch.AuexHKPB, -XX:+HeapDumpOnOutOfMemoryError, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSize=64m, -Des.path.home=/home/es/elasticsearch/elasticsearch-6.2.0, -Des.path.conf=/home/es/elasticsearch/elasticsearch-6.2.0/config] [2018-02-08T18:07:37,299][INFO ][o.e.p.PluginsService ] [dRoj17S] loaded module [aggs-matrix-stats] [2018-02-08T18:07:37,304][INFO ][o.e.p.PluginsService ] [dRoj17S] loaded module [analysis-common] [2018-02-08T18:07:37,304][INFO ][o.e.p.PluginsService ] [dRoj17S] loaded module [ingest-common] [2018-02-08T18:07:37,305][INFO ][o.e.p.PluginsService ] [dRoj17S] loaded module [lang-expression] [2018-02-08T18:07:37,305][INFO ][o.e.p.PluginsService ] [dRoj17S] loaded module [lang-mustache] [2018-02-08T18:07:37,306][INFO ][o.e.p.PluginsService ] [dRoj17S] loaded module [lang-painless] [2018-02-08T18:07:37,306][INFO ][o.e.p.PluginsService ] [dRoj17S] loaded module [mapper-extras] [2018-02-08T18:07:37,306][INFO ][o.e.p.PluginsService ] [dRoj17S] loaded module [parent-join] [2018-02-08T18:07:37,307][INFO ][o.e.p.PluginsService ] [dRoj17S] loaded module [percolator] [2018-02-08T18:07:37,307][INFO ][o.e.p.PluginsService ] [dRoj17S] loaded module [rank-eval] [2018-02-08T18:07:37,307][INFO ][o.e.p.PluginsService ] [dRoj17S] loaded module [reindex] [2018-02-08T18:07:37,307][INFO ][o.e.p.PluginsService ] [dRoj17S] loaded module [repository-url] [2018-02-08T18:07:37,307][INFO ][o.e.p.PluginsService ] [dRoj17S] loaded module [transport-netty4] [2018-02-08T18:07:37,307][INFO ][o.e.p.PluginsService ] [dRoj17S] loaded module [tribe] [2018-02-08T18:07:37,308][INFO ][o.e.p.PluginsService ] [dRoj17S] no plugins loaded [2018-02-08T18:07:43,383][INFO ][o.e.d.DiscoveryModule ] [dRoj17S] using discovery type [zen] [2018-02-08T18:07:44,446][INFO ][o.e.n.Node ] initialized [2018-02-08T18:07:44,446][INFO ][o.e.n.Node ] [dRoj17S] starting ... [2018-02-08T18:07:44,739][INFO ][o.e.t.TransportService ] [dRoj17S] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300} [2018-02-08T18:07:44,757][WARN ][o.e.b.BootstrapChecks ] [dRoj17S] max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536] [2018-02-08T18:07:44,757][WARN ][o.e.b.BootstrapChecks ] [dRoj17S] max number of threads [1024] for user [es] is too low, increase to at least [4096] [2018-02-08T18:07:44,757][WARN ][o.e.b.BootstrapChecks ] [dRoj17S] max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] [2018-02-08T18:07:44,758][WARN ][o.e.b.BootstrapChecks ] [dRoj17S] system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk [2018-02-08T18:07:47,892][INFO ][o.e.c.s.MasterService ] [dRoj17S] zen-disco-elected-as-master ([0] nodes joined), reason: new_master {dRoj17S}{dRoj17SdQ12H6bAgF_jfLw}{UBEX5MGRQ5iWiKb8lYm1IA}{127.0.0.1}{127.0.0.1:9300} [2018-02-08T18:07:47,904][INFO ][o.e.c.s.ClusterApplierService] [dRoj17S] new_master {dRoj17S}{dRoj17SdQ12H6bAgF_jfLw}{UBEX5MGRQ5iWiKb8lYm1IA}{127.0.0.1}{127.0.0.1:9300}, reason: apply cluster state (from master [master {dRoj17S}{dRoj17SdQ12H6bAgF_jfLw}{UBEX5MGRQ5iWiKb8lYm1IA}{127.0.0.1}{127.0.0.1:9300} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)]]) [2018-02-08T18:07:47,957][INFO ][o.e.h.n.Netty4HttpServerTransport] [dRoj17S] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200} [2018-02-08T18:07:47,957][INFO ][o.e.n.Node ] [dRoj17S] started [2018-02-08T18:07:47,966][INFO ][o.e.g.GatewayService ] [dRoj17S] recovered [0] indices into cluster_state
执行
curl -X GET https://localhost:9200
结果:
{ "name" : "dRoj17S", "cluster_name" : "elasticsearch", "cluster_uuid" : "kN_fnGlHTkSY4wjpRCqNNA", "version" : { "number" : "6.2.0", "build_hash" : "37cdac1", "build_date" : "2018-02-01T17:31:12.527918Z", "build_snapshot" : false, "lucene_version" : "7.2.1", "minimum_wire_compatibility_version" : "5.6.0", "minimum_index_compatibility_version" : "5.0.0" }, "tagline" : "You Know, for Search" }
从命令行编辑运行Elasticsearch
Elasticsearch可以从命令行启动,如下所示:
./bin/elasticsearch
默认情况下,Elasticsearch在前台运行,将其日志打印到标准输出(stdout),并可以通过按停止Ctrl-C。
注意
与Elasticsearch打包在一起的所有脚本都需要一个支持数组的Bash版本,并假定Bash可用/bin/bash。因此,Bash应该直接或通过符号链接在这条路径上可用。
检查Elasticsearch是否正在运行编辑
您可以测试你的Elasticsearch节点通过发送一个HTTP请求的端口上运行9200上localhost:
GET /
这应该给你一个这样的回应:
{ "name" : "Cp8oag6", "cluster_name" : "elasticsearch", "cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA", "version" : { "number" : "6.2.0", "build_hash" : "f27399d", "build_date" : "2016-03-30T09:51:41.449Z", "build_snapshot" : false, "lucene_version" : "7.2.1", "minimum_wire_compatibility_version" : "1.2.3", "minimum_index_compatibility_version" : "1.2.3" }, "tagline" : "You Know, for Search" }
stdout使用 命令行上的-q或–quiet选项可以禁用日志打印。
作为守护程序运行
要将Elasticsearch作为守护程序运行,请-d在命令行上指定,并使用以下-p选项将进程ID记录到文件中:
./bin/elasticsearch -d -p pid
日志消息可以在$ES_HOME/logs/目录中找到。
要关闭Elasticsearch,请杀死pid文件中记录的进程ID :
kill `cat pid`
注意
RPM和Debian 软件包中提供的启动脚本负责为您启动和停止Elasticsearch过程。
在命令行上配置Elasticsearch
Elasticsearch $ES_HOME/config/elasticsearch.yml 默认从文件加载它的配置。配置Elasticsearch解释了这个配置文件的格式 。
可以在配置文件中指定的任何设置也可以在命令行中指定,使用-E语法如下:
./bin/elasticsearch -d -Ecluster.name=my_cluster -Enode.name=node_1
TIP
通常情况下,任何群集范围的设置(如cluster.name)应该被添加到elasticsearch.yml配置文件中,而任何节点特定的设置(如node.name可以在命令行中指定)。
目录布局.zip和.tar.gz档案
在.zip和.tar.gz包是完全独立的。所有的文件和目录,默认情况下都包含在$ES_HOME解压档案时创建的目录中。
这非常方便,因为您不必创建任何目录来开始使用Elasticsearch,卸载Elasticsearch就像删除$ES_HOME目录一样简单。但是,建议更改config目录,数据目录和日志目录的默认位置,以便稍后不要删除重要数据。
Type | Description | Default Location | Setting |
---|---|---|---|
home | Elasticsearch主目录或 $ES_HOME | 通过解压归档文件创建的目录 | |
bin | 二进制脚本,包括elasticsearch启动节点和elasticsearch-plugin安装插件 | $ES_HOME/bin | |
conf | 配置文件包括 elasticsearch.yml | $ES_HOME/config | ES_PATH_CONF |
data | 在节点上分配的每个索引/分片的数据文件的位置。可以容纳多个地点。 | $ES_HOME/data | path.data |
logs | 日志文件位置 | $ES_HOME/logs | path.logs |
plugins | 插件文件的位置。每个插件将被包含在一个子目录中 | $ES_HOME/plugins | |
repo | 共享文件系统存储库位置。可以容纳多个地点。文件系统存储库可以放置在此处指定的任何目录的任何子目录中。 | Not configured | path.repo |
script | 脚本文件的位置 | $ES_HOME/scripts | path.scripts |
后续步骤
您现在已经设置了一个测试Elasticsearch环境。在您开始认真开发或者使用Elasticsearch进行生产之前,您需要进行一些额外的设置:
了解如何配置Elasticsearch。 配置重要的Elasticsearch设置。 配置重要的系统设置。
推荐阅读