此博文为原创技术分享,如需转载请标明出处
es我是前几天装的,写博文的时候没重新装一遍,如果有什么遗漏的欢迎留言
目录
6.1 elasticsearch process is too low
6.2 vm.max_map_count [65530] is too low
1.下载elasticsearch7.4.0
https://www.elastic.co/cn/downloads/past-releases/elasticsearch-7-4-0
2.将压缩包拷到服务器
这里我是在/usr/local下创建了个es文件夹,用xshell或xftp都能拖拽上传,xshell拖拽上传有时需要装个插件,具体百度,这里不细讲
进到对应目录
cd /usr/local/es
然后解压出来
如果下的是.tar.gz的
tar -zxvf elasticsearch-7.4.0-linux-x86_64.tar.gz
如果是zip,没有unzip的话安装下,依旧百度~
unzip elasticsearch-7.4.0.zip
3.设置配置文件
cd /usr/local/es/elasticsearch-7.4.0/config
在elasticsearch.yml文件中加入下面的配置,我是用xftp做这步的,可以直接打开文件修改,用xshell的话就vim
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.seed_hosts: ["127.0.0.1"]
cluster.initial_master_nodes: ["node-1"]
xpack.security.enabled: false
xpack.ml.enabled: false
path.data: /usr/local/es/data
4. ik分词器
https://github.com/medcl/elasticsearch-analysis-ik 可查看elasticsearch匹配的版本
https://github.com/medcl/elasticsearch-analysis-ik/releases 下载
我这用的是7.4.0 按里面说7+都能兼容,我就也下个7.4.0的
在/usr/local/es/elasticsearch-7.4.0/plugins目录下新建ik文件夹
然后把压缩文件里的东西全放进去
启动时看到有句
loaded plugin [analyzer-ik] 就表示集成成功了
5.启动elasticsearch
elasticsearch出于安全性考虑,不让通过root账号启动,所以要把es文件夹设置可读写权限,并且创建一个新的账号用于启动
一般在第一次启动es的服务器上都会有些问题,可以考虑先设置第6点里的内容,或者启动完发现有对应报错再解决
5.1 设置文件夹权限
上面我设置的path.data也在es目录下,所以开放es文件夹权限就行,如果数据存储路径在别的地方,记得也开下读写权限
chmod -R 777 /usr/local/es
5.2 创建用户
adduser创建用户 passwd设置密码 执行passwd后会让你输入2次密码,要一致
su命令切换用户
adduser elastic(用户名)
passwd elastic(用户名)
su elastic
5.3 启动
进入目录启动elasticsearch 后面的&是让你退出时,es会继续保持运行用的
cd /usr/local/es/elasticsearch-7.4.0/bin
./elasticsearch &
5.4 关闭
搜索进程,然后kill掉
ps -ef |grep elastic
kill -9 85541(进程号)
6.常见错误
6.1 elasticsearch process is too low
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
用root账号修改 /etc/security/limits.conf 文件
在文件最下方添加
elastic(自己新建的那个用户名) hard nofile 65535
elastic(自己新建的那个用户名) soft nofile 65535
6.2 vm.max_map_count [65530] is too low
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
用root账号修改/etc/sysctl.conf 文件
在文件最下方添加
vm.max_map_count=262144
然后执行命令使配置生效
sysctl -p