今天调试一个现有项目报错,
[Faraday::ConnectionFailed] Connection refused - connect(2) {:host=>"localhost", :port=>"9200", :protocol=>"http"} Connection refused - connect(2)
发现自己还没装elasticsearch
找到官网下载页https://www.elastic.co/guide/en/elasticsearch/reference/current/_installation.html
看到第一句话发现自己还需要先装java:
Elasticsearch requires at least Java 7. Specifically as of this writing, it is recommended that you use the Oracle JDK version 1.8.0_25. Java installation varies from platform to platform so we won’t go into those details here.
于是查阅了ubuntu安装java的指南,并且看了下stackoverflow里的大神经验贴
https://help.ubuntu.com/community/Java
http://stackoverflow.com/questions/16263556/installing-java-7-on-ubuntu
(1)开始使用大神经验贴里的步骤安装java
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java7-installer
(2)装完java查看下就可以继续装elasticsearch啦
步骤就是官网下载页里提供的:
https://www.elastic.co/guide/en/elasticsearch/reference/current/_installation.html
java -version
echo $JAVA_HOME
curl -L -O https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.1.tar.gz
tar -xvf elasticsearch-1.7.1.tar.gz
cd elasticsearch-1.7.1/bin
./elasticsearch
If everything goes well, you should see a bunch of messages that look like below:
17,218][INFO ][node ] [New Goblin] version[1.7.1], pid[2085], build[5c03844/2014-02-25T15:52:53Z] [2014-03-13 13:42:17,219][INFO ][node ] [New Goblin] initializing ... [2014-03-13 13:42:17,223][INFO ][plugins ] [New Goblin] loaded [], sites [] [2014-03-13 13:42:19,831][INFO ][node ] [New Goblin] initialized [2014-03-13 13:42:19,832][INFO ][node ] [New Goblin] starting ... [2014-03-13 13:42:19,958][INFO ][transport ] [New Goblin] bound_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish_address {inet[/192.168.8.112:9300]} [2014-03-13 13:42:23,030][INFO ][cluster.service] [New Goblin] new_master [New Goblin][rWMtGj3dQouz2r6ZFL9v4g][mwubuntu1][inet[/192.168.8.112:9300]], reason: zen-disco-join (elected_as_master) [2014-03-13 13:42:23,100][INFO ][discovery ] [New Goblin] elasticsearch/rWMtGj3dQouz2r6ZFL9v4g [2014-03-13 13:42:23,125][INFO ][http ] [New Goblin] bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address {inet[/192.168.8.112:9200]} [2014-03-13 13:42:23,629][INFO ][gateway ] [New Goblin] recovered [1] indices into cluster_state [2014-03-13 13:42:23,630][INFO ][node ] [New Goblin] started
(3)还要安装rails集成的相关gem
https://github.com/elastic/elasticsearch-rails
gem install elasticsearch-model elasticsearch-rails