第一步:准备工作
Linux 环境
elasticsearch verison
1: elasticsearch-5.4.0.tar.gz
jdk version
1:jdk-8u111-linux-x64.tar.gz
第二步 :jdk 安装
jdk 环境检测
一些开发版的centos会自带jdk,我们一般用自己的jdk,把自带的删除。先看看有没有安装java -version
1、查找他们的安装位置
[root@localhost ~]# rpm -qa | grep java
java-1.8.0-openjdk-headless-1.8.0.101-3.b13.el7_2.x86_64
tzdata-java-2016f-1.el7.noarch
java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
javapackages-tools-3.4.1-11.el7.noarch
java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.2.el7_2.x86_64
java-1.7.0-openjdk-1.7.0.111-2.6.7.2.el7_2.x86_64
python-javapackages-3.4.1-11.el7.noarch
2、删除全部,noarch文件可以不用删除
[root@localhost ~]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.101-3.b13.el7_2.x86_64
[root@localhost ~]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64
[root@localhost ~]# rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.2.el7_2.x86_64
[root@localhost ~]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.111-2.6.7.2.el7_2.x86_64
3、检查有没有删除 [root@localhost ~]# java -version
-bash: /usr/bin/java: 没有那个文件或目录
jdk 安装
1、解压 tar xvzf jdk-8u111-linux-x64.tar.gz
2、配置环境变量
输入 vi /etc/profile,进入profile文件,然后按 I 键进入编辑模式,输入以下内容:
export JAVA_HOME=/evchar/java/jdk1.8.0_111
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
键盘 按 : i
shift + :
wq 保存
3、source /etc/profile ← 使配置生效
第三步 :Elasticsearch 5.4.1 version 安装
下载elasticsearch
第一种方式: wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.0.tar.gz
第二种方式:
网络不好,可以直接去官网下载
https://www.elastic.co/downloads/past-releases/elasticsearch-5-4-1
安装elasticsearch
官网参考:
https://www.elastic.co/guide/en/elasticsearch/reference/current/zip-targz.html
1:创建帐号和分配权限
官方文档上说Elasticsearch不适合在root管理员帐号下运行,所以要先建立一个账号专门运行Elasticsearch.
创建一个elasticsearch用户
adduser elasticsearch
passwd elasticsearch 123456
按照提示输入密码和确认密码就成功创建elasticsearch账户了。
修改用户权限,这一步非常重要
使用vim 编辑器打开文件打开/etc 目录下面的文件sudoers
vim /etc/sudoers
i 编辑
shift+:
wq! 强制保存
2:elastIcsearch 安装
改变 权限 为elasticsearch 用户
chown -R elasticsearch:elasticsearch elasticsearch-5.4.1
配置 elasticsearch.yaml 文件
cluster.name: evchar-cluster
node.name: node-1
path.data: /evchar/elk/es/data
path.logs: /evchar/elk/es/logs
bootstrap.memory_lock: true
network.host: 127.0.0.1 本机IP
http.port: 9200
增加新的参数,这样head插件可以访问es
http.cors.enabled: true
http.cors.allow-origin: "*"
保存elasticsearch.yaml文件
3:启动 elasticsearch
[elasticsearch@localhost bin]$ ./elasticsearch
发现问题?
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: memory locking requested for elasticsearch process but memory is not locked
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[4]: max number of threads [1024] for user [elasticsearch] is too low, increase to at least [2048]
1:文件描述符和内存锁定问题
参考文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/file-descriptors.html
参考文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html
参考文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/max-number-of-threads.html
2:解决方法
根据提示 修改 limits.conf文件
elasticsearch soft memlock unlimited elasticsearch hard memlock unlimited * hard nofile 65536 * soft nofile 65536
[root@localhost bin]# sysctl -p
fs.file-max = 65536 vm.max_map_count = 262144
4 、错误原因:启动检查未通过 elasticsearch用户的最大线程数太低
su root
修改limits.d目录下的配置文件:
vi /etc/security/limits.d/90-nproc.conf
3:再次启动elasticsearch 验证
启动命令:bin/elasticsearch &
检查ES服务是否启动
ps -ef |grep elasticsearch
检查防火墙是否关闭
systemctl disable firewalld 永久关闭防火墙命令。重启后,防火墙不会自动启动。
systemctl stop firewalld 临时关闭防火墙命令。重启电脑后,防火墙自动起来
systemctl status firewalld 查看防火墙状态
systemctl enable firewalld 打开防火墙命令
关闭防火墙。
访问 页面,检查es 是否启动完毕
来源:oschina
链接:https://my.oschina.net/u/3136594/blog/1301836