前言一、安装ElasticSearch
1. 下载ElasticSearch2. 解压缩 二、创建用户
1. 创建用户2. 删除用户(如有必要)3. 给新建用户授权 三、修改ElasticSearch的配置四、修改Linux的配置
1. 修改/etc/security/limits.conf2. 修改/etc/security/limits.d/20-nproc.conf3. 修改/etc/sysctl.conf4. 重新加载 五、启动ElasticSearch
1. 启动2. 切换用户3. 再次执行启动4. 重新授权并启动5. 再次启动6. 验证
前言
一、安装ElasticSearch 1. 下载ElasticSearch
下载地址:https://www.elastic.co/cn/downloads/past-releases/elasticsearch-7-8-0
2. 解压缩#找到下载的安装包 cd /opt/module/software/ #解压缩至上级目录 tar -zxvf elasticsearch-7.8.0-linux-x86_64.tar.gz -C ../ #返回上一级目录 cd ../ #重命名解压的文件夹名称为es mv elasticsearch-7.8.0/ es二、创建用户
因为安全问题,ElasticSearch不允许root用户直接运行,所以需要创建新的用户,下面将使用root用户创建新的用户:
1. 创建用户#创建用户 useradd es #设置密码 passwd es2. 删除用户(如有必要)
userdel -r es3. 给新建用户授权
chown -R es:es /opt/module/es三、修改ElasticSearch的配置
使用Xftp打开/opt/module/es/config/elasticsearch.yml配置文件,在该文件的最下面添加如下配置信息:
cluster.name: elasticsearch node.name: node-1 network.host: 0.0.0.0 http.port: 9200 cluster.initial_master_nodes: ["node-1"]四、修改Linux的配置 1. 修改/etc/security/limits.conf
在配置文件末尾追加如下内容
#每一个进程可以打开的文件数上限 es soft nofile 65536 es hard nofile 655362. 修改/etc/security/limits.d/20-nproc.conf
在配置文件末尾追加如下内容
#每一个进程可以打开的文件数上限 es soft nofile 65536 es hard nofile 655363. 修改/etc/sysctl.conf
在配置文件末尾追加如下内容
#一个进程可以拥有的VMA(虚拟内存区域)的数量,默认值为65536 vm.max_map_count=6553604. 重新加载
sysctl -p五、启动ElasticSearch 1. 启动
cd /opt/module/es/ #直接启动 bin/elasticsearch #后台启动 bin/elasticsearch -d
原因:使用了root用户进行了启动操作,而ElasticSearch是不允许使用root用户执行操作的;我们需要切换到上面新创建的用户es上进行启动操作!
2. 切换用户su es3. 再次执行启动
cd /opt/module/es/ #直接启动 bin/elasticsearch
原因:es在启动过程中,会动态生成一些文件和目录,而这些新生成的文件和目录,当前es用户是没有权限的,需要重新授权;
4. 重新授权并启动#切换至root用户并输入密码 su root #重新授权 chown -R es:es /opt/module/es #再次切换为es用户 su es #进行启动 cd /opt/module/es/ bin/elasticsearch
发现新的报错信息!
原因:原来是本身机器内存不够大,只有1G内存,而es中的jvm配置文件中,就配置了1g的堆大小,导致没有足够空间分配,故es启动不起来。
解决办法:修改es的配置文件/opt/module/es/config/jvm.options,默认都是1g,下面均改为512m
5. 再次启动启动失败的页面!!!
启动成功的页面!!!
6. 验证


