iiiiiielastic我爱编程

linux 安装 Elasticsearch5.6.x 详细步骤

2018-04-14  本文已影响26人  it_zzy

linux安装Elasticsearch5.6.X详细步骤

第一步:环境

linux 系统 Java 1.8.0_151 elasticsearch-5.6.8

第二步:下载安装

image.png image.png

后台启动es命令:./bin/elasticsearch -d
可以看到es在后台启动了


image.png

第四步:问题

第五步:安装head插件

image.png
执行完成后,可以使用命令 node -v 验证是否安装成功,同时npm 也安装成功了;执行命令 npm -v 也是可以验证的。
image.png image.png
- 修改 vim _site/app.js 文件,修改head的连接地址,如图所示:
image.png
- 最后一个命令: grunt server &  执行完成后就OK了。

- 涉及到的问题,在网页上无法正常访问;查看防火墙是否关闭
  执行命令service iptables status 查看状态 ;直接将防火墙关闭就好了 执行命令service iptables stop。
image.png
- 最后执行的结果是这样的,我没有配置集群: 注意下面使用的端口号,不在是9200 了 而是head 插件中的 9100 了。
image.png
- 看到上面的出现的健康值了吗,说明的连接还是有问题的,解决方案是修改 cd 命令进入到elasticsearch-5.6.3 /config 文件中 vi elasticsearch.yml
     文件下添加 :
    http.cors.enabled: true
    http.cors.allow-origin: "*"

然后重新执行ES ./elasticsearch 成功起来就可以了,执行结果就是这样的


- 未写入数据前:
head head

ES集群安装遇到的问题

报错:

root@hue:~/elasticsearch-5.6.8/bin# [2018-04-03T16:28:51,641][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [master1] 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:136) ~[elasticsearch-5.6.8.jar:5.6.8]

 at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) ~[elasticsearch-5.6.8.jar:5.6.8]

 at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:70) ~[elasticsearch-5.6.8.jar:5.6.8]

 at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) ~[elasticsearch-5.6.8.jar:5.6.8]

 at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-5.6.8.jar:5.6.8]

 at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[elasticsearch-5.6.8.jar:5.6.8]

 at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[elasticsearch-5.6.8.jar:5.6.8]

Caused by: java.lang.RuntimeException: can not run elasticsearch as root

 at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[elasticsearch-5.6.8.jar:5.6.8]

 at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:195) ~[elasticsearch-5.6.8.jar:5.6.8]

 at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) ~[elasticsearch-5.6.8.jar:5.6.8]

 at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) ~[elasticsearch-5.6.8.jar:5.6.8]

... 6 more
image.png

切换到es用户

注意将data目录的用户和用户组设置为es

image.png

Master启动日志如下:

es@hue:/usr/local/es/elasticsearch-5.6.8/bin$ ./elasticsearch &
[1] 25086
es@hue:/usr/local/es/elasticsearch-5.6.8/bin$ [2018-04-03T17:44:54,347][INFO ][o.e.n.Node               ] [master1] initializing ...
[2018-04-03T17:44:54,552][INFO ][o.e.e.NodeEnvironment    ] [master1] using [1] data paths, mounts [[/ (/dev/vda1)]], net usable_space [28.2gb], net total_space [39.2gb], spins? [possibly], types [ext4]
[2018-04-03T17:44:54,553][INFO ][o.e.e.NodeEnvironment    ] [master1] heap size [1.9gb], compressed ordinary object pointers [true]
[2018-04-03T17:44:54,554][INFO ][o.e.n.Node               ] [master1] node name [master1], node ID [T73gSpfdTS-34qIYEwFPYA]
[2018-04-03T17:44:54,554][INFO ][o.e.n.Node               ] [master1] version[5.6.8], pid[25086], build[688ecce/2018-02-16T16:46:30.010Z], OS[Linux/4.4.0-62-generic/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_151/25.151-b12]
[2018-04-03T17:44:54,555][INFO ][o.e.n.Node               ] [master1] JVM arguments [-Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Djdk.io.permissionsUseCanonicalPath=true, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j.skipJansi=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/usr/local/es/elasticsearch-5.6.8]
[2018-04-03T17:44:55,482][INFO ][o.e.p.PluginsService     ] [master1] loaded module [aggs-matrix-stats]
[2018-04-03T17:44:55,482][INFO ][o.e.p.PluginsService     ] [master1] loaded module [ingest-common]
[2018-04-03T17:44:55,483][INFO ][o.e.p.PluginsService     ] [master1] loaded module [lang-expression]
[2018-04-03T17:44:55,483][INFO ][o.e.p.PluginsService     ] [master1] loaded module [lang-groovy]
[2018-04-03T17:44:55,483][INFO ][o.e.p.PluginsService     ] [master1] loaded module [lang-mustache]
[2018-04-03T17:44:55,483][INFO ][o.e.p.PluginsService     ] [master1] loaded module [lang-painless]
[2018-04-03T17:44:55,483][INFO ][o.e.p.PluginsService     ] [master1] loaded module [parent-join]
[2018-04-03T17:44:55,483][INFO ][o.e.p.PluginsService     ] [master1] loaded module [percolator]
[2018-04-03T17:44:55,483][INFO ][o.e.p.PluginsService     ] [master1] loaded module [reindex]
[2018-04-03T17:44:55,484][INFO ][o.e.p.PluginsService     ] [master1] loaded module [transport-netty3]
[2018-04-03T17:44:55,484][INFO ][o.e.p.PluginsService     ] [master1] loaded module [transport-netty4]
[2018-04-03T17:44:55,484][INFO ][o.e.p.PluginsService     ] [master1] no plugins loaded
[2018-04-03T17:44:56,800][INFO ][o.e.d.DiscoveryModule    ] [master1] using discovery type [zen]
[2018-04-03T17:44:57,287][INFO ][o.e.n.Node               ] [master1] initialized
[2018-04-03T17:44:57,288][INFO ][o.e.n.Node               ] [master1] starting ...
[2018-04-03T17:44:57,592][INFO ][o.e.t.TransportService   ] [master1] publish_address {10.1.72.136:9300}, bound_addresses {10.1.72.136:9300}
[2018-04-03T17:44:57,605][INFO ][o.e.b.BootstrapChecks    ] [master1] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2018-04-03T17:45:00,686][INFO ][o.e.c.s.ClusterService   ] [master1] new_master {master1}{T73gSpfdTS-34qIYEwFPYA}{ofDnSPHlSfe8kLZZx4NCaQ}{10.1.72.136}{10.1.72.136:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2018-04-03T17:45:00,745][INFO ][o.e.h.n.Netty4HttpServerTransport] [master1] publish_address {10.1.72.136:9200}, bound_addresses {10.1.72.136:9200}
[2018-04-03T17:45:00,746][INFO ][o.e.n.Node               ] [master1] started
[2018-04-03T17:45:00,765][INFO ][o.e.g.GatewayService     ] [master1] recovered [0] indices into cluster_state

访问master:

image.png

注意要启动slave!!!


image.png

可以看到slave节点也启动了


data1

附es配置文件:

# ======================== 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: bingo-es
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
node.name: master1
node.master: true
node.data: true
# 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: /usr/local/data/es/data
# Path to log files:
#
#path.logs: /path/to/logs
path.logs: /usr/local/data/es/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# 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: host1
#
# Set a custom port for HTTP:
http.port: 9200

discovery.zen.ping.unicast.hosts: ["host1","host2"]
discovery.zen.minimum_master_nodes: 2

#head
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type

bootstrap.memory_lock: false
bootstrap.system_call_filter: false
#
#xpack.security.enabled: false
#xpack.reporting.enabled: false
#xpack.monitoring.enabled: false

#xpack.monitoring.exporters.auth.username: "elastic"
#xpack.monitoring.exporters.auth.password: "changeme"
#xpack.security.audit.enabled: true

#action.auto_create_index: .security,.monitoring*,.watches,.triggered_watches,.watcher-history*

#elasticsearch.username: "elastic"
#elasticsearch.password: "changeme"
# Set a custom port for HTTP:
#
#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: 3
#
# 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
# ======================== 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: bingo-es
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
node.name: data1
#node.master: false
node.master: true
node.data: true
#
# 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: /usr/local/data/es/data
# Path to log files:
#
#path.logs: /path/to/logs
path.logs: /usr/local/data/es/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# 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: host2
# Set a custom port for HTTP:
#
#http.port: 9200
http.port: 9200

discovery.zen.ping.unicast.hosts: ["host1","host2"]
discovery.zen.minimum_master_nodes: 2
#discovery.zen.ping.multicast.enabled: false
#
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type

bootstrap.memory_lock: false
bootstrap.system_call_filter: false
#
#xpack.security.enabled: false
#xpack.reporting.enabled: false
#xpack.monitoring.enabled: false
#action.auto_create_index: .security,.monitoring*,.watches,.triggered_watches,.watcher-history*
#xpack.monitoring.elasticsearch.username: "elastic"
#xpack.monitoring.elasticsearch.password: "changeme"


#elsticsearch.username: "elastic"
#elasticsearch.password: "changeme"

#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: 3
#
# 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
上一篇 下一篇

猜你喜欢

热点阅读