本篇博客的主要目的是介绍ES单机版的安装方式。
elasticsearch-5.4.3.tar.gz 百度云地址链接:https://pan.baidu.com/s/1z9yA2Ai34ZqiteMMifgx-A 提取码:y2zn
官网地址:https://www.elastic.co/cn/downloads/?elektra=home&storm=hero
a、tar开文件到指定的目录下面(创建软连接)
tar -zxvf elasticsearch-5.4.3.tar.gz -C /usr/local/software/
b、修改配置文件
修改/usr/local/software/elasticsearch-5.4.3/config/elasticsearch.yml:
path.data: /usr/local/software/elasticsearch/data # ES数据的存放路径
path.logs: /usr/local/software/elasticsearch/logs # ES日志的存放路径
network.host: 192.168.140.101 # 当前节点绑定的IP地址
c、创建用于存放数据与日志的目录
[root@s101 /usr/local/software/elasticsearch/config]#mkdir -p /usr/local/software/elasticsearch/data
[root@s101 /usr/local/software/elasticsearch/config]#mkdir -p /usr/local/software/elasticsearch/logs
d、创建ES运行用户并修改ES目录权限
useradd es
更改用户密码(输入 123123) passwd es
修改ES目录权限
chown -R es:es /usr/local/software/elasticsearch/
chown -R es:es /usr/local/software/elasticsearch/data/
chown -R es:es /usr/local/software/elasticsearch/logs/
e、启动es服务
[es@s101 /usr/local/software/elasticsearch-5.4.3]$bin/elasticsearch
[2021-03-13T22:10:16,712][INFO ][o.e.n.Node ] [] initializing …
[2021-03-13T22:10:16,807][INFO ][o.e.e.NodeEnvironment ] [D2mKD6R] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [5.6gb], net total_space [17.6gb], spins? [unknown], types [rootfs]
[2021-03-13T22:10:16,807][INFO ][o.e.e.NodeEnvironment ] [D2mKD6R] heap size [1.9gb], compressed ordinary object pointers [true]
[2021-03-13T22:10:16,808][INFO ][o.e.n.Node ] node name [D2mKD6R] derived from node ID [D2mKD6R-TsWntugnCbzXiA]; set [node.name] to override
[2021-03-13T22:10:16,808][INFO ][o.e.n.Node ] version[5.4.3], pid[4750], build[eed30a8/2017-06-22T00:34:03.743Z], OS[Linux/3.10.0-327.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot™ 64-Bit Server VM/1.8.0_65/25.65-b01]
[2021-03-13T22:10:16,809][INFO ][o.e.n.Node ] JVM arguments [-Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+DisableExplicitGC, -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/software/elasticsearch-5.4.3]
[2021-03-13T22:10:18,319][INFO ][o.e.p.PluginsService ] [D2mKD6R] loaded module [aggs-matrix-stats]
[2021-03-13T22:10:18,319][INFO ][o.e.p.PluginsService ] [D2mKD6R] loaded module [ingest-common]
[2021-03-13T22:10:18,320][INFO ][o.e.p.PluginsService ] [D2mKD6R] loaded module [lang-expression]
[2021-03-13T22:10:18,320][INFO ][o.e.p.PluginsService ] [D2mKD6R] loaded module [lang-groovy]
[2021-03-13T22:10:18,320][INFO ][o.e.p.PluginsService ] [D2mKD6R] loaded module [lang-mustache]
[2021-03-13T22:10:18,320][INFO ][o.e.p.PluginsService ] [D2mKD6R] loaded module [lang-painless]
[2021-03-13T22:10:18,320][INFO ][o.e.p.PluginsService ] [D2mKD6R] loaded module [percolator]
[2021-03-13T22:10:18,320][INFO ][o.e.p.PluginsService ] [D2mKD6R] loaded module [reindex]
[2021-03-13T22:10:18,320][INFO ][o.e.p.PluginsService ] [D2mKD6R] loaded module [transport-netty3]
[2021-03-13T22:10:18,320][INFO ][o.e.p.PluginsService ] [D2mKD6R] loaded module [transport-netty4]
[2021-03-13T22:10:18,320][INFO ][o.e.p.PluginsService ] [D2mKD6R] no plugins loaded
[2021-03-13T22:10:20,581][INFO ][o.e.d.DiscoveryModule ] [D2mKD6R] using discovery type [zen]
[2021-03-13T22:10:21,170][INFO ][o.e.n.Node ] initialized
[2021-03-13T22:10:21,171][INFO ][o.e.n.Node ] [D2mKD6R] starting …
[2021-03-13T22:10:21,491][INFO ][o.e.t.TransportService ] [D2mKD6R] publish_address {192.168.140.101:9300}, bound_addresses {192.168.140.101:9300}
[2021-03-13T22:10:21,495][INFO ][o.e.b.BootstrapChecks ] [D2mKD6R] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
[2021-03-13T22:10:24,595][INFO ][o.e.c.s.ClusterService ] [D2mKD6R] new_master {D2mKD6R}{D2mKD6R-TsWntugnCbzXiA}{C3yCAcZtRJ6pP8YseBdfjQ}{192.168.140.101}{192.168.140.101:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2021-03-13T22:10:24,658][INFO ][o.e.h.n.Netty4HttpServerTransport] [D2mKD6R] publish_address {192.168.140.101:9200}, bound_addresses {192.168.140.101:9200}
[2021-03-13T22:10:24,661][INFO ][o.e.n.Node ] [D2mKD6R] started
[2021-03-13T22:10:24,665][INFO ][o.e.g.GatewayService ] [D2mKD6R] recovered [0] indices into cluster_state
需要说明的是,如果你在第d步骤当中遇到了下面的错误:
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
第一:vim /etc/security/limits.conf修改用户最大可创建文件数,在文件的末尾添加:
soft nofile 65536hard nofile 65536
验证:ulimit -Hn查看可打开文件数量
[root@s101 /usr/local/software/elasticsearch-5.4.3]#ulimit -Hn
65536
第二:vim /etc/sysctl.conf修改最大虚拟内存大小,在文件的末尾添加:
vm.max_map_count=262144
验证:sysctl -p查看虚拟内存的大小
[root@s101 /usr/local/software/elasticsearch-5.4.3]#sysctl -p
vm.max_map_count = 262144
f、验证es服务是否启动正常
方法1:
[root@s101 /root]#curl ‘http://192.168.140.101:9200/?pretty’
{
“name” : “D2mKD6R”,
“cluster_name” : “elasticsearch”,
“cluster_uuid” : “B_q-WAhpRZqaC0dHr8VuJg”,
“version” : {
“number” : “5.4.3”,
“build_hash” : “eed30a8”,
“build_date” : “2017-06-22T00:34:03.743Z”,
“build_snapshot” : false,
“lucene_version” : “6.5.1”
},
“tagline” : “You Know, for Search”
}
方法2:在浏览器输入http://192.168.140.101:9200 查看: