搭建 elasticsearch 5.5.3 环境 +IK 分词器 & 拼音分词器

一:准备安装包

  1. 下载 elasticsearch 5.5.3
    链接地址是:https://github.com/elastic/elasticsearch/archive/v5.5.3.zip
  2. 下载 IK 分词插件
    链接地址是:https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.5.3/elasticsearch-analysis-ik-5.5.3.zip
  3. 下载拼音分词插件
    链接地址是:https://github.com/medcl/elasticsearch-analysis-pinyin/releases/download/v5.5.3/elasticsearch-analysis-pinyin-5.5.3.zip

将 ik 分词插件解压后 然后将解压出来的目录重命名为 ik
将 pinyin 分词插件解压后 然后将解压出来的目录重命名为 pinyin
将 ik 与 pinyin 加入 elasticsearch plugin 目录下

二 、安装 elasticsearch-head 可视化插件

  1. 下载 nodejs
    链接地址是:https://nodejs.org/en/download/current/
    下载 elasticsearch-head
  2. 链接地址是:https://github.com/mobz/elasticsearch-head/archive/v5.0.0.zip

执行步骤:
① 使用 npm 安装 grunt:
npm install -g grunt -cli
② 到 elasticsearch-head 目录下,运行命令:
npm install

1、安装 grunt

npm install -g grunt-cli

将 nodejs 加入全局命令
ln -s /app/software/nodejs/bin/npm /usr/local/bin/

ln -s /app/software/nodejs/bin/node /usr/local/bin/

ln -s /app/software/nodejs/bin/grunt /usr/local/bin/

使用命令

[root@localhost ~]# grunt -version
-bash: grunt: command not found
分析
如果一些程序没有安装在系统默认的路径 (ie /bin/, /usr/bin, /usr/local/bin/) 里面,这个时候普通用户想要调用这些命令,必须设定路径。

[root@localhost ~]# vi ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [-f ~/.bashrc]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/local/src/node-v8.2.1-linux-x86/bin
export PATH

  1. 修改配置,启动插件
    编辑 elasticsearch-5.5.3/config/elasticsearch.yml, 加入以下内容:

    http.cors.enabled: true
    http.cors.allow-origin: "*"

    修改

    network.host: 192.168.137.101

  2. 配置设置

    打开 elasticsearch-head-master/Gruntfile.js,找到下面 connect 属性,新增 hostname: '0.0.0.0':

      connect: {
        server: {
            options: {
                hostname: '0.0.0.0',
                port: 9100,
                base: '.',
                keepalive: true
            }
        }
    } 

connect: { server: { options: { hostname: '0.0.0.0', port: 9100, base: '.', keepalive: true } } }

  1. 在 elasticsearch-head/ 目录下,运行启动命令:

    grunt server

三、 异常解决办法

[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536
切换为 root 用户
编辑 limits.conf 在第一行加上如下内容
cat /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
编辑 limits.conf 在第一行加上如下内容
cat /etc/sysctl.conf
vm.max_map_count = 655360

执行 sysctl -p

删除 data 目录下的数据 (如果是新解压的安装包就不必了)

最后注意防火墙是否开放 9200、9300 端口

注意:

  1. 启动执行的时候不能用 root 用户启动。若用 root 用户启动,还需调整配置

    解决方法 1:
    在执行 elasticSearch 时加上参数 -Des.insecure.allow.root=true,完整命令如下
    ./elasticsearch -Des.insecure.allow.root=true
    解决办法 2:
    用 vim 打开 elasicsearch 执行文件,在变量 ES_JAVA_OPTS 使用前添加以下命令
    ES_JAVA_OPTS="-Des.insecure.allow.root=true"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值