Linux(Centos7.6)安装elasticsearch-7.1.1
- 下载:https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.1.1-linux-x86_64.tar.gz
上传到/opt文件夹并解压
1
tar zxvf elasticsearch-7.1.1-linux-x86_64.tar.gz
在解压后的elasticsearch目录里新建data目录
1
mkdir data
修改config/elasticsearch.yml
1
2
3
4
5
6
7
8vim /opt/elasticsearch-7.1.1/config/elasticsearch.yml
cluster.name: my-application #集群名称
node.name: node-1 #节点名称
path.data: /opt/elasticsearch-7.1.1/data #数据和日志的存储目录
path.logs: /opt/elasticsearch-7.1.1/logs
network.host: 0.0.0.0 #设置绑定的ip,设置为0.0.0.0以后就可以让任何计算机节点访问到了
http.port: 9200 #端口
cluster.initial_master_nodes: ["node-1"] #设置在集群中的所有节点名称,这个节点名称就是之前所修改的,当然你也可以采用默认的也行,目前是单机,放入一个节点即可修改内存
1
2
3
4
5vim /opt/elasticsearch-7.1.1/config/jvm.options
-Xms200m
-Xmx200m
解决报错:
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c5330000, 986513408, 0) failed; error='Cannot allocate memory' (errno=12)es6.0版本往后的版本不支持root用户启动,需创建用户(es)
1
2
3groupadd es #创建用户组
useradd es -g es #创建用户
chown -R es:es /opt/elasticsearch-7.1.1 #给用户增加权限解决报各种大小限制问题
1
2
3
4
5
6
7
8
9
10
11vim /etc/security/limits.conf
es soft nofile 65536
es hard nofile 65536
es soft nproc 4096
es hard nproc 4096
vim /etc/security/limits.d/20-nproc.conf
es soft nproc 4096
root soft nproc unlimited
vim /etc/sysctl.conf
vm.max_map_count = 655360
sysctl -p #执行查看是否生效切换到es用户启动es
1
./bin/elasticsearch -d(后台启动)
查看进程
1
ps -ef | grep elasticsearch