首页 > 其他 > 详细

Elasticsearch搭建使用

时间:2020-12-27 16:18:58      阅读:32      评论:0      收藏:0      [点我收藏+]

一、安装

系统:centos7.x

elastic版本:6.7.2 

java版本:1.8

[root@zrl /]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.7.2.tar.gz #下载文件
[root@zrl /]# tar -zxvf elasticsearch-6.7.2.tar.gz # 解压
[root@zrl /]# cd elasticsearch-6.7.2  # 进去文件夹

二、运行

接着,进入解压后的目录,运行下面的命令,启动 Elastic

[root@zrl /]# ./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_pid9590.log

这个时候去修改jvm.options,找到虚拟机参数分配内存改小点

...
-Xms256m
-Xmx256m
...

接着碰到下面的错误,很明显意思就是不能运行在root账号下

org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root

创建一个elastic账号

[root@zrl /]# adduser elastic  # 创建elastic账号
[root@zrl /]# passwd elastic # 修改密码
[root@zrl /]# chown -R elastic elasticsearch-6.7.2 # 给elastic账号权限
[root@zrl /]# su elastic # 切换到elastic用户
[elastic@zrl /]$ ./bin/elasticsearch -d # 启动并在后台运行
[elastic@zrl /]$ cur localhost:9200 # 应该会得到json字符串

访问的时候,又出现新的错误

curl: (7) Failed connect to 106.14.14.158:9200; Connection refused

修改confg/elasticsearch.yml,中

network.host: 0.0.0.0

查看log的时候发现又有一条错误

max number of threads [3897] for user [elastic] is too low, increase to at least [4096]

修改配置 添加 * soft nproc 4096

[root@zrl /] vim /etc/security/limit.d/20-nproc.conf

继续重启,然后访问

[elastic@zrl /]$ ./bin/elasticsearch -d # 启动并在后台运行
[elastic@zrl /]$ cur localhost:9200 # 应该会得到json字符串

三、访问成功

{
  "name" : "JRMD634",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "ewobaquGTy2bXVD16fA-Ow",
  "version" : {
    "number" : "6.7.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "56c6e48",
    "build_date" : "2019-04-29T09:05:50.290371Z",
    "build_snapshot" : false,
    "lucene_version" : "7.7.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

 

Elasticsearch搭建使用

原文:https://www.cnblogs.com/zrl66/p/14197364.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!