安装 elastic search 、 kibana 以及插件 jieba

linux 安装 elastic search

  1. 下载 elastic search 的压缩安装包java

    wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.2-linux-x86_64.tar.gz
    复制代码
  2. 解压压缩包到本身的某个目录node

    tar -xvf elasticsearch-7.3.0-linux-x86_64.tar.gz 		
    复制代码
  3. 若是是 root 用户则在启动的时候会报错。linux

    [o.e.b.ElasticsearchUncaughtExceptionHandler] [localhost.localdomain] 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.0.0.jar:7.0.0]
     	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.0.0.jar:7.0.0]
     	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.0.0.jar:7.0.0]
     	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-7.0.0.jar:7.0.0]
     	at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.0.0.jar:7.0.0]
     	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.0.0.jar:7.0.0]
     	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.0.0.jar:7.0.0]
     Caused by: java.lang.RuntimeException: can not run elasticsearch as root
     	at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:102) ~[elasticsearch-7.0.0.jar:7.0.0]
     	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:169) ~[elasticsearch-7.0.0.jar:7.0.0]
     	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:325) ~[elasticsearch-7.0.0.jar:7.0.0]
     	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.0.0.jar:7.0.0]
     	... 6 more
    复制代码
  4. 须要建立一个用户git

    adduser es (建立一个 es 用户)
     passwd es (须要输入两次本身设置的密码)
     chown -R es elasticsearch-7.3.0 (将 elastic search 主目录权限开放给 es 用户)
     su es (切换到 es 用户)
    复制代码
  5. 修改 elasticsearch.yml 文件github

    node.name: node-1 (设置该节点的名称)
     network.host: {你的主机IP }   (设置 elastic search 所在的主机)
     cluster.initial_master_nodes: ["node-1"] (设置该集群中做为 master 的节点名称)
    复制代码
  6. 在新用户 es 中启动 elastic searchbootstrap

    ./elasticsearch -d (在 /usr/local/elasticsearch-7.0.0/bin 目录下进行后台启动该工具)
    复制代码
  7. 再打开一个终端,测试是否安装成功浏览器

    curl -XGET 'http://localhost:9200/?pretty'
     若是输出如下信息表示成功:
     {
       "name" : "localhost.localdomain",
       "cluster_name" : "elasticsearch",
       "cluster_uuid" : "nHwwkFEMQ46-lMSRNEZgsg",
       "version" : {
         "number" : "7.3.0",
         "build_flavor" : "default",
         "build_type" : "tar",
         "build_hash" : "de777fa",
         "build_date" : "2019-07-24T18:30:11.767338Z",
         "build_snapshot" : false,
         "lucene_version" : "8.1.0",
         "minimum_wire_compatibility_version" : "6.8.0",
         "minimum_index_compatibility_version" : "6.0.0-beta1"
       },
       "tagline" : "You Know, for Search"
     }
    复制代码
  8. 关闭 elastic searchbash

    jps|grep Elasticsearch(找到 pid)
     kill -9 7145 
    复制代码

linux 安装配套的可视化工具 kibana

  1. 下载 kibana 的压缩安装包dom

    wget https://artifacts.elastic.co/downloads/kibana/kibana-7.3.0-linux-x86_64.tar.gz
    复制代码
  2. 解压到本身的某个目录curl

    tar -xvf kibana-7.3.0-linux-x86_64.tar.gz   
    复制代码
  3. 把 kibana 主目录的权限给 es 用户

    chown -R es kibana-7.3.0-linux-x86_64
    复制代码
  4. 修改 kibana.yml 文件

    server.host: "0.0.0.0" (容许远程访问)
     elasticsearch.hosts: ["http://{你的IP}:9200"] (设置本身的 elastic search 服务的 IP 和 端口)
    复制代码
  5. 在 kibana 主目录下的 bin 目录启动 kibana

    ./kibana
    复制代码
  6. 在浏览器中访问 {你的IP}:5601 ,若是有 kibana 面板内容显示,说明配置成功

配置 jieba 插件

  1. 下载 jieba 的安装压缩包

    wget https://github.com/sing1ee/elasticsearch-jieba-plugin/archive/v7.0.0.zip
    复制代码
  2. 解压到某个目录,而后进入该目录

    unzip v7.0.0.zip
     cd elasticsearch-jieba-plugin-7.0.0/
    复制代码
  3. 安装并配置 gradle

    wget https://downloads.gradle-dn.com/distributions/gradle-5.6-bin.zip
     unzip gradle-5.6-bin.zip (解压出的文件夹放到某个目录)		export PATH=$PATH:{ grable 主目录}/gradle-5.6/bin (在  ~/.bash_profile 中添加,而后更新  ~/.bash_profile)
     gradle -v (若是有输出则说明配置正常)
    复制代码
  4. 在 elasticsearch-jieba-plugin-7.0.0/ 目录下使用 gradle 生成压缩文件

    gradle pz (若是输入 BUILD SUCCESSFUL 表示成功)
    复制代码
  5. 当前目录生成的 build/distributions/elasticsearch-jieba-plugin-7.0.0.zip 拷贝elasticsearch-7.0.0 目录下的 plugins 文件夹中

  6. 将 elasticsearch-jieba-plugin-7.0.0.zip 解压以后,删除压缩包便可,最后若是没有自动生成有 jieba 目录,则本身建立,最后的目录结构以下

    *elasticsearch-7.0.0
     	*plugins
     		*jieba
     			dic
     			jieba-analysis-1.0.2.jar
     			elasticsearch-jieba-plugin-7.0.0.jar
     			plugin-descriptor.properties
     			plugin.xml
    复制代码
  7. 将 plugin-descriptor.properties 中的 elasticsearch.version 改成 7.3.0 ,而后 从新启动 elastic search

bug 处理

1.日志显示以下错误:

[WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-1] uncaught exception in thread [main]
	org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: failed to obtain node locks, tried [[/usr/local/elasticsearch-7.0.0/data]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
		at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-7.0.0.jar:7.0.0]
		at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.0.0.jar:7.0.0]
		at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.0.0.jar:7.0.0]
		at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-7.0.0.jar:7.0.0]
		at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.0.0.jar:7.0.0]
		at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.0.0.jar:7.0.0]
		at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.0.0.jar:7.0.0]

这是由于已经打开了一个 elastic searc 的服务,找出以前的进程关闭便可。
复制代码
相关文章
相关标签/搜索