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