下面是安装的操作步骤
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
java -version
ysq@ubuntu:~/Downloads$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.3.3.tar.gz
--2019-04-02 15:23:09-- https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.3.3.tar.gz
Resolving artifacts.elastic.co (artifacts.elastic.co)… 151.101.230.222, 2a04:4e42:36::734
Connecting to artifacts.elastic.co (artifacts.elastic.co)|151.101.230.222|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 33701608 (32M) [binary/octet-stream]
Saving to: ‘elasticsearch-5.3.3.tar.gz’
100%[======================================>] 33,701,608 187KB/s in 2m 8s
2019-04-02 15:25:23 (256 KB/s) - ‘elasticsearch-5.3.3.tar.gz’ saved [33701608/33701608]
ysq@ubuntu:~/Downloads$ tar -xzf elasticsearch-5.3.3.tar.gz
ysq@ubuntu:~/Downloads$ cd elasticsearch-5.3.3/
ysq@ubuntu:~/Downloads/elasticsearch-5.3.3$ ./bin/elasticsearch
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x000000008a660000, 1973026816, 0) failed; error='Cannot allocate memory' (errno=12)
#
There is insufficient memory for the Java Runtime Environment to continue.
Native memory allocation (mmap) failed to map 1973026816 bytes for committing reserved memory.
An error report file with more information is saved as:
/home/ysq/Downloads/elasticsearch-5.3.3/hs_err_pid5794.log
ysq@ubuntu:~/Downloads/elasticsearch-5.3.3$ ls
bin config hs_err_pid5794.log lib LICENSE.txt modules NOTICE.txt plugins README.textile
ysq@ubuntu:~/Downloads/elasticsearch-5.3.3$ cd config/
ysq@ubuntu:~/Downloads/elasticsearch-5.3.3/config$ ls
elasticsearch.yml jvm.options log4j2.properties
ysq@ubuntu:~/Downloads/elasticsearch-5.3.3/config$ clear
ysq@ubuntu:~/Downloads/elasticsearch-5.3.3/config$ ls
elasticsearch.yml jvm.options log4j2.properties
ysq@ubuntu:~/Downloads/elasticsearch-5.3.3/config$ sudo vim elasticsearch.yml
[sudo] password for ysq:
Sorry, try again.
[sudo] password for ysq:
sudo: vim: command not found
ysq@ubuntu:~/Downloads/elasticsearch-5.3.3/config$ sudo vim elasticsearch.yml
sudo: vim: command not found
ysq@ubuntu:~/Downloads/elasticsearch-5.3.3/config$ sudo apt-get install vim
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following package was automatically installed and is no longer required:
libdbusmenu-gtk4
Use 'apt-get autoremove' to remove it.
The following extra packages will be installed:
vim-runtime
Suggested packages:
ctags vim-doc vim-scripts
The following NEW packages will be installed:
vim vim-runtime
0 upgraded, 2 newly installed, 0 to remove and 21 not upgraded.
Need to get 5,838 kB of archives.
After this operation, 28.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main vim-runtime all 2:7.4.052-1ubuntu3.1 [4,882 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main vim amd64 2:7.4.052-1ubuntu3.1 [955 kB]
Fetched 5,838 kB in 9s (648 kB/s)
Selecting previously unselected package vim-runtime.
(Reading database … 167157 files and directories currently installed.)
Preparing to unpack …/vim-runtime_2%3a7.4.052-1ubuntu3.1_all.deb …
Adding 'diversion of /usr/share/vim/vim74/doc/help.txt to /usr/share/vim/vim74/doc/help.txt.vim-tiny by vim-runtime'
Adding 'diversion of /usr/share/vim/vim74/doc/tags to /usr/share/vim/vim74/doc/tags.vim-tiny by vim-runtime'
Unpacking vim-runtime (2:7.4.052-1ubuntu3.1) …
Selecting previously unselected package vim.
Preparing to unpack …/vim_2%3a7.4.052-1ubuntu3.1_amd64.deb …
Unpacking vim (2:7.4.052-1ubuntu3.1) …
Processing triggers for man-db (2.6.7.1-1ubuntu1) …
Setting up vim-runtime (2:7.4.052-1ubuntu3.1) …
Processing /usr/share/vim/addons/doc
Setting up vim (2:7.4.052-1ubuntu3.1) …
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rvim (rvim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rview (rview) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/view (view) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/ex (ex) in auto mode
ysq@ubuntu:~/Downloads/elasticsearch-5.3.3/config$ sudo vim elasticsearch.yml
ysq@ubuntu:~/Downloads/elasticsearch-5.3.3/config$ ls
elasticsearch.yml jvm.options log4j2.properties
ysq@ubuntu:~/Downloads/elasticsearch-5.3.3/config$ sudo vim jvm.options
ysq@ubuntu:~/Downloads/elasticsearch-5.3.3/config$ cd ..
ysq@ubuntu:~/Downloads/elasticsearch-5.3.3$ ./bin/elasticsearch
[2019-04-02T00:36:35,067][INFO ][o.e.n.Node ] [] initializing …
[2019-04-02T00:36:35,161][INFO ][o.e.e.NodeEnvironment ] [tJfB8H1] using [1] data paths, mounts [[/ (/dev/sda1)]], net usable_space [53.8gb], net total_space [61.8gb], spins? [no], types [ext4]
[2019-04-02T00:36:35,161][INFO ][o.e.e.NodeEnvironment ] [tJfB8H1] heap size [123.7mb], compressed ordinary object pointers [true]
[2019-04-02T00:36:35,162][INFO ][o.e.n.Node ] node name [tJfB8H1] derived from node ID [tJfB8H1ARa-Xz51bL_2Z5A]; set [node.name] to override
[2019-04-02T00:36:35,162][INFO ][o.e.n.Node ] version[5.3.3], pid[7984], build[65e26e6/2017-05-22T12:03:12.318Z], OS[Linux/4.4.0-31-generic/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_201/25.201-b09]
[2019-04-02T00:36:36,029][INFO ][o.e.p.PluginsService ] [tJfB8H1] loaded module [aggs-matrix-stats]
[2019-04-02T00:36:36,030][INFO ][o.e.p.PluginsService ] [tJfB8H1] loaded module [ingest-common]
[2019-04-02T00:36:36,030][INFO ][o.e.p.PluginsService ] [tJfB8H1] loaded module [lang-expression]
[2019-04-02T00:36:36,030][INFO ][o.e.p.PluginsService ] [tJfB8H1] loaded module [lang-groovy]
[2019-04-02T00:36:36,031][INFO ][o.e.p.PluginsService ] [tJfB8H1] loaded module [lang-mustache]
[2019-04-02T00:36:36,031][INFO ][o.e.p.PluginsService ] [tJfB8H1] loaded module [lang-painless]
[2019-04-02T00:36:36,031][INFO ][o.e.p.PluginsService ] [tJfB8H1] loaded module [percolator]
[2019-04-02T00:36:36,031][INFO ][o.e.p.PluginsService ] [tJfB8H1] loaded module [reindex]
[2019-04-02T00:36:36,032][INFO ][o.e.p.PluginsService ] [tJfB8H1] loaded module [transport-netty3]
[2019-04-02T00:36:36,032][INFO ][o.e.p.PluginsService ] [tJfB8H1] loaded module [transport-netty4]
[2019-04-02T00:36:36,033][INFO ][o.e.p.PluginsService ] [tJfB8H1] no plugins loaded
[2019-04-02T00:36:38,034][INFO ][o.e.n.Node ] initialized
[2019-04-02T00:36:38,034][INFO ][o.e.n.Node ] [tJfB8H1] starting …
[2019-04-02T00:36:38,220][INFO ][o.e.t.TransportService ] [tJfB8H1] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2019-04-02T00:36:38,226][WARN ][o.e.b.BootstrapChecks ] [tJfB8H1] max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2019-04-02T00:36:38,227][WARN ][o.e.b.BootstrapChecks ] [tJfB8H1] max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2019-04-02T00:36:41,294][INFO ][o.e.c.s.ClusterService ] [tJfB8H1] new_master {tJfB8H1}{tJfB8H1ARa-Xz51bL_2Z5A}{Gyq6lhBmQ9GiitP2G5j5FA}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2019-04-02T00:36:41,346][INFO ][o.e.g.GatewayService ] [tJfB8H1] recovered [0] indices into cluster_state
[2019-04-02T00:36:41,353][INFO ][o.e.h.n.Netty4HttpServerTransport] [tJfB8H1] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2019-04-02T00:36:41,357][INFO ][o.e.n.Node ] [tJfB8H1] started
内存较小,启动失败,修改jvm.options
sudo vim jvm.options
使用代码测试
ps -ef|grep elasticsearch
curl 127.0.0.1:9200
下面的安装成功后的界面
ysq@ubuntu:~$ ps -ef|grep elasticsearch
ysq 7984 2578 20 15:36 pts/5 00:00:08 /usr/lib/jvm/java-8-oracle/bin/java -Xms128m -Xmx128m -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -server -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -Djdk.io.permissionsUseCanonicalPath=true -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Dlog4j.skipJansi=true -XX:+HeapDumpOnOutOfMemoryError -Des.path.home=/home/ysq/Downloads/elasticsearch-5.3.3 -cp /home/ysq/Downloads/elasticsearch-5.3.3/lib/elasticsearch-5.3.3.jar:/home/ysq/Downloads/elasticsearch-5.3.3/lib/* org.elasticsearch.bootstrap.Elasticsearch
ysq 8227 8132 0 15:37 pts/0 00:00:00 grep –color=auto elasticsearch
ysq@ubuntu:~$ curl 127.0.0.1:9200
{
“name” : “tJfB8H1”,
“cluster_name” : “elasticsearch”,
“cluster_uuid” : “HKHSLKd1T1Ci_zL3xvN50w”,
“version” : {
“number” : “5.3.3”,
“build_hash” : “65e26e6”,
“build_date” : “2017-05-22T12:03:12.318Z”,
“build_snapshot” : false,
“lucene_version” : “6.4.2”
},
“tagline” : “You Know, for Search”
}