文章目录
- Download and install archive for Linux
- Download and install archive for MacOS
- Enabled automatic creation of system indices
- Running Elasticsearch from the command line
- Checking that Elasticsearch is Running
- Running as a daemon
- Configuring Elasticsearch on the command line
- Directory layout of archives
- Next steps
Elasticsearch 的 .tar.gz
文件适用于 Linux 和 MacOS 操作系统。
这个包同时包含免费和收费特性。开始一个30天的实验尝试所有特性。
在 Download Elasticsearch 页能找到 Elasticsearch 最细的稳定版本。Past Release page 能找到其他版本。
Elasticsearch 绑定了一个来自 JDK 维护者(GPLv2+CE)的 Open JDK 的版本。如果使用你自己的 Java 版本,查看 JVM version requirements。
Download and install archive for Linux
Elasticsearch v7.15.0 的 Linux 文件可以按如下方式下载和安装:
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.15.0-linux-x86_64.tar.gz
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.15.0-linux-x86_64.tar.gz.sha512 ①
shasum -a 512 -c elasticsearch-7.15.0-linux-x86_64.tar.gz.sha512
tar -xzf elasticsearch-7.15.0-linux-x86_64.tar.gz
cd elasticsearch-7.15.0/ ②
① 使用 SHA 比较下载的 .tar.gz
文件和公共 checksum,正常应该输出 elasticsearch-{version}-linux-x86_64.tar.gz: OK
。
② 这个文件夹被认为是 $ES_HOME
。
Download and install archive for MacOS
(略)
Enabled automatic creation of system indices
一些商业特性会在 Elasticsearch 中自动创建索引。默认的,Elasticsearch 被配置成允许自动创建索引,并且不需要任何额外步骤。然而,如果你需要禁在 Elasticsearch 中自动创建索引,你必须在 elasticsearch.yml
中配置 action.auto_create_index
去允许商业特性创建如下索引:
action.auto_create_index: .monitoring*,.watches,.triggered_watches,.watcher-history*,.ml*
如果你使用 Logstash 或 Beats ,那么你可能最需要在你的 action.auto_create_index 配置额外的索引名称,确切的值取决于您的本地配置。如果您不确定您的环境的正确值,您可以考虑将值设置为*,这将允许自动创建所有索引。
Running Elasticsearch from the command line
Elasticsearch 能像如下命令行所示启动:
./bin/elasticsearch
如果你有密码保护的 Elasticsearch keystore,你将会被提示输入 keystore’s 的密码。查看 Secure settings 获取更多细节。
默认的,Elasticsearch 会打印日志到 console(stdout)和 logs directory 文件夹中的<clustername>.log
文件。Elasticsearch 启动的时候会记录一些信息,但是一旦完成初始化,它将继续在 foreground 运行并且不会记录任何东西直到发生一些事情有值得记录的东西。当 Elasticsearch 运行的时候,你可以与它通过默认的 HTTP 端口 9200 进行交流。停止 Elasticsearch,键入 Ctrl -c
。
注意!All scripts packaged with Elasticsearch require a version of Bash that supports arrays and assume that Bash is available at /bin/bash. As such, Bash should be available at this path either directly or via a symbolic link.
Checking that Elasticsearch is Running
你可以通过发送一个 HTTP 请求到 localhost
的 9200
端口测试你的 Elasticsearch node 是否在运行:
GET /
正常应该返回像如下的 response:
{
"name" : "Cp8oag6",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA",
"version" : {
"number" : "7.15.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "f27399d",
"build_date" : "2016-03-30T09:51:41.449Z",
"build_snapshot" : false,
"lucene_version" : "8.9.0",
"minimum_wire_compatibility_version" : "1.2.3",
"minimum_index_compatibility_version" : "1.2.3"
},
"tagline" : "You Know, for Search"
}
可以在命令行中使用 -q
或 --quiet
选项禁用日志打印到 stdout
。
Running as a daemon
运行 Elasticsearch 作为守护线程,在命令行指定 -d
,并且使用 -p
选项在一个文件中记录 process ID。
./bin/elasticsearch -d -p pid
如果你有密码保护的 Elasticsearch keystore,你将会被提示输入 keystore’s 的密码。查看 Secure settings 获取更多细节。
日志信息可以在 $ES_HOME/logs/
文件夹中找到。
关闭 Elasticsearch,kill 掉被记录在 pid
文件中的 process ID:
pkill -F pid
注意!Elasticsearch 的
.tar.gz
包不包含systemd
模块。若想把 Elasticsearch 当做一个服务管理,使用 Debian 或 RPM 包替代它。
Configuring Elasticsearch on the command line
Elasticsearch 默认从 $ES_HOME/config/elasticsearch.yml
加载它的配置。Confirguring Elasticsearch 中解释了配置文件的格式。
一些配置可以在配置文件中指定,同样也能在命令行中使用 -E
语法如下:
./bin/elasticsearch -d -Ecluster.name=my_cluster -Enode.name=node_1
小贴士!一些集群范围的设置(像
cluster.name
)应该加到elasticsearch.yml
配置文件中,当一些 节点级设置例如node.name
可以在命令行中指定。
Directory layout of archives
archive 发行版是完整自包含的。所有的文件夹,默认的包含在 archive 解压时创建的 $ES_HOME
中。
这是非常方便的因为在你使用 Elasticsearch 时候不需要创建任何文件夹,并且卸载 Elasticsearch 就像删除 $ES_HOME
文件夹一样简单。然而,明智的做法是改变默认的配置文件夹位置,数据文件夹,日志文件夹,这样你就不会删除重要数据了。
Type | Description | Default Location | Setting |
---|---|---|---|
home | Elasticsearch home directory or $ES_HOME | Directory created by unpacking the archive | |
bin | Binary scripts including elasticsearch to start a node and elasticsearch-plugin to install plugins | $ES_HOME/bin | |
conf | Configuration files including elasticsearch.yml | $ES_HOME/config | ES_PATH_CONF |
data | The location of the data files of each index / shard allocated on the node | $ES_HOME/data | path.data |
logs | Log files location | $ES_HOME/logs | path.logs |
plugins | Plugin files location.Each plugin will be contained in a subdirectory. | $ES_HOME/plugins | |
repo | Shared file system repository location. Can hold multiple location. A file system repository can be placed in to any subdirectory of any directory specified here. | Not configured | path.repo |
Next steps
(略)