您好,登錄后才能下訂單哦!
公司之前的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.<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. [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.<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環境的問題,把之前的文件全部刪掉,全新安裝
[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/ 可以看到數據。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。