• elasticsearch -- 安装


            Elasticsearch至少需要Java 8.具体到撰写本文时,建议您使用Oracle JDK版本1.8.0_131。Java安装因平台而异,因此我们不会在此处详细介绍。可以在Oracle的网站上找到Oracle推荐的安装文档。可以说,在安装Elasticsearch之前,请先运行检查Java版本(然后根据需要进行相应的安装/升级):

     java -versionecho $ JAVA_HOME

            一旦我们设置了Java,我们就可以下载并运行Elasticsearch。文件可以到www.elastic.co/downloads下载。对于每个版本,您可以选择zip或tar存档,DEB或RPM包或包。为简单起见,我们使用tar文件。

    1)下载Elasticsearch 5.4.3 tar(Windows用户应该下载zip包):

    curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.3.tar.gz

    然后按如下方式提取它(Windows用户应该解压缩zip包):tar -xvf elasticsearch-5.4.3.tar.gz

    它会在当前目录中创建一堆文件和文件夹。

    2)进入bin目录,如下所示:

    cd elasticsearch-5.4.3 / bin

    现在我们准备启动我们的节点和单个集群(Windows用户应该运行elasticsearch.bat文件):

    ./elasticsearch

    如果一切顺利,你应该看到一堆如下所示的消息:

    [2016-09-16T14:17:51,251][INFO ][o.e.n.Node ] [] initializing ...

    [2016-09-16T14:17:51,329][INFO ][o.e.e.NodeEnvironment    ] [6-bjhwl] using [1] data paths, mounts [[/ (/dev/sda1)]], net usable_space [317.7gb], net total_space [453.6gb], spins? [no], types [ext4]

    [2016-09-16T14:17:51,330][INFO ][o.e.e.NodeEnvironment    ] [6-bjhwl] heap size [1.9gb], compressed ordinary object pointers [true]

    [2016-09-16T14:17:51,333][INFO ][o.e.n.Node              ] [6-bjhwl] node name [6-bjhwl] derived from node ID; set [node.name] to override

    [2016-09-16T14:17:51,334][INFO ][o.e.n.Node              ] [6-bjhwl] version[5.4.3], pid[21261], build[f5daa16/2016-09-16T09:12:24.346Z], OS[Linux/4.4.0-36-generic/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_60/25.60-b23]

    [2016-09-16T14:17:51,967][INFO ][o.e.p.PluginsService    ] [6-bjhwl] loaded module [aggs-matrix-stats]

    [2016-09-16T14:17:51,967][INFO ][o.e.p.PluginsService    ] [6-bjhwl] loaded module [ingest-common]

    [2016-09-16T14:17:51,967][INFO ][o.e.p.PluginsService    ] [6-bjhwl] loaded module [lang-expression]

    [2016-09-16T14:17:51,967][INFO ][o.e.p.PluginsService    ] [6-bjhwl] loaded module [lang-groovy]

    [2016-09-16T14:17:51,967][INFO ][o.e.p.PluginsService    ] [6-bjhwl] loaded module [lang-mustache]

    [2016-09-16T14:17:51,967][INFO ][o.e.p.PluginsService    ] [6-bjhwl] loaded module [lang-painless]

    [2016-09-16T14:17:51,967][INFO ][o.e.p.PluginsService    ] [6-bjhwl] loaded module [percolator]

    [2016-09-16T14:17:51,968][INFO ][o.e.p.PluginsService    ] [6-bjhwl] loaded module [reindex]

    [2016-09-16T14:17:51,968][INFO ][o.e.p.PluginsService    ] [6-bjhwl] loaded module [transport-netty3]

    [2016-09-16T14:17:51,968][INFO ][o.e.p.PluginsService    ] [6-bjhwl] loaded module [transport-netty4]

    [2016-09-16T14:17:51,968][INFO ][o.e.p.PluginsService    ] [6-bjhwl] loaded plugin [mapper-murmur3]

    [2016-09-16T14:17:53,521][INFO ][o.e.n.Node              ] [6-bjhwl] initialized

    [2016-09-16T14:17:53,521][INFO ][o.e.n.Node              ] [6-bjhwl] starting ...

    [2016-09-16T14:17:53,671][INFO ][o.e.t.TransportService  ] [6-bjhwl] publish_address {192.168.8.112:9300}, bound_addresses {{192.168.8.112:9300}

    [2016-09-16T14:17:53,676][WARN ][o.e.b.BootstrapCheck    ] [6-bjhwl] max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]

    [2016-09-16T14:17:56,731][INFO ][o.e.h.HttpServer        ] [6-bjhwl] publish_address {192.168.8.112:9200}, bound_addresses {[::1]:9200}, {192.168.8.112:9200}

    [2016-09-16T14:17:56,732][INFO ][o.e.g.GatewayService    ] [6-bjhwl] recovered [0] indices into cluster_state

    [2016-09-16T14:17:56,748][INFO ][o.e.n.Node              ] [6-bjhwl] started

     3)在不详细讨论的情况下,我们可以看到名为“6-bjhwl”的节点(在您的情况下将是一组不同的字符)已经启动并选择自己作为单个集群中的主节点。现在不要担心掌握意味着什么。这里最重要的是我们在一个集群中启动了一个节点。

    如前所述,我们可以覆盖集群或节点名称。这可以在启动Elasticsearch时从命令行完成,如下所示:

    ./elasticsearch -Ecluster.name = my_cluster_name -Enode.name = my_node_name

    另请注意标有http的行,其中包含有关我们的节点可以访问的HTTP地址(192.168.8.112)和端口(9200)的信息。默认情况下,Elasticsearch使用port 9200来提供对其REST API的访问。如有必要,可以配置此端口。

    部署elasticsearch常见错误

    一、Exception in thread "main" SettingsException[Failed to load settings from [elasticsearch.yml]]; nested: ElasticsearchParseException[malformed, expected settings to start with 'object', instead was [VALUE_STRING]];

    原因:elasticsearch.yml文件错误

    解决:参数与参数值等号间需要空格

    node.name ="node"  ##错误

    node.name = "node" ##正确 

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

    原因:处于对root用户的安全保护,需要使用其他用户组进行授权启动

    解决:

    step1:用户组进行授权启动

    groupadd elsearch         

    useradd elsearch -g elsearch -p elasticsearch

    chown -R elsearch:elsearch  elasticsearch-6.3.0

    备注: 添加用户组 elsearch 

          添加用户 elsearch 密码为 elasticsearch 到用户组 elsearch

          将elsearch安装目录授权给 用户组:用户  即 elsearch:elsearch 

    step2: 重新启动

    su elsearch

    /elasticsearch-6.3.0/bin/elasticsearch

    备注:切换 elsearch 用户

          重新启动

    三、OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot a ...'(errno=12);

    原因:jvm要分配最大内存超出系统内存

    解决:

    step1:适当调整指定jvm内存

    vi /home/elasticsearch-6.3.0/config/jvm.options

    备注:编辑elasticsearch jvm配置文件 修改如下 esc+:wq保存退出

    ## JVM configuration

    ################################################################

    ## IMPORTANT: JVM heap size

    ################################################################

    ##

    ## You should always set the min and max JVM heap

    ## size to the same value. For example, to set

    ## the heap to 4 GB, set:

    ##

    ## -Xms4g

    ## -Xmx4g

    ##

    ## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html

    ## for more information

    ##

    ################################################################

    # Xms represents the initial size of total heap space

    # Xmx represents the maximum size of total heap space

    -Xms512m

    -Xmx512m

    备注:由于虚拟机内存制定1g,所以适当降低jvm内存指定

    step2:重启

    su elsearch

    /elasticsearch-6.3.0/bin/elasticsearch

    四、ERROR: [3] bootstrap checks failed

    原因:虚拟机限制用户的执行内存

    解决:

    [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

    [2]: max number of threads [3802] for user [elsearch] is too low, increase to at least [4096]

    step1:修改安全限制配置文件

    su root

    vi /etc/security/limits.conf

    备注:使用最高权限 修改安全配置 在文件末尾加入

    # End of file

    elsearch      hard        nofile        65536

    elsearch      soft        nofile        65536

    *              soft      nproc        4096

    *              hard      nproc        4096

    备注: elsearch为用户名 可以是使用*进行通配 

    nofile 最大打开文件数目

    nproc 最大打开线程数目

    [3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

    step2:修改系统配置文件

    vi /etc/sysctl.conf

    备注:行末加上vm.max_map_count = 655360 ,esc +:wq保存退出

    # sysctl settings are defined through files in

    # /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.

    #

    # Vendors settings live in /usr/lib/sysctl.d/.

    # To override a whole file, create a new file with the same in

    # /etc/sysctl.d/ and put new settings there. To override

    # only specific settings, add a file with a lexically later

    # name in /etc/sysctl.d/ and put new settings there.

    #

    # For more information, see sysctl.conf(5) and sysctl.d(5).

    vm.max_map_count = 655360

    执行sysctl -p 让配置生效

    备注:vm.max_map_count = 655360 值大于错误提示值

    step3:重启

    su elsearch

    /elasticsearch-6.3.0/bin/elasticsearch 

    五、org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: failed to obtain node locks, tried [[/home/elasticsearch-6.3.0/data/elasticsearch]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?

    原因:线程占用

    解决:重新启动

    step1:杀死elasticsearch线程

    ps -ef | grep elastic


     

    kill -9 2002


     

    step2: 重启

    su elsearch

    /elasticsearch-6.3.0/bin/elasticsearch

    六、验证

    1、后台启动

    /home/elasticsearch-6.3.0/bin/elasticsearch -d


     

    2、curl验证

    curl http://zk01:9200


     

    3、网站验证


     
  • 相关阅读:
    第一阶段冲刺——4
    Day 1 测试流程--H模型
    【疑问】待解决
    Zookeeper 入门(一)
    【基础组件1】Flume入门(一)
    埋点测试、埋点接口测试
    单点登录 VS 多点登录
    web系统原理
    测试用例总结篇(一)
    功能测试心得(二)
  • 原文地址:https://www.cnblogs.com/onekey/p/10250130.html
Copyright © 2020-2023  润新知