elasticsearch以及ik分词器的安装及使用

elasticsearch下载地址

https://www.elastic.co/cn/downloads/elasticsearch/

Elasticsearch 5 需要 Java 8 以上版本;

Elasticsearch 6.5 开始支持 Java 11;

Elasticsearch 7.0 开始,内置了 Java 环境,所以说,安装 7.0+ 版本会方便很多。

1.解压安装包

tar -zxvf elasticsearch-7.6.1-linux-x86_64.tar.gz

2.用root账号创建linux新用户

adduser es   #创建新用户

chown -R es /opt/elasticsearch-7.6.1/    #给新用户赋权

3.修改elasticsearch.yml配置文件

cd /opt/elasticsearch-7.6.1/config
vim elasticsearch.yml

修改项

cluster.name: essss
node.name: es-node1
network.host: 0.0.0.0
http.port: 9200
cluster.initial_master_nodes: ["es-node1"]

新增项
#开启跨域访问支持,默认为false
http.cors.enabled: true
##跨域访问允许的域名地址,(允许所有域名)以上使用正则
http.cors.allow-origin: /.*/
4.修改config文件夹下的jvm.options

-Xms1g

-Xmx1g

改为

-Xms128m

-Xmx128m

5.在新建的用户下启动elasticsearch

su es
nohup ./bin/elasticsearch &

测试

[root@localhost elasticsearch-7.6.1]# curl localhost:9200
{
  "name" : "es-node1",
  "cluster_name" : "essss",
  "cluster_uuid" : "hIdF5P8JSdWjqgDswh_uyA",
  "version" : {
    "number" : "7.6.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "aa751e09be0a5072e8570670309b1f12348f023b",
    "build_date" : "2020-02-29T00:15:25.529771Z",
    "build_snapshot" : false,
    "lucene_version" : "8.4.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
 

6.安装ik中文分词器

下载地址

https://github.com/medcl/elasticsearch-analysis-ik

6.1创建ik文件夹并上传elasticsearch-analysis-ik-7.6.1.zip

cd /opt/elasticsearch-7.6.1/plugins
mkdir ik

解压elasticsearch-analysis-ik-7.6.1.zip到ik目录下

重启elasticsearch

启动的时候会打印以下日志,可忽略,等待几秒便可正常启动

future versions of Elasticsearch will require Java 11; your Java version from [/opt/jdk/jdk1.8.0_144/jre] does not meet this requirement
 

测试

POST http://192.168.114.128:9200/_analyze

{
  "analyzer": "ik_smart",
  "text": "武汉,加油!"
}

常见错误

1.max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]

sudo sysctl -w vm.max_map_count=262144

2.max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]

sudo vim /etc/security/limits.conf

新增一下两项

soft nofile 65536
hard nofile 65536

vim /etc/profile

添加

ulimit -SHn 65536

source /etc/profile

查看是否生效

ulimit -n

 

ik分词器7.6.1

链接:https://pan.baidu.com/s/1bUjg3KbAjP4_K4wLEPonLA 
提取码:t6q7 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值