Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install es on Mac #4

Open
happypeter opened this issue Jul 9, 2014 · 10 comments
Open

install es on Mac #4

happypeter opened this issue Jul 9, 2014 · 10 comments

Comments

@happypeter
Copy link
Collaborator

brew update && brew install elasticsearch

then I see

billie@bogon:~/apps/happycasts% brew install elasticsearch
==> Downloading https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.2.1.tar.gz
######################################################################## 100.0%
==> Caveats
Data:    /usr/local/var/elasticsearch/elasticsearch_billie/
Logs:    /usr/local/var/log/elasticsearch/elasticsearch_billie.log
Plugins: /usr/local/var/lib/elasticsearch/plugins/

ElasticSearch requires Java 7; you will need to install an appropriate JDK.

To have launchd start elasticsearch at login:
    ln -sfv /usr/local/opt/elasticsearch/*.plist ~/Library/LaunchAgents
Then to load elasticsearch now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
Or, if you don't want/need launchctl, you can just run:
    elasticsearch --config=/usr/local/opt/elasticsearch/config/elasticsearch.yml
==> Summary
🍺  /usr/local/Cellar/elasticsearch/1.2.1: 31 files, 21M, built in 43 seconds
@happypeter
Copy link
Collaborator Author

在 Mac 上装了 Java7 之后, chrome 就不能运行 Java 了,可能导致一些 applet 不能用(可能一些银行网站会受影响?)

Java 7 and Chrome on Mac OS X and Linux
Chrome does not support Java 7 on the Mac or Linux platforms.
A 64-bit browser (Safari or Firefox, for example) is required to run Java 7 on Mac OS X. 32-bit browsers such as Chrome do not support Java 7 on the Mac platform. Firefox is the recommended browser for Java on Linux.

不管他,实在不行用 safari,这些狗屎的落后技术。

@happypeter
Copy link
Collaborator Author

显然我需要安装 java7:

打开 terminal,看起来不太对劲

billie@bogon:~% java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

重启了一下,还是一样,而且试了一下 chrome 用 boc.cn 也还可以用

但是用 safari 打开:https://www.java.com/en/download/help/mac_install.xml
点击上面的 test_applet 可以看到 “Java 7 installed" 的字样。
screen shot 2014-07-09 at 4 42 10 pm

@happypeter
Copy link
Collaborator Author

运行

ln -sfv /usr/local/opt/elasticsearch/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist

@happypeter
Copy link
Collaborator Author

启动应用,试图去使用搜素功能,报错:

(Connection refused - connect(2)):

terminal 里去运行 es 报错:

billie@bogon:~% elasticsearch
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/elasticsearch/bootstrap/Elasticsearch : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

看来目前依然是 java6 (1.6 就是 6? YES)

billie@bogon:~% java -version
java version "1.6.0_65"
n% java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)
billie@bogon:/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin% ./java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)
billie@bogon:/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin%

终于在 system preference 下找到 java7 的安装位置了:http://java.com/en/download/faq/java_mac.xml#version,原来在 /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin

但是直接把这个 path 导出成 JAVA_HOME 依然是不灵的:

billie@bogon:~% export JAVA_HOME='/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin'
billie@bogon:~% cd $JAVA_HOME
billie@bogon:~JAVA_HOME% ./java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)
billie@bogon:~JAVA_HOME% java -version
Unable to locate an executable at "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/bin/java" (-1)

@happypeter
Copy link
Collaborator Author

但是直接把这个 path 导出成 JAVA_HOME 依然是不灵的:

其实是可以的,上面 export 时,最后多了 bin/ 去掉就好了:

export JAVA_HOME='/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home'
➜  ~JAVA_HOME  java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)

这时命令行执行 $ elasticsearch 也跑起来了。

@happypeter
Copy link
Collaborator Author

现在再去执行搜索,报错

Elasticsearch::Transport::Transport::Errors::NotFound in Users#search
Showing /Users/Billie/apps/ppweb/app/views/users/search.html.erb where line #3 raised:

[404] {"error":"IndexMissingException[[users] missing]","status":404}

解决方法:要”索引数据“,参考:http://happycasts.github.io/ep/elasticsearch-setup/

@happypeter
Copy link
Collaborator Author

好,现在 es 可以工作了。

@happypeter
Copy link
Collaborator Author

重启机器, es 没有起来。es 本身的 plist 已经加载了,所以看来是 java7 没有加载。

export JAVA_HOME='/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home'

ADD TO ~/.zshrc. 也还是不行。 需要一种开机就加载 java 的方式。先不折腾了,启动机器后,打开终端,自己起一下 es 就能用了。

$ elasticsearch

@chiehwen
Copy link

thanks for sharing

@happypeter
Copy link
Collaborator Author

@chiehwen You're welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants