一、安装java环境
-bash-4.2$ yum -y install java
-bash-4.2$ java -version
openjdk version "1.8.0_121"
OpenJDK Runtime Environment (build 1.8.0_121-b13)
OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)
备注:
如果是源码安装,需要声明
cat >> /etc/bashrc << END
export JAVA_HOME="/usr/java/jdk1.8.0_25"
export CLASSPATH=${JAVA_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
END
source /etc/bashrc
二、源码编译并配置elasticsearch
-bash-4.2$ tar -zxf elasticsearch-5.0.1.tar.gz -C /usr/local/
-bash-4.2$ mv elasticsearch-5.0.1 elasticsearch
-bash-4.2$ useradd elasticsearch
-bash-4.2$ echo "123456" | passwd --stdin elasticsearch
-bash-4.2$ chown elasticsearch.elasticsearch /usr/local/elasticsearch -R
-bash-4.2$ grep ^[a-Z] /usr/local/elasticsearch/config/elasticsearch.yml
cluster.name: elk-cluster
node.name: linux-node1
path.data: /data/es-data
path.logs: /var/log/elasticsearch
bootstrap.memory_lock: true
network.host: 192.168.88.133
http.port: 9200
discovery.zen.ping.unicast.hosts: ["linux-node1", "linux-node2"]
http.cors.enabled: true #跨域用的
http.cors.allow-origin: "*" #跨域用的
备注:安装注意点
①当ES配置文件中的 network.host 不是 localhost 或者 127.0.0.1 的时候,就会认为是生产环境,对环境要求比较高,所以要修改 config/jvm.options 文件,-Xms256m -Xmx256m (这个大小根据自己实际情况设定)
②在centos6的系统中需禁用 bootstrap,这时要在ES配置文件中添加: bootstrap.system_call_filter: false
三、创建所需要数据和日志文件路径
-bash-4.2$ mkdir -p /data/es-data
-bash-4.2$ mkdir -p /var/log/elasticsearch
-bash-4.2$ chown elasticsearch.elasticsearch /data/es-data -R
-bash-4.2$ chown elasticsearch.elasticsearch /var/log/elasticsearch -R
四、启动
-bash-4.2$ su - elasticsearch
-bash-4.2$ /usr/local/elasticsearch/bin/elasticsearch -d
-bash-4.2$ ps -ef | grep elasticsearch
等过一会进程就消失了
如果出现这个问题,请参考我的博文:
CentOS7上elasticsearch5.0启动失败 : http://blog.csdn.net/m0_37886429/article/details/68486682
五、重新启动,测试
备注:
1、elasticsearch不能用root用户启动,我这边采用的elasticsearch用户
-bash-4.2$
2、大环境:文件描述符和内存锁定问题
2.1 增大文件描述符
cat >> /etc/security/limits.conf << END
elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited
* hard nofile 65536
* soft nofile 65536
END
备注:必须为65536
2.2 内存锁定问题
cat >> /etc/sysctl.conf << END
fs.file-max=65536
vm.max_map_count=262144
END
sysctl -p
3、如果是rpm包安装的jdk,需要声明jdk的家目录
export JAVA_HOME=/usr/java/jdk1.8.0_131
export CLASSPATH=${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar