一、下载elasticsearch-7.0.1-linux-x86_64.tar.gz
二、解压tar -zxvf elasticsearch-7.0.1-linux-x86_64.tar.gz
三、jvm.options (默认Xms1g Xmx1g 如果内存不够启动会报如下异常)
四、不能用root用户启动,要新建用户
adduser:esadmin
passwd:esadmin
给新建用户授权操作es:chown -R esadmin:esadmin elasticsearch-5.6.3
切换用户:su esadmin
五、修改 /config/elasticsearch.yml
network.host: 0.0.0.0(如果修改为127.0.0.1只能内网访问,如果修改成公网ip会报下图错误)
http.port: 9200
可能出现的问题
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
切换root用户修改/etc/security/limits.conf,追加以下内容;
* soft nofile 65536
* hard nofile 65536
[2]: max number of threads [3818] for user [admin] is too low, increase to at least [4096]
继续在/etc/security/limits.conf,追加以下内容;
* soft nproc 4096
* hard nproc 4096
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
编辑 /etc/sysctl.conf,追加以下内容:
vm.max_map_count=262144
保存后,执行:
sysctl -p
[4]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
编辑/opt/elasticsearch/elasticsearch-7.0.1/config/elasticsearch.yml
将cluster.initial_master_nodes: ["node-1","node-2"]注释去掉 改为cluster.initial_master_nodes: ["node-1"]
切换回esadmin 执行 ./bin/elasticsearch启动
六、安装ElasticSearch-Head
从https://github.com/mobz/elasticsearch-head下载ZIP包。
用unzip命令到解压到新创建的目录/plugins/head/_site
下
如果在可视化工具中提示无法连接
可以在/config/elasticsearch.yml中添加
http.cors.enabled: true
http.cors.allow-origin: "*"
七、安装分词ik
从https://github.com/medcl/elasticsearch-analysis-ik下载zip,通过unzip解压到任意目录
sudo apt-get install maven 安装mvn
mvn package 或者mvn clean package
执行操作后会在target/releases目录下生成elasticsearch对应版本的ik插件
找到zip压缩包,之后解压至lasticsearch的plugins目录下建一个ik文件夹