1. Elasticsearch 需要使用 Java,请检查 Java 环境
//检查Java版本
$ java -version
//若未找到Java命令,请安装:
$ yum install java-1.8.0-openjdk.x86_64
//再次检查Java安装
$ java -version
2.下载并安装 Elasticsearch 公共签名密钥:
$ rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch
//此步骤要求简单的 vi 编辑器操作技能
$ vi /etc/yum.repos.d/elasticsearch.repo
//填入 并 保存:
[elasticsearch-6.x]
name=Elasticsearch repository for 6.x packages
baseurl=https://artifacts.elastic.co/packages/6.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
3.安装 Elasticsearch :
$ yum install elasticsearch
4.设置ES自启动:
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
//相关ES操作可输入查看:
service elasticsearch
5.检查ES运行状态:
$ curl localhost:9200
//如有如下类似返回,则说明运行正常:
[root@localhost ~]$ curl localhost:9200
{
"name" : "ZGws7ZX",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "yeYDTLbNQ--rmDXMi2xO-g",
"version" : {
"number" : "*。*。*",
"build_hash" : "b2f0c09",
"build_date" : "2017-08-14T12:33:14.154Z",
"build_snapshot" : false,
"lucene_version" : "6.6.0"
},
"tagline" : "You Know, for Search"
对于服务器内存比较小的需要设置内存大小
vi /etc/elasticsearch/jvm.options
默认是: -Xms1g -Xmx1g 修改为: -Xms256m -Xmx256m