安装elasticsearch:
1.解压安装包(我这里用的是elasticsearch6.2.2版本)tar -zxvf
2.切换用户su xxx(elasticsearch不能在root用户下启动)
如需增加用户并设置密码:
useradd xxx
passwd xxx
3.移动解压好的文件到soft文件夹下(个人习惯把应用都放在soft文件夹下)
mv elasticsearch-6.2.2 soft/elasticsearch
4.修改配置参数
vi elasticsearch/config/elasticsearch.yml
cluster.name: es-app #集群名称,可以自行修改
node.name: es-1 #节点名称,自行修改
network.host: 192.168.235.133 #主机地址,这里写本机IP
http.port: 9200 #端口
http.cors.enabled: true #设置跨域
http.cors.allow-origin: "*" #设置访问
可能出现的问题:
(1)系统最大文件数太低
vi /etc/security/limits.conf 文件末尾追加
xxx soft nofile 65536
xxx hard nofile 131072
xxx soft nproc 4096
xxx hard nproc 4096
(2)虚拟内存太低
vi /etc/sysctl.conf文件末尾追加
vm.max_map_count=655360
激活:sysctl -p
一定要激活一下
(3)java.nio.file.AccessDeniedException: …/elasticsearch-6.2.2/config/jvm.options
chown 用户名 elasticsearch-6.2.2安装目录路径 -R
启动elasticsearch:
在非root用户下进入
cd /opt/soft/elasticsearch/bin/
./elasticsearch
安装elastic-head
考虑需要安装elasticsearch-head作为web展示 所以首先安装nodejs主要是利用npm
安装nodejs:
1.wget https://npm.taobao.org/mirrors/node/v11.0.0/node-v11.0.0.tar.gz
2.tar –zxvf node-v11.0.0.tar.gz
3.cd node-v11.0.0
4.yum install gcc gcc-c++
5../configure
6.make
7.make install
8.node –v
make的时间非常长,大概20分钟左右,请耐心等待。。。
安装elastic-head:
1.tar –zxvf elasticsearch-head-master 解压压缩包
2.npm install 安装
3.npm run start 启动elastic-head