centos6.5 安装Elasticsearch及可视化插件head

1.确认jdk版本,1.8以上


如果没有安装jdk,则下载jdk二进制安装包,解压到/usr/local/java/目录
image
配置环境变量

vi /etc/profile

在末尾追加(注意将JAVA_HOME后的路径改为你解压后的jdk的目录)

export JAVA_HOME=/usr/local/java/jdk1.8.0_181
export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

修改完后文件生效

source  /etc/profile

查看是否配置成功
image

2.根据系统下载es Kibana

image

3.解压到/usr/local/目录

image

4.创建es用户组及es用户并设置es用户密码

groupadd es
useradd es -g es
passwd es

更改es文件夹及内部文件的所属用户及组为es:es(在elasticsearch根目录执行此命令)

chown -R es:es /usr/local/elasticsearch-7.13.2

5.配置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
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#
# 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 to log files:
#
#path.logs: /path/to/logs
#
# ----------------------------------- 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 -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
#network.host: 192.168.0.1
network.host: 10.202.205.30
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["node-1"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true

启动报:max number of threads [1024] for user [es] is too low, increase to at least [4096] 错误
配置 /etc/security/limits.d/90-nproc.conf 文件(注:重启无效再添加 * hard nproc 4096)
image

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] 错误
在/etc/sysctl.conf文件最后添加一行
vm.max_map_count=262144
image
执行/sbin/sysctl -p 立即生效

max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535] 错误
在/etc/security/limits.conf倒数第二行添加

* soft nofile 65536
* hard nofile 65536

image

6.重启 正常

[es@document bin]$ ./elasticsearch
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
Future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/java/jdk1.8.0_181/jre] does not meet this requirement. Consider switching to a distribution of Elasticsearch with a bundled JDK. If you are already using a distribution with a bundled JDK, ensure the JAVA_HOME environment variable is not set.
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
Future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/java/jdk1.8.0_181/jre] does not meet this requirement. Consider switching to a distribution of Elasticsearch with a bundled JDK. If you are already using a distribution with a bundled JDK, ensure the JAVA_HOME environment variable is not set.
Java HotSpot(TM) 64-Bit Server VM warning: Cannot open file logs/gc.log due to Permission denied

[2021-06-16T18:58:46,100][INFO ][o.e.n.Node               ] [node-1] version[7.13.2], pid[2859], build[default/tar/4d960a0733be83dd2543ca018aa4ddc42e956800/2021-06-10T21:01:55.251515791Z], OS[Linux/2.6.32-504.el6.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_181/25.181-b13]
[2021-06-16T18:58:46,115][INFO ][o.e.n.Node               ] [node-1] JVM home [/usr/local/java/jdk1.8.0_181/jre], using bundled JDK [false]
[2021-06-16T18:58:46,115][INFO ][o.e.n.Node               ] [node-1] JVM arguments [-Xshare:auto, -Des.networkaddress.cache.ttl=60, -Des.networkaddress.cache.negative.ttl=10, -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, -Dio.netty.allocator.numDirectArenas=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.locale.providers=SPI,JRE, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -Djava.io.tmpdir=/tmp/elasticsearch-4333734367761419365, -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, -Xms1024m, -Xmx1024m, -XX:MaxDirectMemorySize=536870912, -Des.path.home=/usr/local/elasticsearch-7.13.2, -Des.path.conf=/usr/local/elasticsearch-7.13.2/config, -Des.distribution.flavor=default, -Des.distribution.type=tar, -Des.bundled_jdk=true]
[2021-06-16T18:58:50,666][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [aggs-matrix-stats]
[2021-06-16T18:58:50,667][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [analysis-common]
[2021-06-16T18:58:50,667][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [constant-keyword]
[2021-06-16T18:58:50,667][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [frozen-indices]
[2021-06-16T18:58:50,667][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [ingest-common]
[2021-06-16T18:58:50,667][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [ingest-geoip]
[2021-06-16T18:58:50,668][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [ingest-user-agent]
[2021-06-16T18:58:50,668][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [kibana]
[2021-06-16T18:58:50,668][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-expression]
[2021-06-16T18:58:50,668][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-mustache]
[2021-06-16T18:58:50,669][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-painless]
[2021-06-16T18:58:50,669][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [mapper-extras]
[2021-06-16T18:58:50,669][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [mapper-version]
[2021-06-16T18:58:50,669][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [parent-join]
[2021-06-16T18:58:50,669][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [percolator]
[2021-06-16T18:58:50,670][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [rank-eval]
[2021-06-16T18:58:50,670][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [reindex]
[2021-06-16T18:58:50,670][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [repositories-metering-api]
[2021-06-16T18:58:50,670][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [repository-encrypted]
[2021-06-16T18:58:50,670][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [repository-url]
[2021-06-16T18:58:50,671][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [runtime-fields-common]
[2021-06-16T18:58:50,671][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [search-business-rules]
[2021-06-16T18:58:50,671][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [searchable-snapshots]
[2021-06-16T18:58:50,671][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [snapshot-repo-test-kit]
[2021-06-16T18:58:50,671][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [spatial]
[2021-06-16T18:58:50,672][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [transform]
[2021-06-16T18:58:50,672][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [transport-netty4]
[2021-06-16T18:58:50,672][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [unsigned-long]
[2021-06-16T18:58:50,672][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [vectors]
[2021-06-16T18:58:50,672][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [wildcard]
[2021-06-16T18:58:50,673][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-aggregate-metric]
[2021-06-16T18:58:50,673][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-analytics]
[2021-06-16T18:58:50,673][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-async]
[2021-06-16T18:58:50,673][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-async-search]
[2021-06-16T18:58:50,673][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-autoscaling]
[2021-06-16T18:58:50,674][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-ccr]
[2021-06-16T18:58:50,674][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-core]
[2021-06-16T18:58:50,674][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-data-streams]
[2021-06-16T18:58:50,674][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-deprecation]
[2021-06-16T18:58:50,674][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-enrich]
[2021-06-16T18:58:50,675][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-eql]
[2021-06-16T18:58:50,675][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-fleet]
[2021-06-16T18:58:50,675][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-graph]
[2021-06-16T18:58:50,675][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-identity-provider]
[2021-06-16T18:58:50,676][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-ilm]
[2021-06-16T18:58:50,676][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-logstash]
[2021-06-16T18:58:50,676][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-ml]
[2021-06-16T18:58:50,676][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-monitoring]
[2021-06-16T18:58:50,676][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-ql]
[2021-06-16T18:58:50,676][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-rollup]
[2021-06-16T18:58:50,677][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-security]
[2021-06-16T18:58:50,677][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-shutdown]
[2021-06-16T18:58:50,677][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-sql]
[2021-06-16T18:58:50,677][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-stack]
[2021-06-16T18:58:50,677][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-text-structure]
[2021-06-16T18:58:50,678][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-voting-only-node]
[2021-06-16T18:58:50,678][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [x-pack-watcher]
[2021-06-16T18:58:50,678][INFO ][o.e.p.PluginsService     ] [node-1] no plugins loaded
[2021-06-16T18:58:50,724][INFO ][o.e.e.NodeEnvironment    ] [node-1] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [44.5gb], net total_space [49gb], types [rootfs]
[2021-06-16T18:58:50,725][INFO ][o.e.e.NodeEnvironment    ] [node-1] heap size [989.8mb], compressed ordinary object pointers [true]
[2021-06-16T18:58:50,848][INFO ][o.e.n.Node               ] [node-1] node name [node-1], node ID [KDMYprjcSFWrSXLn8NYGvg], cluster name [elasticsearch], roles [transform, data_frozen, master, remote_cluster_client, data, ml, data_content, data_hot, data_warm, data_cold, ingest]
[2021-06-16T18:58:56,366][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [node-1] [controller/3294] [Main.cc@117] controller (64 bit): Version 7.13.2 (Build 4d6c6f14d75f39) Copyright (c) 2021 Elasticsearch BV
[2021-06-16T18:58:57,013][INFO ][o.e.x.s.a.s.FileRolesStore] [node-1] parsed [0] roles from file [/usr/local/elasticsearch-7.13.2/config/roles.yml]
[2021-06-16T18:58:57,928][INFO ][o.e.i.g.LocalDatabases   ] [node-1] initialized default databases [[GeoLite2-Country.mmdb, GeoLite2-City.mmdb, GeoLite2-ASN.mmdb]], config databases [[]] and watching [/usr/local/elasticsearch-7.13.2/config/ingest-geoip] for changes
[2021-06-16T18:58:57,929][INFO ][o.e.i.g.DatabaseRegistry ] [node-1] initialized database registry, using geoip-databases directory [/tmp/elasticsearch-4333734367761419365/geoip-databases/KDMYprjcSFWrSXLn8NYGvg]
[2021-06-16T18:58:58,890][INFO ][o.e.t.NettyAllocator     ] [node-1] creating NettyAllocator with the following configs: [name=unpooled, suggested_max_allocation_size=1mb, factors={es.unsafe.use_unpooled_allocator=null, g1gc_enabled=false, g1gc_region_size=0b, heap_size=989.8mb}]
[2021-06-16T18:58:58,987][INFO ][o.e.d.DiscoveryModule    ] [node-1] using discovery type [zen] and seed hosts providers [settings]
[2021-06-16T18:58:59,676][INFO ][o.e.g.DanglingIndicesState] [node-1] gateway.auto_import_dangling_indices is disabled, dangling indices will not be automatically detected or imported and must be managed manually
[2021-06-16T18:59:00,353][INFO ][o.e.n.Node               ] [node-1] initialized
[2021-06-16T18:59:00,354][INFO ][o.e.n.Node               ] [node-1] starting ...
[2021-06-16T18:59:00,377][INFO ][o.e.x.s.c.f.PersistentCache] [node-1] persistent cache index loaded
[2021-06-16T18:59:00,535][INFO ][o.e.t.TransportService   ] [node-1] publish_address {10.202.205.30:9300}, bound_addresses {10.202.205.30:9300}
[2021-06-16T18:59:00,764][INFO ][o.e.b.BootstrapChecks    ] [node-1] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2021-06-16T18:59:00,808][INFO ][o.e.c.c.Coordinator      ] [node-1] cluster UUID [-iRToHRdQX6KmtfwBjAXIw]
[2021-06-16T18:59:00,987][INFO ][o.e.c.s.MasterService    ] [node-1] elected-as-master ([1] nodes joined)[{node-1}{KDMYprjcSFWrSXLn8NYGvg}{tHdr9XVsT4yjxligw2057Q}{10.202.205.30}{10.202.205.30:9300}{cdfhilmrstw} elect leader, _BECOME_MASTER_TASK_, _FINISH_ELECTION_], term: 2, version: 36, delta: master node changed {previous [], current [{node-1}{KDMYprjcSFWrSXLn8NYGvg}{tHdr9XVsT4yjxligw2057Q}{10.202.205.30}{10.202.205.30:9300}{cdfhilmrstw}]}
[2021-06-16T18:59:01,075][INFO ][o.e.c.s.ClusterApplierService] [node-1] master node changed {previous [], current [{node-1}{KDMYprjcSFWrSXLn8NYGvg}{tHdr9XVsT4yjxligw2057Q}{10.202.205.30}{10.202.205.30:9300}{cdfhilmrstw}]}, term: 2, version: 36, reason: Publication{term=2, version=36}
[2021-06-16T18:59:01,154][INFO ][o.e.h.AbstractHttpServerTransport] [node-1] publish_address {10.202.205.30:9200}, bound_addresses {10.202.205.30:9200}
[2021-06-16T18:59:01,154][INFO ][o.e.n.Node               ] [node-1] started
[2021-06-16T18:59:01,489][INFO ][o.e.l.LicenseService     ] [node-1] license [0c80b30b-f4b1-4f73-9b71-5a1ebff5d77c] mode [basic] - valid
[2021-06-16T18:59:01,491][INFO ][o.e.x.s.s.SecurityStatusChangeListener] [node-1] Active license is now [BASIC]; Security is disabled
[2021-06-16T18:59:01,492][WARN ][o.e.x.s.s.SecurityStatusChangeListener] [node-1] Elasticsearch built-in security features are not enabled. Without authentication, your cluster could be accessible to anyone. See https://www.elastic.co/guide/en/elasticsearch/reference/7.13/security-minimal-setup.html to enable security.
[2021-06-16T18:59:01,498][INFO ][o.e.g.GatewayService     ] [node-1] recovered [0] indices into cluster_state

image

7.安装head

下载zip(注:提前安装好nodejs、grunt centos6.6 安装nodejs和npm
nodejs安装依赖参考:GLIBCXX_3.4.18 glibc-2.17
image
解压到es安装目录下的plugins文件夹下,重命名为head
image
重启es,org.elasticsearch.bootstrap.StartupException: java.lang.IllegalArgumentException: property [elasticsearch.version] is missing for plugin [head] 错误
原因:elasticsearch新版本是不允许安装插件在文件目录plugins下面的
解决:将plugins下面的插件目录放到其他目录即可
image
重启es问题解决

7.1安装head插件,进入head目录
执行 npm install

image
启动head插件服务:

npm run start

image
image

7.2解决跨域问题

编辑elasticsearch.yml文件,追加:

http.cors.enabled: true
http.cors.allow-origin: "*"

image

8.先启es、再启head

image

posted @ 2021-06-16 14:56  语海  阅读(225)  评论(0)    收藏  举报