您现在的位置是:首页 > 文章详情

elasticsearch 支持中英文搜索和混合搜索

日期:2018-07-12点击:322

环境: ubuntu16.04

安装: elasticsearch 5.22

1. 第一步,安装java
 apt-get install default-jre
 apt-get install default-jdk

2.第二步,安装elasticsearch.   5.22
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.2.deb
dpkg -i elasticsearch-5.2.2.deb

3.启动服务
 systemctl daemon-reload
 systemctl enable elasticsearch
 systemctl restart elasticsearch

碰到问题:
[2018-07-02 18:36:32,700][INFO ][node                     ] [Captain Fate] version[1.7.3], pid[25545], build[NA/NA]
[2018-07-02 18:36:32,701][INFO ][node                     ] [Captain Fate] initializing ...
[2018-07-02 18:36:32,900][INFO ][plugins                  ] [Captain Fate] loaded [], sites []
[2018-07-02 18:36:32,930][INFO ][env                      ] [Captain Fate] using [1] data paths, mounts [[/ (/dev/vda1)]], net usable_space [27gb], net total_space [39.2gb], types [ext4]
[2018-07-02 18:36:35,634][WARN ][common.network           ] failed to resolve local host, fallback to loopback
java.net.UnknownHostException: iZhp3ig1mh8lh6acp6sx0xZ: iZhp3ig1mh8lh6acp6sx0xZ: Name or service not known
    at java.net.InetAddress.getLocalHost(InetAddress.java:1505)
    at org.elasticsearch.common.network.NetworkUtils.<clinit>(NetworkUtils.java:55)
    at org.elasticsearch.http.netty.NettyHttpServerTransport.<init>(NettyHttpServerTransport.java:165)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)


修改etc/hosts文件,加上你自己的hostname里面的值
127.0.0.1       localhost  iZhp3ig1mh8lh6acp6sx0xZ

4.验证是否成功
curl -XGET "http://localhost:9200"

 

5.注意的几点:

a.新建用户elasticsearch 

useradd elasitcsearch

b.让上面的用户拥有目录:/usr/share/elasticsearch 的权限

chown elasitcsearch:elasitcsearch /usr/share/elasticsearch

chown -R 777 /usr/share/elasticsearch

 sudo chown -R elsearch:elsearch /etc/elasticsearch

sudo chmod -R 775 /etc/elasticsearch/

 

6.添加支持中文分词的插件等,所有插件,必须和elasticsearch版本一致,下载解压到/usr/share/elasticsearch/plugins目录下面,名字如下=命名:

 

7.启动的时候可以切换到目录/usr/share/elasticsearch/bin/ .  直接执行./elasticsearch 就可以进行启动了

需要的插件地址都可以在这里找到:https://github.com/medcl

下载如下

elasticsearch-5.2.2.deb              elasticsearch-analysis-stconvert-5.2.2.zip
elasticsearch-analysis-ik-5.2.2.zip  kibana-5.2.2-amd64.deb

 

问题:

1、Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)

由于elasticsearch5.0默认分配jvm空间大小为2g,修改jvm空间分配

  1. # vim config/jvm.options
  2. -Xms2g
  3. -Xmx2g
修改为
  1. -Xms512m
  2. -Xmx512m

2.Exception in thread "main" org.elasticsearch.bootstrap.BootstrapException: java.nio.file.NoSuchF

ileException: /usr/share/elasticsearch/config

解决方法:cp -R /etc/elasticsearch/* ./config/

 


Likely root cause: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/config

原文链接:https://yq.aliyun.com/articles/612086
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章