天天看點

elasticsearch 支援中英文搜尋和混合搜尋

環境: 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"

elasticsearch 支援中英文搜尋和混合搜尋

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目錄下面,名字如下=命名:

elasticsearch 支援中英文搜尋和混合搜尋

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