一.安装
系统准备:
操作系统:CentOS6.4 64bit(CentOS从7.0以后有些命令不一样)
软件版本:JDK8.60,ElasticSearch1.7.7(此二者版本是有联系的。)
具体软件名称:jdk-8u60-linux-x64.tar.gz,elasticsearch-1.7.1.tar.gz
JDK下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
ElasticSearch下载地址:https://www.elastic.co/downloads/elasticsearch
安装JDK,配置java环境变量(ElasticSearch基于Lucene,而Lucene是java开发的,离不开java虚拟机),首先检查系统有无自带jdk :java -version(如若操作系统没有装一些开发库的话,jdk是不会自带的 ),,,,卸载java:yum remove java,,yum groupremove java(通过组的方式彻底删掉。)
jdk安装以及环境变量配置:# tar zxvf jdk-8u60-linux-x64.tar.gz
# vim /etc/profile
#JDK1.8
export JAVA_HOME=/opt/jdk1.8.0_111
export JAVA_BIN=/opt/jdk1.8.0_111/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN CLASSPATH
让系统配置立即生效:source /etc/profile
重启:reboot
uname -a 查看linux系统版本。
删除文件/文件夹:rm -rf文件夹 rm文件
移动文件 mv文件 目录
su切换到root用户,su 用户名 切换到普通用户
确认安装:# java -version
安装ElasticSearch
下载:wget https://www.elastic.co/downloads/past-releases/elasticsearch-1-7-1,,然后解压就安装好了。
启动ElasticSearch
进入elasticsearch bin 目录下, ./elasticsearch -d(-d是为了让服务能在后台运行)
报错:
jvm uses the client vm, make sure to run `java` with the server vm for best performance by adding `-server` to the command line
Java HotSpot(TM) Client VM warning: You have loaded library /opt/elasticsearch-1.7.1/lib/sigar/libsigar-x86-linux.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
解决:
1.[root@localhost bin]# execstack -c /opt/elasticsearch-1.7.1/lib/sigar/libsigar-x86-linux.so
2.[root@localhost bin]# java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) Client VM (build 25.111-b14, mixed mode)
./elasticsearch -server -d
检测:
elsaticsearch web服务地址:http://localhost:9200
curl -XGET http://localhost:9200
curl -GET http://localhost:9200
想确认程序是否运行,则运行
lsof -i:
9200
lsof -i:
9300
一个是节点对外服务端口,一个是节点间交互端口(如果有集群的话)。
查看日志(启动信息)
[root@localhost elasticsearch-1.7.1]# cd logs/
[root@localhost logs]# ll
total 12
-rw-r--r--. 1 root root 0 Nov 23 16:24 elasticsearch_index_indexing_slowlog.log
-rw-r--r--. 1 root root 0 Nov 23 16:24 elasticsearch_index_search_slowlog.log
-rw-r--r--. 1 root root 8549 Nov 23 16:34 elasticsearch.log
ElasticSearch目录结构
elasticsearch相关插件:
Head插件
BigDesk插件
另外还有分词插件,同步插件,数据传输插件,脚本插件,站点插件等其他插件。
https://github.com/mobz/elasticsearch-head/archive/master.zip
进入elasticsearch的bin目录,下载并安装插件:./plugin -install mobz/elasticsearch-head
sudo elasticsearch/bin/plugin -install mobz/elasticsearch-head
[root@localhost bin]# ./plugin -install mobz/elasticsearch-head
-> Installing mobz/elasticsearch-head...
Trying https://github.com/mobz/elasticsearch-head/archive/master.zip...
Downloading .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................DONE
Installed mobz/elasticsearch-head into /opt/elasticsearch-1.7.1/plugins/head
http://localhost:9200/_plugin/head/
bigdesk官网:bigdesk.org
安装:sudo elasticsearch/bin/plugin -install lukas-vlcek/bigdesk/2.5.0
[root@localhost bin]# ./plugin -install lukas-vlcek/bigdesk/2.5.0
-> Installing lukas-vlcek/bigdesk/2.5.0...
Trying http://download.elasticsearch.org/lukas-vlcek/bigdesk/bigdesk-2.5.0.zip...
Trying http://search.maven.org/remotecontent?filepath=lukas-vlcek/bigdesk/2.5.0/bigdesk-2.5.0.zip...
Trying https://oss.sonatype.org/service/local/repositories/releases/content/lukas-vlcek/bigdesk/2.5.0/bigdesk-2.5.0.zip...
Trying https://github.com/lukas-vlcek/bigdesk/archive/2.5.0.zip...
Trying https://github.com/lukDownloading ........................................................................................................................................................................................................................................................DONEas-vlcek/bigdesk/archive/master.zip...
Installed lukas-vlcek/bigdesk/2.5.0 into /opt/elasticsearch-1.7.1/plugins/bigdesk
Identified as a _site plugin, moving to _site structure ..
http://localhost:9200/_plugin/bigdesk
基本上,只要在同一网段,网络通了,然后启动相关服务,它(elasticsearch)就会自动把这个节点拉进来,,我们可以在head和bigdesk插件中看到。。所以说elasticsearch扩展性是非常强的。
主机与虚拟机互PING能通,但主机无法访问虚拟机服务:
检查防火墙是否将80端口屏蔽:telnet {服务器ip} 80
解决方法如下: /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT 然后保存: /etc/rc.d/init.d/iptables save 重启防火墙 /etc/init.d/iptables restart
CentOS防火墙的关闭,关闭其服务即可:
查看CentOS防火墙信息:
/etc/init.d/iptables status
关闭CentOS防火墙服务:
/etc/init.d/iptables stop
永久关闭防火墙:
chkconfig --level 35 iptables off
最后,打开主机浏览器,输入虚拟机地方,就可以访问虚拟机的WEB服务器了!
最直接的 打开iptables
gedit /etc/sysconfig/iptables
在里面添加下面的(增加80,8080)
-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
然后重启service iptables restart