Elasticsearch 学习笔记 (二) 之 上手体验

来源:互联网 发布:如何删除网络驱动器 编辑:程序博客网 时间:2024/05/17 09:23


安装


elasticsearch 在Linux/Mac OS/Windows环境下都能运行, 安装非常简单:


1、上官网下载安装包

2、运行 bin/elasticsearch (Windows上运行 bin\elasticsearch.bat)

3、打开浏览器输入http://localhost:9200/ 或者: curl -X GET http://localhost:9200/


可以看到如下信息:

{  "name" : "Shi'ar Gladiator",  "cluster_name" : "elasticsearch",  "version" : {    "number" : "2.3.3",    "build_hash" : "218bdf10790eef486ff2c41a3df5cfa32dadcfde",    "build_timestamp" : "2016-05-17T15:40:04Z",    "build_snapshot" : false,    "lucene_version" : "5.5.0"  },  "tagline" : "You Know, for Search"}

恭喜你, Elasticsearch 已经安装成功 ^_^  很简单有木有??


Elasticsearch目录

TypeDescriptionDefault LocationSetting

home

Home of elasticsearch installation.

path.home

bin

Binary scripts including elasticsearch to start a node.

{path.home}/bin

conf

Configuration files including elasticsearch.yml

{path.home}/config

path.conf

data

The location of the data files of each index / shard allocated on the node. Can hold multiple locations.

{path.home}/data

path.data

logs

Log files location.

{path.home}/logs

path.logs

plugins

Plugin files location. Each plugin will be contained in a subdirectory.

{path.home}/plugins

path.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.

{path.conf}/scripts

path.script

注:我们可以通过下面两种方式配置多个数据目录

---------------------------------path.data: /mnt/first,/mnt/second---------------------------------
Or  in an array format:
----------------------------------------path.data: ["/mnt/first", "/mnt/second"]----------------------------------------


环境变量

Elasticsearch 首先会读取通用的JAVA_OPTS环境变量来获取JVM参数, 除了可以用JAVA_OPTS配置JVM参数外, 还可以通过Elasticsearch提供的ES_JAVA_OPTS环境变量配置JVM参数, ES_JAVA_OPTS会覆盖JAVA_OPTS中配置的相同参数, 官方建议是在JAVA_OPTS中配置通用的参数, 在ES_JAVA_OPTS中配置针对Elasticsearch需要调整的参数。

环境变量最主要的作用是指定 -Xmx 最大堆大小和 -Xms 最小堆大小。


Elasticsearch配置

elasticsearch的配置文件有两个config/elasticsearch.yml 和 config/logging.yml

听名字不难看出, 前者是配置主要参数的地方, 后者是配置日志参数的地方。


通常elasticsearch用默认的配置参数就够了, 如果有特殊需求要调整默认参数也很简单, 打开上面说的两个文件, 内容很简单, 能配置的参数都有注释和例子, 这里不在赘述。


以服务方式启动


Linux

elasticsearch针对不同的linux发行版提供了不同的二进制安装包, 下载专用的安装包即可轻松实现以服务方式启动。 当然如果你要找刺激, 也可以下载tar包, 自己配置成服务。


Windows

Windows版的zip包中官方提供了一个脚本(bin/service.bat)

用法:service.bat install|remove|start|stop|manager[SERVICE_ID]

参数说明:

install

Install Elasticsearch as a service

remove

Remove the installed Elasticsearch service (and stop the service if started)

start

Start the Elasticsearch service (if installed)

stop

Stop the Elasticsearch service (if started)

manager

Start a GUI for managing the installed service




0 0