Linux安装Elasticsearch(内含es/kibana历史版本下载地址)

1、Elasticsearch下载命令:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.1.tar.gz

es版本最好和kibana版本一致
es历史版本地址: https://www.elastic.co/cn/downloads/past-releases#elasticsearch
kibana历史版本地址: https://www.elastic.co/cn/downloads/past-releases#kibana

2、解压elasticsearch-6.6.1.tar.gz到/usr/local/目录:

tar -avxf elasticsearch-6.6.1.tar.gz -C /usr/local/

3、进入解压后的elasticsearch目录:

1)新建data、logs目录:

mkdir data
mkdir logs

2)修改config/elasticsearch.yml:

vim config/elasticsearch.yml

取消下列项注释并修改:

cluster.name: my-application #集群名称
node.name: node-1 #节点名称
#数据和日志的存储目录
path.data: /usr/local/elasticsearch-6.6.1/data
path.logs: /usr/local/elasticsearch-6.6.1/logs
#设置绑定的ip,设置为0.0.0.0以后就可以让任何计算机节点访问到了
network.host: 0.0.0.0
http.port: 9200 #端口
#设置在集群中的所有节点名称,这个节点名称就是之前所修改的,当然你也可以采用默认的也行,目前是单机,放入一个节点即可
cluster.initial_master_nodes: ["node-1"]

修改完毕后,:wq 保存退出vim

4、准备启动es

进入/bin目录执行命令:

./elasticsearch

我这里出现如下错误:

Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c5330000, 986513408, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 986513408 bytes for committing reserved memory.
# An error report file with more information is saved as:
# logs/hs_err_pid22863.log
[root@VM_0_2_centos bin]# 

看来是我这1G的内存太小了啊,elasticsearch使用java的jvm默认是使用1G的内存的,这里我们修改一下内存,直接把内存改到200m
cd 到es目录修改 ./config/jvm.options:

vim ./config/jvm.options 

修改内容:

-Xms200m
-Xmx200m

:wq 保存并退出vim,再次启动es

再次启动出现如下错误:

[2019-06-21T16:20:03,039][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-1] 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:163) ~[elasticsearch-6.6.1.jar:6.6.1]
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-6.6.1.jar:6.6.1]
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.6.1.jar:6.6.1]
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.6.1.jar:6.6.1]
    at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.6.1.jar:6.6.1]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-6.6.1.jar:6.6.1]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-6.6.1.jar:6.6.1]
    Caused by: java.lang.RuntimeException: can not run elasticsearch as root
    at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:102) ~[elasticsearch-6.6.1.jar:6.6.1]
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:169) ~[elasticsearch-6.6.1.jar:6.6.1]
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:325) ~[elasticsearch-6.6.1.jar:6.6.1]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.6.1.jar:6.6.1]
    ... 6 more
    [root@VM_0_2_centos elasticsearch-6.6.1]# 

这是不能使用root用户操作,添加一个其他的用户再试试:

[root@VM_0_2_centos elasticsearch-6.6.1]# adduser es
[root@VM_0_2_centos elasticsearch-6.6.1]# passwd es
Changing password for user es.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

改一下es目录所属用户:

[root@VM_0_2_centos elasticsearch-6.6.1]# chown es /usr/local/elasticsearch-6.6.1/ -R

vim 编辑 /etc/security/limits.conf,在末尾加上:

es soft nofile 65536
es hard nofile 65536
es soft nproc 4096
es hard nproc 4096

vim 编辑 vim /etc/security/limits.d/20-nproc.conf,将* 改为用户名(es):

# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

es          soft    nproc     4096
root       soft    nproc     unlimited

vim 编辑 /etc/sysctl.conf,在末尾加上:

vm.max_map_count = 655360

执行 sysctl -p

[root@VM_0_2_centos ~]# sysctl -p
kernel.printk = 5
vm.max_map_count = 655360
[root@VM_0_2_centos ~]# 

登录刚才新建的es用户,并启动elasticsearch,OK

[root@VM_0_2_centos elasticsearch-7.1.1]# su es
[es@VM_0_2_centos elasticsearch-7.1.1]$ ./bin/elasticsearch -d

测试
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值