linux单节点安装elasticsearch 6.4.1

Elasticsearch 官网:https://www.elastic.co

Elasticsearch封装了支持索引和全文搜索的Lucene的强大且复杂难以使用功能,同时,Elasticsearch提供分布式实时文件存储和实时分析搜索引擎,具有可扩展性。这些功能全部集成在ES服务里,支持各种语音的应用、客户端、命令行只需要调用它提供的操作简单的REST API 的接口,就可以与之交互。它开箱即用,就是说安装即可用。

 

安装准备

Linux操作系统(我的是CentOS 7.6 x86_64)

JDK1.8.*(我的是系统自带的 V1.8.0_181)

 

创建用户

#创建组
[root@bogon ~]# groupadd es

#创建用户
[root@bogon ~]# useradd es -g es

#设置密码
[root@bogon ~]# echo "自定义密码"|passwd es --stdin
更改用户 es 的密码 。
passwd:所有的身份验证令牌已经成功更新。

#切换到es用户
[root@bogon ~]# su - es

 

下载
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.1.tar.gz
 
解压
tar -zxvf elasticsearch-6.4.1.tar.gz

 

安装路径
/home/es/elasticsearch-6.4.1

 

启动服务端
进入ES安装目录,执行 ./bin/elasticsearch
[es@bogon ~]$ elasticsearch-6.4.1/bin/elasticsearch
[2019-10-17T09:43:29,363][INFO ][o.e.n.Node               ] [] initializing ...
[2019-10-17T09:43:29,409][INFO ][o.e.e.NodeEnvironment    ] [uyS3a_p] using [1] data paths, mounts [[/home (/dev/mapper/centos-home)]], net usable_space [140.6gb], net total_space [141.5gb], types [xfs]
[2019-10-17T09:43:29,409][INFO ][o.e.e.NodeEnvironment    ] [uyS3a_p] heap size [989.8mb], compressed ordinary object pointers [true]
[2019-10-17T09:43:29,410][INFO ][o.e.n.Node               ] [uyS3a_p] node name derived from node ID [uyS3a_pATBG5NwZNzfpWJQ]; set [node.name] to override
[2019-10-17T09:43:29,410][INFO ][o.e.n.Node               ] [uyS3a_p] version[6.4.1], pid[24171], build[default/tar/e36acdb/2018-09-13T22:18:07.696808Z], OS[Linux/3.10.0-957.el7.x86_64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_181/25.181-b13]
[2019-10-17T09:43:29,410][INFO ][o.e.n.Node               ] [uyS3a_p] 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.kJBGHbPY, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -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-6.4.1, -Des.path.conf=/home/es/elasticsearch-6.4.1/config, -Des.distribution.flavor=default, -Des.distribution.type=tar]
[2019-10-17T09:43:30,461][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [aggs-matrix-stats]
[2019-10-17T09:43:30,461][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [analysis-common]
[2019-10-17T09:43:30,462][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [ingest-common]
[2019-10-17T09:43:30,462][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [lang-expression]
[2019-10-17T09:43:30,462][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [lang-mustache]
[2019-10-17T09:43:30,462][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [lang-painless]
[2019-10-17T09:43:30,462][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [mapper-extras]
[2019-10-17T09:43:30,462][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [parent-join]
[2019-10-17T09:43:30,462][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [percolator]
[2019-10-17T09:43:30,462][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [rank-eval]
[2019-10-17T09:43:30,462][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [reindex]
[2019-10-17T09:43:30,462][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [repository-url]
[2019-10-17T09:43:30,462][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [transport-netty4]
[2019-10-17T09:43:30,462][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [tribe]
[2019-10-17T09:43:30,463][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [x-pack-core]
[2019-10-17T09:43:30,463][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [x-pack-deprecation]
[2019-10-17T09:43:30,463][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [x-pack-graph]
[2019-10-17T09:43:30,463][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [x-pack-logstash]
[2019-10-17T09:43:30,463][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [x-pack-ml]
[2019-10-17T09:43:30,463][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [x-pack-monitoring]
[2019-10-17T09:43:30,463][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [x-pack-rollup]
[2019-10-17T09:43:30,463][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [x-pack-security]
[2019-10-17T09:43:30,463][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [x-pack-sql]
[2019-10-17T09:43:30,463][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [x-pack-upgrade]
[2019-10-17T09:43:30,463][INFO ][o.e.p.PluginsService     ] [uyS3a_p] loaded module [x-pack-watcher]
[2019-10-17T09:43:30,464][INFO ][o.e.p.PluginsService     ] [uyS3a_p] no plugins loaded
[2019-10-17T09:43:33,206][INFO ][o.e.x.s.a.s.FileRolesStore] [uyS3a_p] parsed [0] roles from file [/home/es/elasticsearch-6.4.1/config/roles.yml]
[2019-10-17T09:43:33,554][INFO ][o.e.x.m.j.p.l.CppLogMessageHandler] [controller/24250] [Main.cc@109] controller (64 bit): Version 6.4.1 (Build 1df3104bc26648) Copyright (c) 2018 Elasticsearch BV
[2019-10-17T09:43:33,785][DEBUG][o.e.a.ActionModule       ] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security
[2019-10-17T09:43:33,905][INFO ][o.e.d.DiscoveryModule    ] [uyS3a_p] using discovery type [zen]
[2019-10-17T09:43:34,339][INFO ][o.e.n.Node               ] [uyS3a_p] initialized
[2019-10-17T09:43:34,339][INFO ][o.e.n.Node               ] [uyS3a_p] starting ...
[2019-10-17T09:43:34,476][INFO ][o.e.t.TransportService   ] [uyS3a_p] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2019-10-17T09:43:37,551][INFO ][o.e.c.s.MasterService    ] [uyS3a_p] zen-disco-elected-as-master ([0] nodes joined)[, ], reason: new_master {uyS3a_p}{uyS3a_pATBG5NwZNzfpWJQ}{5saUm0dRTbK0825eT3pO7w}{127.0.0.1}{127.0.0.1:9300}{ml.machine_memory=16358428672, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true}
[2019-10-17T09:43:37,556][INFO ][o.e.c.s.ClusterApplierService] [uyS3a_p] new_master {uyS3a_p}{uyS3a_pATBG5NwZNzfpWJQ}{5saUm0dRTbK0825eT3pO7w}{127.0.0.1}{127.0.0.1:9300}{ml.machine_memory=16358428672, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true}, reason: apply cluster state (from master [master {uyS3a_p}{uyS3a_pATBG5NwZNzfpWJQ}{5saUm0dRTbK0825eT3pO7w}{127.0.0.1}{127.0.0.1:9300}{ml.machine_memory=16358428672, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)[, ]]])
[2019-10-17T09:43:37,569][INFO ][o.e.x.s.t.n.SecurityNetty4HttpServerTransport] [uyS3a_p] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2019-10-17T09:43:37,569][INFO ][o.e.n.Node               ] [uyS3a_p] started
[2019-10-17T09:43:37,583][WARN ][o.e.x.s.a.s.m.NativeRoleMappingStore] [uyS3a_p] Failed to clear cache for realms [[]]
[2019-10-17T09:43:37,612][INFO ][o.e.g.GatewayService     ] [uyS3a_p] recovered [0] indices into cluster_state
[2019-10-17T09:43:37,715][INFO ][o.e.c.m.MetaDataIndexTemplateService] [uyS3a_p] adding template [.watch-history-9] for index patterns [.watcher-history-9*]
[2019-10-17T09:43:37,737][INFO ][o.e.c.m.MetaDataIndexTemplateService] [uyS3a_p] adding template [.triggered_watches] for index patterns [.triggered_watches*]
[2019-10-17T09:43:37,756][INFO ][o.e.c.m.MetaDataIndexTemplateService] [uyS3a_p] adding template [.watches] for index patterns [.watches*]
[2019-10-17T09:43:37,779][INFO ][o.e.c.m.MetaDataIndexTemplateService] [uyS3a_p] adding template [.monitoring-logstash] for index patterns [.monitoring-logstash-6-*]
[2019-10-17T09:43:37,803][INFO ][o.e.c.m.MetaDataIndexTemplateService] [uyS3a_p] adding template [.monitoring-es] for index patterns [.monitoring-es-6-*]
[2019-10-17T09:43:37,827][INFO ][o.e.c.m.MetaDataIndexTemplateService] [uyS3a_p] adding template [.monitoring-beats] for index patterns [.monitoring-beats-6-*]
[2019-10-17T09:43:37,845][INFO ][o.e.c.m.MetaDataIndexTemplateService] [uyS3a_p] adding template [.monitoring-alerts] for index patterns [.monitoring-alerts-6]
[2019-10-17T09:43:37,866][INFO ][o.e.c.m.MetaDataIndexTemplateService] [uyS3a_p] adding template [.monitoring-kibana] for index patterns [.monitoring-kibana-6-*]
[2019-10-17T09:43:37,953][INFO ][o.e.l.LicenseService     ] [uyS3a_p] license [6e085e8f-9539-4f07-acdb-06ec3793e20e] mode [basic] - valid
View Code

 

启动遇到问题1

max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
#原因:无法创建本地文件问题,用户最大可创建文件数太小

需要修改配置文件limits.conf,永久(非暂时性的)改系统的“最大进程数”和“最大文件打开数限制”:

* soft nofile 65536
* hard nofile 65536
* soft nproc 4096
* hard nproc 4096

#切换到root用户
[es@bogon elasticsearch-6.4.1]$ su - root
密码:
上一次登录:四 10月 17 10:15:10 CST 2019pts/1#进入编辑模式
[root@bogon ~]# vim /etc/security/limits.conf

前面的*符号必须带上。

执行完成后可以使用命令 ulimit -n 查看最大进程数,用ulimit -u查看用户最大文件打开数

[root@bogon ~]# ulimit -n
65536
[root@bogon ~]# ulimit -u
4096 

 

启动遇到问题2

ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
#原因:最大虚拟内存太小,需要修改系统变量的最大值。

修改配置sysctl.conf 增加配置值: vm.max_map_count=262144

#注意:需要切换到root用户
#进入编辑模式
[root@bogon ~]# vim /etc/sysctl.conf

执行之后查看

[root@bogon ~]# sysctl -p
vm.max_map_count = 262144

 

启动遇到问题3

max number of threads [1024] for user [es] likely too low, increase to at least [2048]
#原因:无法创建本地线程问题,用户最大可创建线程数太小
需要切换到root用户,进入limits.d目录下,修改90-nproc.conf 或20-nproc.conf配置文件,* soft nproc 1024 改为* soft nproc 2048

但是我的机器不存在这个错误,所以没有作任何修改,查看我的机器信息:
#查看20-nproc.conf文件
[root@bogon ~]# vim  /etc/security/limits.d/20-nproc.conf


#
Default limit for number of user's processes to prevent # accidental fork bombs. # See rhbz #432903 for reasoning. * soft nproc 4096 root soft nproc unlimited

 

启动遇到问题4

system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
#原因:Centos6不支持SecComp,而ES6.4.2默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动。

在es安装目录下的./config/elasticsearch.yml中新增配置bootstrap.system_call_filter,设为false,注意要在Memory下面添加:

bootstrap.memory_lock: false

bootstrap.system_call_filter: false

如果已经启动了服务,重新启动ES服务就可。

我的机器不存在这个错误,所以并没有添加这段配置。

 

调用RESTful API

前面说了,ES提供了简单的RESTful API给应用或客户端调用。默认在9200端口运行,现在打开另一个命令终端,发请求至该端口,会得到以下的jason返回:

[es@bogon elasticsearch-6.3.2]$ curl localhost:9200
{
  "name" : "uyS3a_p",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "mg7654_-T7eUMmtn7RLznQ",
  "version" : {
    "number" : "6.4.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "e36acdb",
    "build_date" : "2018-09-13T22:18:07.696808Z",
    "build_snapshot" : false,
    "lucene_version" : "7.4.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

 一个单节点的elasticsearch就启动成功了!

 

如果想配一个稍个性化的ES服务,还需要对配置文件做一些简单设置,如下。

 

其他ES配置

修改配置文件elasticsearch.yml

#进入ES安装目录
[es@bogon ~]$ cd /home/es/elasticsearch-6.4.1

#备份./config/elasticsearch.yml文件
[es@bogon elasticsearch-6.4.1]$ cp -a config/elasticsearch.yml{,_$(date +%F)}

#查看./config目录内容
[es@bogon elasticsearch-6.4.1]$ ls config
elasticsearch.keystore        jvm.options        roles.yml
elasticsearch.yml             log4j2.properties  users
elasticsearch.yml_2019-10-17  role_mapping.yml   users_roles

#进入编辑模式
[es@bogon elasticsearch-6.4.1]$ vim config/elasticsearch.yml

 

设置集群名称,节点名,数据路径和日志路径;注意格式,所有参数名的冒号的后面都要有个空格!

cluster.name: lsy-application

node.name: node1

path.data: /home/es/elasticsearch-6.4.1/data

path.logs: /home/es/elasticsearch-6.4.1/logs

 

 

重启ES服务

在服务启动窗口,用Ctrl+C关闭服务

可能会遇到的问题

[es@bogon elasticsearch-6.4.1]$ bin/elasticsearch
[2019-10-17T19:09:39,311][INFO ][o.e.n.Node               ] [node1] initializing ...
[2019-10-17T19:09:39,333][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [node1] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: failed to obtain node locks, tried [[/home/es/elasticsearch-6.4.1/data/lsy-application]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:140) ~[elasticsearch-6.4.1.jar:6.4.1]
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) ~[elasticsearch-6.4.1.jar:6.4.1]
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.4.1.jar:6.4.1]
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.4.1.jar:6.4.1]
    at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.4.1.jar:6.4.1]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.4.1.jar:6.4.1]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) ~[elasticsearch-6.4.1.jar:6.4.1]
Caused by: java.lang.IllegalStateException: failed to obtain node locks, tried [[/home/es/elasticsearch-6.4.1/data/lsy-application]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
    at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:243) ~[elasticsearch-6.4.1.jar:6.4.1]
    at org.elasticsearch.node.Node.<init>(Node.java:274) ~[elasticsearch-6.4.1.jar:6.4.1]
    at org.elasticsearch.node.Node.<init>(Node.java:256) ~[elasticsearch-6.4.1.jar:6.4.1]
    at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:213) ~[elasticsearch-6.4.1.jar:6.4.1]
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:213) ~[elasticsearch-6.4.1.jar:6.4.1]
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:326) ~[elasticsearch-6.4.1.jar:6.4.1]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-6.4.1.jar:6.4.1]
    ... 6 more

# 关键字是failed to obtain node locks, 就是绑定节点失败!!!导致的原因可能是因为之前运行的es还没有正常关闭

 

解决方案是杀掉进程

#查看elastic进程,建议在root和es用户下都查一下!
[root@bogon ~]# ps -ef | grep elastic
es       28377     1  1 18:57 ?        00:00:31 /bin/java -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.GVB61OVI -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=data -XX:ErrorFile=logs/hs_err_pid%p.log -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-6.4.1 -Des.path.conf=/home/es/elasticsearch-6.4.1/config -Des.distribution.flavor=default -Des.distribution.type=tar -cp /home/es/elasticsearch-6.4.1/lib/* org.elasticsearch.bootstrap.Elasticsearch -d
es       28402 28377  0 18:57 ?        00:00:00 /home/es/elasticsearch-6.4.1/modules/x-pack-ml/platform/linux-x86_64/bin/controller
root     29676 29628  0 19:26 pts/0    00:00:00 grep --color=auto elastic

#强杀掉进程
[root@bogon ~]# kill -9 28377 28402

 

用es用户登陆,在es安装目录下,可以用 bin/elasticsearch命令重新启动服务,也可以加-d在后台启动

#后台启动服务
[es@bogon ~]$ elasticsearch-6.4.1/bin/elasticsearch -d

#看看ES后台进程是否启起来了
[es@bogon ~]$ ps -ef |grep elastic
es       30281     1 99 19:33 pts/0    00:00:20 /bin/java -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.adpgCFjE -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=data -XX:ErrorFile=logs/hs_err_pid%p.log -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-6.4.1 -Des.path.conf=/home/es/elasticsearch-6.4.1/config -Des.distribution.flavor=default -Des.distribution.type=tar -cp /home/es/elasticsearch-6.4.1/lib/* org.elasticsearch.bootstrap.Elasticsearch -d
es       30306 30281  0 19:33 pts/0    00:00:00 /home/es/elasticsearch-6.4.1/modules/x-pack-ml/platform/linux-x86_64/bin/controller
es       30351 29760  0 19:33 pts/0    00:00:00 grep --color=auto elastic

#发送API请求,注意name和cluster_name已经是我们刚刚自定义的名字了
[es@bogon ~]$ curl localhost:9200
{
  "name" : "node1",
  "cluster_name" : "lsy-application",
  "cluster_uuid" : "mg7654_-T7eUMmtn7RLznQ",
  "version" : {
    "number" : "6.4.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "e36acdb",
    "build_date" : "2018-09-13T22:18:07.696808Z",
    "build_snapshot" : false,
    "lucene_version" : "7.4.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}
#成功!

 

在浏览器输入链接 localhost:9200,也可以看到相同的内容

 

 

 这个url可以查看集群的健康状态: http://localhost:9200/_cluster/health?pretty

 

网络配置network.host

在配置文件 network.host参数默认使用local,这也就是为什么我们在调用API的时候使用的localhost:9200。这个参数接受 ip 地址,主机名,指定值或者包含这些值的数组!节点将绑定到一个主机名或者 ip 地址并且会将该这个节点通知集群中的其他节点。

- 如果想通过集群外部机器连接elasticsearch服务,也就是设置外网访问,需配成 network.host: 0.0.0.0 ,并开通集群硬件防火墙相应端口。

- 如果不需要外网访问的话, 就配置127.0.0.1或者对应的内网ip就行。

#进入编辑模式
[es@bogon ~]$ vim elasticsearch-6.4.1/config/elasticsearch.yml
#-------------------------------------在文件中设置network.host---------------------------------------------- # ---------------------------------- Network ----------------------------------- # # Set the bind address to a specific IP (IPv4 or IPv6): # #network.host: 192.168.0.1 network.host: 192.168.89.66

 

保存之后,重启服务,再调用API,使用192.168.89.66:9200

 
现在,我们已经可以通过ES提供的API来访问服务了,但这些API还不能满足人们多样复杂的需求,比如集群/节点的操作管理,分词工具(搜索依赖的功能),数据库同步工具等。所以大家又开放了很多ES插件,辅助人们完成复杂多样的工作。
 
参考
elasticsearch-head 插件安装 https://www.cnblogs.com/happyliusiyi/p/11684136.html

 

posted @ 2019-10-17 10:00  柳思颐开心的一天  阅读(1202)  评论(0编辑  收藏  举报