环境为centos 7,已经安装了jdk7, jdk必须要安装7及以上版本
切换到非root用户(目前的es不能使用root用户)
下载es并解压:
wget https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.2.1/elasticsearch-2.2.1.tar.gz tar -xvzf elasticsearch-2.2.1.tar.gz 我这里是下载和解压到当前用户的home下面
关闭防火墙
sudo systemctl stop firewalld.service
我用的是centos7所以用以上命令关闭,假如你用的是centos6可用以下命令
/etc/init.d/iptables stop //关闭防火墙服务 chkconfig –level 35 iptables off //永久关闭防火墙
运行
~/elasticsearch-2.2.1/bin/elasticsearch
以上命令是前端运行,关掉终端会结束进程,要后台运行,并且把进程的pid打印到当前目录的pid文件里面,可以加参数运行如下
~/elasticsearch-2.2.1/bin/elasticsearch -d -p pid
检查是否已经启动
[hadoop@master ~]$ curl localhost:9200 { "name" : "Redeemer", "cluster_name" : "elasticsearch", "version" : { "number" : "2.2.1", "build_hash" : "d045fc29d1932bce18b2e65ab8b297fbf6cd41a1", "build_timestamp" : "2016-03-09T09:38:54Z", "build_snapshot" : false, "lucene_version" : "5.4.1" }, "tagline" : "You Know, for Search" }
注意:此时用外网或者局域网ip是不能访问的,如果要访问,按以下修改:
vim ~/elasticsearch-2.2.1/config/elasticsearch.yml 修改配置 network.host: 0.0.0.0
安装head插件
插件安装格式为:sudo bin/plugin install [org]/[user|component]/[version]
[hadoop@master ~]$ ~/elasticsearch-2.2.1/bin/plugin install mobz/elasticsearch-head -> Installing mobz/elasticsearch-head... Trying https://github.com/mobz/elasticsearch-head/archive/master.zip ... Downloading ...................................................................................................................................................... .................................................................................................................................................................. .................................................................................................................................................................. .................................................................................................................................................................. ........................DONE Verifying https://github.com/mobz/elasticsearch-head/archive/master.zip checksums if available ... NOTE: Unable to verify checksum for downloaded plugin (unable to find .sha1 or .md5 file to verify) Installed head into /home/hadoop/elasticsearch-2.2.1/plugins/head
关闭
- 在运行的时候如果加了-p参数,那es进程的pid会写入参数指定的文件里面,然后kill pid即可
还可以通过jps命令找到es的pid
[hadoop@master ~]$ jps 30462 Jps 23584 Elasticsearch