linux安装elasticsearch5.5

大家好,我是烤鸭:

我是采用官网下载tar包的方式安装的。

安装环境:centos 7.2,jdk1.8

下载地址:
https://www.elastic.co/downloads/elasticsearch
1.解压缩:
解压 elasticsearch.5.5.2.tar.gz

tar -zxvf  elasticsearch-5.2.2.tar.gz

2.创建用户:
因为Elasticsearch5.0之后,不能使用root账户启动,我们先创建一个elasticsearch组和账户

useradd  elasticsearch -g elasticsearch -p elasticsearch
chown -R elasticsearch:elasticsearch elasticsearch-5.2.2

3.修改配置文件:
贴一下我的elasticsearch.yml配置文件::

# ---------------------------------- 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):
#数据路径(我是在elasticsearch的安装目录下新建了data文件夹)
path.data: /usr/my/elasticsearch/elasticsearch-5.5.2/data
# Path to log files:
#日志路径(我是在elasticsearch的安装目录下新建了logs文件夹)
path.logs: /usr/my/elasticsearch/elasticsearch-5.5.2/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
# 当JVM开始写入交换空间时(swapping)ElasticSearch性能会低下,你应该保证它不会写入交换空间 
# 设置这个属性为true来锁定内存,同时也要允许elasticsearch的进程可以锁住内存,linux下可以通过 `ulimit -l unlimited` 命令 
bootstrap.memory_lock: 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 -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#设置绑定的ip地址,可以是ipv4或ipv6的,默认为0.0.0.0 
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
# 设置对外服务的http端口,默认为9200 
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]"]
#这是一个集群中的主节点的初始列表,当节点(主节点或者数据节点)启动时使用这个列表进行探测 
    ["192.168.0.1(服务器ip):9300"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
# 设置这个参数来保证集群中的节点可以知道其它N个有master资格的节点.默认为1,对于大的集群来说,可以设置大一点的值(2-4) 
discovery.zen.minimum_master_nodes: 1
#
# 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
#开启跨域访问支持,默认为false
http.cors.enabled: true
#跨域访问允许的域名地址,以上使用正则,(域名这里我替换了IP /http?:\/\/192.168.10.139(:[0-9]+)?/)
http.cors.allow-origin: "*"
4.启动
可以前台启动或者后台启动,进入elasticsearch目录
前台启动:

./bin/elasticsearch
后台启动:(个人喜欢后台启动,启动失败可以logs下查看日志方便)

./bin/elasticsearch -d
按照以上配置,我的是可以正常启动的。

另外说一下,防火墙,阿里云是有安全组配置的,如果不在安全组开放端口的话,服务器关闭防火墙也是没用的。
贴一下centos 7.2,7.3关闭防火墙的命令:
关闭防火墙:

systemctl stop firewalld.service

关闭防火墙开机自启动功能:

systemctl disable firewalld.service

出现以下命令,就启动成功了:

[2017-09-20T10:36:10,400][INFO ][o.e.e.NodeEnvironment    ] [node-1] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [29.9gb], net total_space [39.2gb], spins? [unknown], types [rootfs]
[2017-09-20T10:36:10,401][INFO ][o.e.e.NodeEnvironment    ] [node-1] heap size [495.3mb], compressed ordinary object pointers [true]
[2017-09-20T10:36:10,401][INFO ][o.e.n.Node               ] [node-1] node name [node-1], node ID [uoi6ZmIbSNGu6xaol_OCpw]
[2017-09-20T10:36:10,402][INFO ][o.e.n.Node               ] [node-1] version[5.5.2], pid[9979], build[b2f0c09/2017-08-14T12:33:14.154Z], OS[Linux/3.10.0-514.26.2.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_144/25.144-b01]
[2017-09-20T10:36:10,402][INFO ][o.e.n.Node               ] [node-1] JVM arguments [-Xms512m, -Xmx512m, -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/my/elasticsearch/elasticsearch-5.5.2]
[2017-09-20T10:36:11,174][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [aggs-matrix-stats]
[2017-09-20T10:36:11,174][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [ingest-common]
[2017-09-20T10:36:11,174][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-expression]
[2017-09-20T10:36:11,174][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-groovy]
[2017-09-20T10:36:11,174][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-mustache]
[2017-09-20T10:36:11,174][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [lang-painless]
[2017-09-20T10:36:11,174][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [parent-join]
[2017-09-20T10:36:11,174][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [percolator]
[2017-09-20T10:36:11,174][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [reindex]
[2017-09-20T10:36:11,175][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [transport-netty3]
[2017-09-20T10:36:11,175][INFO ][o.e.p.PluginsService     ] [node-1] loaded module [transport-netty4]
[2017-09-20T10:36:11,175][INFO ][o.e.p.PluginsService     ] [node-1] no plugins loaded
[2017-09-20T10:36:12,770][INFO ][o.e.d.DiscoveryModule    ] [node-1] using discovery type [zen]
[2017-09-20T10:36:13,234][INFO ][o.e.n.Node               ] [node-1] initialized
[2017-09-20T10:36:13,235][INFO ][o.e.n.Node               ] [node-1] starting ...
[2017-09-20T10:36:13,389][INFO ][o.e.t.TransportService   ] [node-1] publish_address {172.17.214.191:9300}, bound_addresses {0.0.0.0:9300}
[2017-09-20T10:36:13,398][INFO ][o.e.b.BootstrapChecks    ] [node-1] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
[2017-09-20T10:36:16,446][INFO ][o.e.c.s.ClusterService   ] [node-1] new_master {node-1}{uoi6ZmIbSNGu6xaol_OCpw}{kGPZi3xEREuq_Nb-s5yEKQ}{172.17.214.191}{172.17.214.191:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2017-09-20T10:36:16,469][INFO ][o.e.g.GatewayService     ] [node-1] recovered [0] indices into cluster_state
[2017-09-20T10:36:16,469][INFO ][o.e.h.n.Netty4HttpServerTransport] [node-1] publish_address {172.17.214.191:9200}, bound_addresses {0.0.0.0:9200}
[2017-09-20T10:36:16,469][INFO ][o.e.n.Node               ] [node-1] started

访问成功:


关于之前遇到的坑,也记录一下:


1、Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)


修改elasticsearch目录中config/jvm.options
vim config/jvm.options
将原来的:

-Xms2g  
-Xmx2g 
修改为:
-Xms512m
-Xmx512m
2、max number of threads [1024] for user [elasticsearch] is too low, increase to at least [2048]
修改 /etc/security/limits.d/90-nproc.conf 
*          soft    nproc     1024
*          soft    nproc     2048
3、max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
修改/etc/sysctl.conf配置文件,

cat /etc/sysctl.conf | grep vm.max_map_count
vm.max_map_count=262144
如果不存在则添加

echo "vm.max_map_count=262144" >>/etc/sysctl.conf
4.uncaught exception in thread [main]

org.elasticsearch.bootstrap.StartupException: BindTransportException[Failed to bind to [9300-9400]]; nested: BindException[Cannot assign requested address];


修改elasticsearch下的config/elasticsearch.yml
这里的network.host原本写的是服务器ip地址,
改成

network.host: 0.0.0.0
也有的说是,之前生成的结点数据没有清除,
找到配置文件中的配置的结点目录(path.data: /usr/my/elasticsearch/elasticsearch-5.5.2/dat)

清空原来的内容


5.[1] bootstrap checks failed
[1]: memory locking requested for elasticsearch process but memory is not locked
修改elasticsearch下的config/elasticsearch.yml
修改bootstrap.memory_lock:true

bootstrap.memory_lock: false



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

烤鸭的世界我们不懂

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值