升级安装elastcsearch

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了升级安装elastcsearch相关的知识,希望对你有一定的参考价值。

公司之前的elasticsearch版本为1.7版本,由于体验更多的特性,需要把1.7版本升级到最新版本2.2.1

查看java版本,官方推荐最低为1.7
[[email protected] 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包,并进行安装
[[email protected] 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!
尝试启动服务
[[email protected] tmp]# /etc/init.d/elasticsearch start
Starting elasticsearch (via systemctl):  Warning: elasticsearch.service changed on disk. Run ‘systemctl daemon-reload‘ to reload units.
                                                           [  OK  ]
[[email protected] 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.

[[email protected] 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.<init>(Node.java:153)
Mar 29 06:18:15 dev.wware.org elasticsearch[3301]: at org.elasticsearch.node.Node.<init>(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.
[[email protected] 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.<init>(Node.java:155)
	at org.elasticsearch.node.Node.<init>(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.<init>(NodeEnvironment.java:169)
	at org.elasticsearch.node.Node.<init>(Node.java:153)
	... 5 more

看来升级安装后,服务会起不来,是node环境的问题,把之前的文件全部删掉,全新安装

[[email protected] lib64]# find / -name "elasticsearch" -exec  rm -rf {} \;

再次安装

[[email protected] 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!
[[email protected] tmp]# sudo systemctl daemon-reload
[[email protected] 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.
[[email protected] tmp]# sudo systemctl start elasticsearch.service
[[email protected] 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.
[[email protected] 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.

查看端口

[[email protected] 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上。

comment:2

看来下官方文档, elasticsearch默认监听在localhost上,修改配置文件,把127.0.0.1改为本机ip

[[email protected] elasticsearch]# vim elasticsearch.yml
network.host: 10.0.2.15
使用curl访问下
[[email protected] 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-attachments


[[email protected] elasticsearch]# find / -type f -name plugin
/usr/share/elasticsearch/bin/plugin
[[email protected] 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
[email protected] elasticsearch]# /usr/share/elasticsearch/bin/plugin install mapper-attachments
-> Installing mapper-attachments...
Trying https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/mapper-attachments/2.2.1/mapper-attachments-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/
可以看到数据。

本文出自 “完美世界!” 博客,请务必保留此出处http://shyln.blog.51cto.com/6890594/1758284

以上是关于升级安装elastcsearch的主要内容,如果未能解决你的问题,请参考以下文章

2C++ 的升级

在android studio中升级repo v9后,片段必须是公共静态类崩溃错误

javascript 即兼容性升级页面样式片段

在Tomcat的安装目录下conf目录下的server.xml文件中增加一个xml代码片段,该代码片段中每个属性的含义与用途

PHP代码-psysh调试代码片段工具

我升级到 Android Studio 2.3.3,一个旧的、无错误的程序现在给出错误:“片段应该是静态的......”