欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

linux安装elasticsearch

程序员文章站 2022-05-27 22:14:49
环境: centOS7 Elasticsearch-6.6.1 JDK8 准备: jdk下载地址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html elasticsearch下载地 ......

环境:

centos7  elasticsearch-6.6.1  jdk8

准备:

jdk下载地址:

elasticsearch下载地址:

安装:

jdk安装:

1.删除自带的jdk

java -version
rpm -qa | grep java
yum -y remove ***

2.安装

mkdir /usr/jdk
tar -xvf jdk-8u112-linux-x64.tar.gz /usr/jdk

3.配置环境变量

vim /etc/profile

添加如下内容

export java_home=/usr/jdk/jdk1.8.0_112  
export path=$java_home/bin:$path
export classpath=.:$java_home/lib/dt.jar:$java_home/lib/tools.jar

保存退出,是配置生效

source /etc/profile

4.查看是否安装成功

java -version

elasticsearch安装

1.解压并拷贝

tar -zxvf elasticsearch-6.6.1.tar.gz
mv elasticsearch-6.6.1 /usr/local/src/elasticsearch

 2.创建用户和用户组

groupadd elasticsearch
useradd elasticsearch -g elasticsearch
chown -r elasticsearch:elasticsearch /usr/local/elasticsearch

3.创建数据文件和日志文件

mkdir /data/es/{data,logs,work} -p
chown -r /data/es

4.修改elasticsearch配置文件

cluster.name: es-cluster
node.name: node-1
network.host: 192.168.227.130
http.port: 9200
transport.tcp.port: 9300
node.master: true
node.data: true
#path.conf: /usr/local/src/elasticsearch/conf
path.data: /data/es/data
#path.work: /data/es/work
path.logs: /data/es/logs
discovery.zen.ping.unicast.hosts: ["192.168.227.130:9300", "192.168.227.131:9300", "192.168.227.132:9300"]
discovery.zen.minimum_master_nodes: 1
http.cors.enabled: true
http.cors.allow-origin: "*"

5.启动

cd /usr/local/src/elasticsearch/bin
./elasticsearch -d

6.查看是否启动成功

[root@bogon bin]# curl http://192.168.227.130:9200
{
  "name" : "node-1",
  "cluster_name" : "es-cluster",
  "cluster_uuid" : "iflcurw-se-u9-njsb9a_g",
  "version" : {
    "number" : "6.6.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "1fd8f69",
    "build_date" : "2019-02-13t17:10:04.160291z",
    "build_snapshot" : false,
    "lucene_version" : "7.6.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "you know, for search"
}