1: elasticsearch-5.4.0.tar.gzhtml
1:jdk-8u111-linux-x64.tar.gzjava
一些开发版的centos会自带jdk,咱们通常用本身的jdk,把自带的删除。先看看有没有安装java -versionnode
一、查找他们的安装位置python
[root@localhost ~]# rpm -qa | grep javalinux
java-1.8.0-openjdk-headless-1.8.0.101-3.b13.el7_2.x86_64bootstrap
tzdata-java-2016f-1.el7.noarchvim
java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64centos
javapackages-tools-3.4.1-11.el7.noarchbash
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
二、删除所有,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
三、检查有没有删除 [root@localhost ~]# java -version
-bash: /usr/bin/java: 没有那个文件或目录
一、解压 tar xvzf jdk-8u111-linux-x64.tar.gz
二、配置环境变量
输入 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 保存
三、source /etc/profile ← 使配置生效
第一种方式: wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.0.tar.gz
第二种方式:
网络很差,能够直接去官网下载
https://www.elastic.co/downloads/past-releases/elasticsearch-5-4-1
官网参考:
https://www.elastic.co/guide/en/elasticsearch/reference/current/zip-targz.html
官方文档上说Elasticsearch不适合在root管理员账号下运行,因此要先创建一个帐号专门运行Elasticsearch.
建立一个elasticsearch用户
adduser elasticsearch
passwd elasticsearch 123456
按照提示输入密码和确认密码就成功建立elasticsearch帐户了。
修改用户权限,这一步很是重要
使用vim 编辑器打开文件打开/etc 目录下面的文件sudoers
vim /etc/sudoers
i 编辑
shift+:
wq! 强制保存
改变 权限 为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文件
[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]
参考文档: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
根据提示 修改 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
启动命令:bin/elasticsearch &
检查ES服务是否启动
ps -ef |grep elasticsearch
检查防火墙是否关闭
systemctl disable firewalld 永久关闭防火墙命令。重启后,防火墙不会自动启动。
systemctl stop firewalld 临时关闭防火墙命令。重启电脑后,防火墙自动起来
systemctl status firewalld 查看防火墙状态
systemctl enable firewalld 打开防火墙命令
关闭防火墙。
访问 页面,检查es 是否启动完毕