扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
公司之前的elasticsearch版本为1.7版本,由于体验更多的特性,需要把1.7版本升级到最新版本2.2.1
公司主营业务:成都做网站、网站设计、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。成都创新互联是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。成都创新互联推出宿迁免费做网站回馈大家。
查看java版本,官方推荐最低为1.7 [root@dev lib64]# java -version java version "1.8.0_31" Java(TM) SE Runtime Environment (build 1.8.0_31-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode) 下载ela 2.2.1版本的rpm包,并进行安装 [root@dev tmp]# yum localinstall elasticsearch-2.2.1.rpm Loaded plugins: fastestmirror Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast Examining elasticsearch-2.2.1.rpm: elasticsearch-2.2.1-1.noarch Marking elasticsearch-2.2.1.rpm as an update to elasticsearch-1.7.4-1.noarch Resolving Dependencies --> Running transaction check ---> Package elasticsearch.noarch 0:1.7.4-1 will be updated ---> Package elasticsearch.noarch 0:2.2.1-1 will be an update --> Finished Dependency Resolution Dependencies Resolved ============================================================================= Package Arch Version Repository Size ============================================================================= Updating: elasticsearch noarch 2.2.1-1 /elasticsearch-2.2.1 31 M Transaction Summary ============================================================================= Upgrade 1 Package Total size: 31 M Is this ok [y/d/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : elasticsearch-2.2.1-1.noarch 1/2 warning: /etc/elasticsearch/elasticsearch.yml created as /etc/elasticsearch/elasticsearch.yml.rpmnew warning: /etc/sysconfig/elasticsearch created as /etc/sysconfig/elasticsearch.rpmnew Cleanup : elasticsearch-1.7.4-1.noarch 2/2 warning: file /tmp/elasticsearch: remove failed: No such file or directory Verifying : elasticsearch-2.2.1-1.noarch 1/2 Verifying : elasticsearch-1.7.4-1.noarch 2/2 Updated: elasticsearch.noarch 0:2.2.1-1 Complete! 尝试启动服务 [root@dev tmp]# /etc/init.d/elasticsearch start Starting elasticsearch (via systemctl): Warning: elasticsearch.service changed on disk. Run 'systemctl daemon-reload' to reload units. [ OK ] [root@dev tmp]# /etc/init.d/elasticsearch status CONF_FILE setting is no longer supported. elasticsearch.yml must be placed in the config directory and cannot be renamed. [root@dev tmp]# /etc/init.d/elasticsearch status ● elasticsearch.service - Elasticsearch Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Tue 2016-03-29 06:18:15 EDT; 4min 7s ago Docs: http://www.elastic.co Process: 3301 ExecStart=/usr/share/elasticsearch/bin/elasticsearch -Des.pidfile=${PID_DIR}/elasticsearch.pid -Des.default.path.home=${ES_HOME} -Des.default.path.logs=${LOG_DIR} -Des.default.path.data=${DATA_DIR} -Des.default.path.conf=${CONF_DIR} (code=exited, status=1/FAILURE) Process: 3299 ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec (code=exited, status=0/SUCCESS) Main PID: 3301 (code=exited, status=1/FAILURE) Mar 29 06:18:15 dev.wware.org elasticsearch[3301]: at org.elasticsearch.node.Node.(Node.java:153) Mar 29 06:18:15 dev.wware.org elasticsearch[3301]: at org.elasticsearch.node.Node. (Node.java:128) Mar 29 06:18:15 dev.wware.org elasticsearch[3301]: at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:145) Mar 29 06:18:15 dev.wware.org elasticsearch[3301]: at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:178) Mar 29 06:18:15 dev.wware.org elasticsearch[3301]: at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:285) Mar 29 06:18:15 dev.wware.org elasticsearch[3301]: at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35) Mar 29 06:18:15 dev.wware.org elasticsearch[3301]: Refer to the log for complete error details. Mar 29 06:18:15 dev.wware.org systemd[1]: elasticsearch.service: main process exited, code=exited, status=1/FAILURE Mar 29 06:18:15 dev.wware.org systemd[1]: Unit elasticsearch.service entered failed state. Mar 29 06:18:15 dev.wware.org systemd[1]: elasticsearch.service failed. [root@dev tmp]# 查看log [2016-03-29 06:24:44,501][INFO ][node ] [Snowfall] version[2.2.1], pid[3583], build[d045fc2/2016-03-09T09:38:54Z] [2016-03-29 06:24:44,502][INFO ][node ] [Snowfall] initializing ... [2016-03-29 06:24:45,225][INFO ][plugins ] [Snowfall] modules [lang-expression, lang-groovy], plugins [], sites [] [2016-03-29 06:24:45,249][ERROR][bootstrap ] Exception java.lang.IllegalStateException: Failed to created node environment at org.elasticsearch.node.Node. (Node.java:155) at org.elasticsearch.node.Node. (Node.java:128) at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:145) at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:178) at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:285) at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35) Caused by: java.nio.file.AccessDeniedException: /var/lib/elasticsearch/elasticsearch/nodes/1 at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84) at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384) at java.nio.file.Files.createDirectory(Files.java:674) at java.nio.file.Files.createAndCheckIsDirectory(Files.java:781) at java.nio.file.Files.createDirectories(Files.java:767) at org.elasticsearch.env.NodeEnvironment. (NodeEnvironment.java:169) at org.elasticsearch.node.Node. (Node.java:153) ... 5 more
看来升级安装后,服务会起不来,是node环境的问题,把之前的文件全部删掉,全新安装
[root@dev lib64]# find / -name "elasticsearch" -exec rm -rf {} \;
再次安装
[root@dev tmp]# yum localinstall elasticsearch-2.2.1.rpm Loaded plugins: fastestmirror Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast Examining elasticsearch-2.2.1.rpm: elasticsearch-2.2.1-1.noarch Marking elasticsearch-2.2.1.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package elasticsearch.noarch 0:2.2.1-1 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================= Package Arch Version Repository Size ============================================================================= Installing: elasticsearch noarch 2.2.1-1 /elasticsearch-2.2.1 31 M Transaction Summary ============================================================================= Install 1 Package Total size: 31 M Installed size: 31 M Is this ok [y/d/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Creating elasticsearch group... OK Creating elasticsearch user... OK Installing : elasticsearch-2.2.1-1.noarch 1/1 ### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd sudo systemctl daemon-reload sudo systemctl enable elasticsearch.service ### You can start elasticsearch service by executing sudo systemctl start elasticsearch.service Verifying : elasticsearch-2.2.1-1.noarch 1/1 Installed: elasticsearch.noarch 0:2.2.1-1 Complete! [root@dev tmp]# sudo systemctl daemon-reload [root@dev tmp]# sudo systemctl enable elasticsearch.service Created symlink from /etc/systemd/system/multi-user.target.wants/elasticsearch.service to /usr/lib/systemd/system/elasticsearch.service. [root@dev tmp]# sudo systemctl start elasticsearch.service [root@dev tmp]# sudo systemctl status elasticsearch.service ● elasticsearch.service - Elasticsearch Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2016-03-29 06:35:17 EDT; 5s ago Docs: http://www.elastic.co Process: 3992 ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec (code=exited, status=0/SUCCESS) Main PID: 3994 (java) CGroup: /system.slice/elasticsearch.service └─3994 /bin/java -Xms256m -Xmx1g -Djava.awt.headless=true -XX:+... Mar 29 06:35:18 dev.wware.org elasticsearch[3994]: [2016-03-29 06:35:18,91... Mar 29 06:35:18 dev.wware.org elasticsearch[3994]: [2016-03-29 06:35:18,91... Mar 29 06:35:19 dev.wware.org elasticsearch[3994]: [2016-03-29 06:35:19,65... Mar 29 06:35:19 dev.wware.org elasticsearch[3994]: [2016-03-29 06:35:19,68... Mar 29 06:35:19 dev.wware.org elasticsearch[3994]: [2016-03-29 06:35:19,68... Mar 29 06:35:19 dev.wware.org elasticsearch[3994]: [2016-03-29 06:35:19,68... Mar 29 06:35:22 dev.wware.org elasticsearch[3994]: [2016-03-29 06:35:22,70... Mar 29 06:35:22 dev.wware.org elasticsearch[3994]: [2016-03-29 06:35:22,70... Mar 29 06:35:22 dev.wware.org elasticsearch[3994]: [2016-03-29 06:35:22,90... Mar 29 06:35:22 dev.wware.org elasticsearch[3994]: [2016-03-29 06:35:22,94... Hint: Some lines were ellipsized, use -l to show in full. [root@dev tmp]# sudo systemctl status elasticsearch.service ● elasticsearch.service - Elasticsearch Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2016-03-29 06:35:17 EDT; 6s ago Docs: http://www.elastic.co Process: 3992 ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec (code=exited, status=0/SUCCESS) Main PID: 3994 (java) CGroup: /system.slice/elasticsearch.service └─3994 /bin/java -Xms256m -Xmx1g -Djava.awt.headless=true -XX:+... Mar 29 06:35:18 dev.wware.org elasticsearch[3994]: [2016-03-29 06:35:18,91... Mar 29 06:35:18 dev.wware.org elasticsearch[3994]: [2016-03-29 06:35:18,91... Mar 29 06:35:19 dev.wware.org elasticsearch[3994]: [2016-03-29 06:35:19,65... Mar 29 06:35:19 dev.wware.org elasticsearch[3994]: [2016-03-29 06:35:19,68... Mar 29 06:35:19 dev.wware.org elasticsearch[3994]: [2016-03-29 06:35:19,68... Mar 29 06:35:19 dev.wware.org elasticsearch[3994]: [2016-03-29 06:35:19,68... Mar 29 06:35:22 dev.wware.org elasticsearch[3994]: [2016-03-29 06:35:22,70... Mar 29 06:35:22 dev.wware.org elasticsearch[3994]: [2016-03-29 06:35:22,70... Mar 29 06:35:22 dev.wware.org elasticsearch[3994]: [2016-03-29 06:35:22,90... Mar 29 06:35:22 dev.wware.org elasticsearch[3994]: [2016-03-29 06:35:22,94... Hint: Some lines were ellipsized, use -l to show in full.
查看端口
[root@dev tmp]# lsof -i:9200 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME java 3994 elasticsearch 112u IPv6 54287 0t0 TCP localhost:wap-wsp (LISTEN) java 3994 elasticsearch 113u IPv6 54288 0t0 TCP localhost:wap-wsp (LISTEN)
端口没监听在ipv4上。
看来下官方文档, elasticsearch默认监听在localhost上,修改配置文件,把127.0.0.1改为本机ip
[root@dev elasticsearch]# vim elasticsearch.yml network.host: 10.0.2.15 使用curl访问下 [root@dev elasticsearch]# curl 10.0.2.15:9200 { "name" : "Bulldozer", "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" }
使用浏览器访问
http://10.0.2.15:9200/ { "name" : "Bulldozer", "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" }
公司需要安装analysis-smartcn和mapper-p_w_uploads
[root@dev elasticsearch]# find / -type f -name plugin /usr/share/elasticsearch/bin/plugin [root@dev elasticsearch]# /usr/share/elasticsearch/bin/plugin install analysis-smartcn -> Installing analysis-smartcn... Trying https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/analysis-smartcn/2.2.1/analysis-smartcn-2.2.1.zip ... Downloading .............................................................................................................................................................................................................................DONE Verifying https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/analysis-smartcn/2.2.1/analysis-smartcn-2.2.1.zip checksums if available ... Downloading .DONE root@dev elasticsearch]# /usr/share/elasticsearch/bin/plugin install mapper-p_w_uploads -> Installing mapper-p_w_uploads... Trying https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/mapper-p_w_uploads/2.2.1/mapper-p_w_uploads-2.2.1.zip ... Downloading ........................................................ 安装这两个插件时会被墙掉,可以自己先wget下来,然后使用/usr/share/elasticsearch/bin/plugin install +rurl指定安装包安装。 如果需要使用http访问elasticsearch数据库,需要安装head,安装 /usr/share/elasticsearch/bin/plugin install mobz/elasticsearch-head 使用浏览器访问 10.0.2.15:9200/_plugin/head/ 可以看到数据。
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流