• centos7安装运行Elasticsearch7.1


    Elasticsearch是个开源分布式搜索引擎,它的特点有:开源、灵活性、分布式,零配置,自动发现,索引自动分片,索引副本机制,restful风格接口,多数据源,自动搜索负载等。

    Elasticsearch是基于java开发的,先安装java8运行环境,参考centos7下安装Java8运行环境

    [root@guangzhou src]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.1.1-linux-x86_64.tar.gz
    [root@guangzhou src]# mv elasticsearch-7.1.1 elasticsearch && mv elasticsearch /usr/local/elasticsearch
    [root@guangzhou src]# cd /usr/local/elasticsearch
    
    #编辑配置信息
    [root@guangzhou elasticsearch]# vim config/elasticsearch.yml
    #单机模式,取消注释
    node.name: node-1
    #数据存储路径
    path.data: /usr/local/elasticsearch/data
    #日志存放路径
    path.logs: /usr/local/elasticsearch/logs
    #指定主节点
    cluster.initial_master_nodes: ["127.0.0.1:9300"]
    #发现模块
    discovery.seed_hosts: ["127.0.0.1", "[::1]"]
    #取消IP限制
    network.host: 0.0.0.0
    #访问端口
    http.port: 9200
    
    #更改jvm相关配置
    [elk@guangzhou elasticsearch]$ vim config/jvm.options
    -Xms128m
    Xmx128m

    启动es

    [root@guangzhou bin]# ./elasticsearch
    [2020-02-07T16:08:40,816][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-7.1.1.jar:7.1.1]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.1.1.jar:7.1.1]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.1.1.jar:7.1.1]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-7.1.1.jar:7.1.1]
        at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.1.1.jar:7.1.1]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.1.1.jar:7.1.1]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.1.1.jar:7.1.1]
    Caused by: java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:102) ~[elasticsearch-7.1.1.jar:7.1.1]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:169) ~[elasticsearch-7.1.1.jar:7.1.1]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:325) ~[elasticsearch-7.1.1.jar:7.1.1]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.1.1.jar:7.1.1]
        ... 6 more
    
    #错误显示的不能以root运行elasticsearh,考虑到后面会搭建elk,新建用户名elk来运行elasticsearch
    [root@guangzhou bin]# groupadd elk
    [root@guangzhou bin]# useradd -g elk elk
    [root@guangzhou bin]# chown -R elk:elk /usr/local/elasticsearch/
    
    #再次运行
    [root@guangzhou bin]# su elk
    [elk@guangzhou bin]$ ./elasticsearch
    ...
    
    #新开窗口输入以下命令看结果知道启动成功
    [root@guangzhou bin]# curl http://127.0.0.1:9200
    {
      "name" : "node-1",
      "cluster_name" : "elasticsearch",
      "cluster_uuid" : "_na_",
      "version" : {
        "number" : "7.1.1",
        "build_flavor" : "default",
        "build_type" : "tar",
        "build_hash" : "7a013de",
        "build_date" : "2019-05-23T14:04:00.380842Z",
        "build_snapshot" : false,
        "lucene_version" : "8.0.0",
        "minimum_wire_compatibility_version" : "6.8.0",
        "minimum_index_compatibility_version" : "6.0.0-beta1"
      },
      "tagline" : "You Know, for Search"
    }
    #另外如果要开放给其他机器访问,需要开放端口
    [root@guangzhou bin]# firewall-cmd --zone=public --add-port=9200/tcp --permanent
    success
    [root@guangzhou bin]# firewall-cmd --reload
  • 相关阅读:
    org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException
    Mybatis分页插件PageHelper使用
    比特大陆发布终端 AI 芯片 端云联手聚焦安防
    大数据相乘
    MyBatis学习 之 二、SQL语句映射文件(1)resultMap
    MyBatis学习 之 一、MyBatis简介与配置MyBatis+Spring+MySql
    MyBatis学习 之 一、MyBatis简介与配置MyBatis+Spring+MySql
    MyBatis学习 之 四、MyBatis配置文件
    MyBatis学习 之 四、MyBatis配置文件
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
  • 原文地址:https://www.cnblogs.com/wscsq789/p/12272271.html
Copyright © 2020-2023  润新知