1.确保环境已经安装 java jdk
材料下载 https://www.elastic.co/cn/downloads/past-releases/elasticsearch-6-7-1
elasticSearch 安装包:elasticsearch-7.6.1-linux-x86_64.tar.gz ik分词器:elasticsearch-analysis-ik-7.6.1.zip,在/data 目录下解压
tar xf elasticsearch-7.6.1-linux-x86_64.tar.gz
2.设置 elasticsearch.yml 找到解压包下/data/elasticsearch-7.6.1/config
cd /data/elasticsearch-7.6.1/config vim elasticsearch.yml
-- 设置引擎名称 cluster.name: weilai-es
--设置引擎节点名称 node.name: node-1
-- 设置数据路径 path.data: /data/elasticSearch/es/data -- 设置日志路径 path.logs: /data/elasticSearch/es/logs
-- 设置不绑定内存 bootstrap.memory_lock: false bootstrap.system_call_filter: false
-- 设置任何ip都可以访问 network.host: 0.0.0.0
-- 设置http访问端口 http.port: 9200
-- 设置使用到的节点名称,如果有多个节点配置多个 cluster.initial_master_nodes: ["node-1"]
-- 设置支持http和xpark访问 http.cors.enabled: true http.cors.allow-origin: "*" http.cors.allow-headers: Authorization xpack.security.enabled: true xpack.security.transport.ssl.enabled: true
3.基本设置完,需要为启动elasticsearch 设置系统启动用户,elasticsearch7.x不支持root启动
添加用户
useradd esuser
给用户设置密码
passwd esuser
给用户授权操作某个文件夹
chown -R esuser elasticsearch-7.6.1
4.启动
cd /data/elasticsearch-7.6.1/bin su esuser -- 启动后后台运行 ./elasticsearch -d
5.关于报错
ERROR: [3] bootstrap checks failed [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535] [2]: max number of threads [1024] for user [esuser] is too low, increase to at least [4096] [3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决报错方案:
vim /etc/security/limits.d/90-nproc.conf
-- 将原来的soft nproc 改到大于4096 soft nproc 4097
vim /etc/security/limits.conf
-- 最下面加入 * soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4097
vim /etc/sysctl.conf
-- 最下面加入 vm.max_map_count = 262145
6.bin目录下启动:
./elasticsearch -d
7.bin设置密码
/elasticsearch-setup-passwords interactive
输入 一系列密码,结束