ES学习经历一,安装和启动

[BEGIN] 2018/1/31 15:46:15
[2018/1/31 15:46:15] 不从 skel 目录里向其中复制任何文件。
[root@bogon ~]# 
Connection closed.
Disconnected from remote host(192.168.0.154) at 15:46:05.
Type `help' to learn how to use Xshell prompt.
[d:\~]$ 
Connecting to 192.168.0.154:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Last login: Wed Jan 31 22:46:26 2018 from 192.168.0.122
//通过ftp将压缩包传输进来
[2018/1/31 15:47:37] [root@bogon data]# ll
[2018/1/31 15:47:37] 总用量 95548
[2018/1/31 15:47:37] -rw-r--r--. 1 gaocc root  9536557 1月  26 19:19 apache-tomcat-8.5.27.tar.gz
[2018/1/31 15:47:37] -rw-r--r--. 1 gaocc root      356 1月  26 18:16 copy-folder.zip
[2018/1/31 15:47:37] -rw-r--r--. 1 gaocc root 33485703 1月   3 02:36 elasticsearch-5.5.2.tar.gz
[2018/1/31 15:47:37] -rw-r--r--. 1 gaocc root 54792288 1月  26 18:54 server-jre-8u161-linux-x64.tar.gz
[2018/1/31 15:47:37] -rw-r--r--. 1 gaocc root     8722 8月  14 21:15 test.xlsx
//解压
[2018/1/31 15:50:38] [root@bogon data]# tar -xzvf elasticsearch-5.5.2.tar.gz 
[2018/1/31 15:50:38] elasticsearch-5.5.2/
[2018/1/31 15:50:38] elasticsearch-5.5.2/lib/
…………
[2018/1/31 15:50:41] [root@bogon data]# ll
[2018/1/31 15:50:41] 总用量 95552
[2018/1/31 15:50:41] -rw-r--r--. 1 gaocc root  9536557 1月  26 19:19 apache-tomcat-8.5.27.tar.gz
[2018/1/31 15:50:41] -rw-r--r--. 1 gaocc root      356 1月  26 18:16 copy-folder.zip
[2018/1/31 15:50:41] drwxr-xr-x. 7 root  root     4096 8月  14 20:35 elasticsearch-5.5.2
[2018/1/31 15:50:41] -rw-r--r--. 1 gaocc root 33485703 1月   3 02:36 elasticsearch-5.5.2.tar.gz
[2018/1/31 15:50:41] -rw-r--r--. 1 gaocc root 54792288 1月  26 18:54 server-jre-8u161-linux-x64.tar.gz
//新建文件夹es,将elasticsearch转移
[2018/1/31 15:50:41] -rw-r--r--. 1 gaocc root     8722 8月  14 21:15 test.xlsx
[2018/1/31 15:50:58] [root@bogon data]# mkdir /home/es
[2018/1/31 15:51:22] [root@bogon data]# cp -r elasticsearch-5.5.2 /home/es/
[2018/1/31 15:51:34] [root@bogon data]# ll /home/es/
[2018/1/31 15:51:34] 总用量 4
[2018/1/31 15:51:34] drwxr-xr-x. 7 root root 4096 1月  31 23:51 elasticsearch-5.5.2
//查看es包含的内容,主要关心bin和config
[2018/1/31 15:51:43] [root@bogon data]# ll /home/es/elasticsearch-5.5.2/
[2018/1/31 15:51:43] 总用量 228
[2018/1/31 15:51:43] drwxr-xr-x.  2 root root   4096 1月  31 23:51 bin
[2018/1/31 15:51:43] drwxr-xr-x.  2 root root     72 1月  31 23:51 config
[2018/1/31 15:51:43] drwxr-xr-x.  2 root root   4096 1月  31 23:51 lib
[2018/1/31 15:51:43] -rw-r--r--.  1 root root  11358 1月  31 23:51 LICENSE.txt
[2018/1/31 15:51:43] drwxr-xr-x. 13 root root   4096 1月  31 23:51 modules
[2018/1/31 15:51:43] -rw-r--r--.  1 root root 194187 1月  31 23:51 NOTICE.txt
[2018/1/31 15:51:43] drwxr-xr-x.  2 root root      6 1月  31 23:51 plugins
[2018/1/31 15:51:43] -rw-r--r--.  1 root root   9549 1月  31 23:51 README.textile
//bin内容,elasticsearch为启动文件
[2018/1/31 15:53:43] [root@bogon data]# ll /home/es/elasticsearch-5.5.2/bin/
[2018/1/31 15:53:43] 总用量 348
[2018/1/31 15:53:43] -rwxr-xr-x. 1 root root   8075 1月  31 23:51 elasticsearch
[2018/1/31 15:53:43] -rw-r--r--. 1 root root   3343 1月  31 23:51 elasticsearch.bat
[2018/1/31 15:53:43] -rw-r--r--. 1 root root   1023 1月  31 23:51 elasticsearch.in.bat
[2018/1/31 15:53:43] -rwxr-xr-x. 1 root root    367 1月  31 23:51 elasticsearch.in.sh
[2018/1/31 15:53:43] -rwxr-xr-x. 1 root root   2550 1月  31 23:51 elasticsearch-keystore
[2018/1/31 15:53:43] -rw-r--r--. 1 root root    743 1月  31 23:51 elasticsearch-keystore.bat
[2018/1/31 15:53:43] -rwxr-xr-x. 1 root root   2540 1月  31 23:51 elasticsearch-plugin
[2018/1/31 15:53:43] -rw-r--r--. 1 root root    731 1月  31 23:51 elasticsearch-plugin.bat
[2018/1/31 15:53:43] -rw-r--r--. 1 root root  11239 1月  31 23:51 elasticsearch-service.bat
[2018/1/31 15:53:43] -rw-r--r--. 1 root root 104448 1月  31 23:51 elasticsearch-service-mgr.exe
[2018/1/31 15:53:43] -rw-r--r--. 1 root root 103936 1月  31 23:51 elasticsearch-service-x64.exe
[2018/1/31 15:53:43] -rw-r--r--. 1 root root  80896 1月  31 23:51 elasticsearch-service-x86.exe
[2018/1/31 15:53:43] -rwxr-xr-x. 1 root root    223 1月  31 23:51 elasticsearch-systemd-pre-exec
[2018/1/31 15:53:43] -rwxr-xr-x. 1 root root   2514 1月  31 23:51 elasticsearch-translog
[2018/1/31 15:53:43] -rw-r--r--. 1 root root   1435 1月  31 23:51 elasticsearch-translog.bat
//查看配置文件夹内容,elasticsearch.yml是yml格式的主要配置内容
[2018/1/31 15:54:14] [root@bogon data]# ll /home/es/elasticsearch-5.5.2/config/
[2018/1/31 15:54:14] 总用量 16
[2018/1/31 15:54:14] -rw-r-----. 1 root root 2854 1月  31 23:51 elasticsearch.yml
[2018/1/31 15:54:14] -rw-r-----. 1 root root 3064 1月  31 23:51 jvm.options
[2018/1/31 15:54:14] -rw-r-----. 1 root root 4456 1月  31 23:51 log4j2.properties
//查看lib,可以看到这是基于lucence的
[2018/1/31 15:54:19] [root@bogon data]# ll /home/es/elasticsearch-5.5.2/lib/
[2018/1/31 15:54:19] 总用量 22136
[2018/1/31 15:54:19] -rw-r--r--. 1 root root 10037940 1月  31 23:51 elasticsearch-5.5.2.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root   114165 1月  31 23:51 HdrHistogram-2.1.9.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root  1140290 1月  31 23:51 hppc-0.7.1.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root   281203 1月  31 23:51 jackson-core-2.8.6.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root    50700 1月  31 23:51 jackson-dataformat-cbor-2.8.6.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root    73897 1月  31 23:51 jackson-dataformat-smile-2.8.6.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root    40877 1月  31 23:51 jackson-dataformat-yaml-2.8.6.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root     7465 1月  31 23:51 java-version-checker-5.5.2.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root   479510 1月  31 23:51 jna-4.4.0.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root   632037 1月  31 23:51 joda-time-2.9.5.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root    78074 1月  31 23:51 jopt-simple-5.0.2.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root   794991 1月  31 23:51 jts-1.13.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root    61146 1月  31 23:51 log4j-1.2-api-2.8.2.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root   228154 1月  31 23:51 log4j-api-2.8.2.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root  1407853 1月  31 23:51 log4j-core-2.8.2.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root  1513789 1月  31 23:51 lucene-analyzers-common-6.6.0.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root    87409 1月  31 23:51 lucene-backward-codecs-6.6.0.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root  2783533 1月  31 23:51 lucene-core-6.6.0.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root   107680 1月  31 23:51 lucene-grouping-6.6.0.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root   230588 1月  31 23:51 lucene-highlighter-6.6.0.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root   146618 1月  31 23:51 lucene-join-6.6.0.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root    46468 1月  31 23:51 lucene-memory-6.6.0.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root   165082 1月  31 23:51 lucene-misc-6.6.0.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root   237890 1月  31 23:51 lucene-queries-6.6.0.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root   404764 1月  31 23:51 lucene-queryparser-6.6.0.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root   169064 1月  31 23:51 lucene-sandbox-6.6.0.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root   236943 1月  31 23:51 lucene-spatial3d-6.6.0.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root    57019 1月  31 23:51 lucene-spatial-6.6.0.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root   196552 1月  31 23:51 lucene-spatial-extras-6.6.0.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root   249321 1月  31 23:51 lucene-suggest-6.6.0.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root    27919 1月  31 23:51 plugin-cli-5.5.2.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root     7419 1月  31 23:51 securesm-1.1.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root   269295 1月  31 23:51 snakeyaml-1.15.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root   187537 1月  31 23:51 spatial4j-0.6.jar
[2018/1/31 15:54:19] -rw-r--r--. 1 root root    49754 1月  31 23:51 t-digest-3.0.jar
//尝试启动,用sh命令
[2018/1/31 15:56:26] [root@bogon data]# sh /home/es/elasticsearch-5.5.2/bin/elasticsearch
[2018/1/31 15:57:43] [2018-01-31T23:57:43,132][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
[2018/1/31 15:57:43] org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
[2018/1/31 15:57:43] 	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:127) ~[elasticsearch-5.5.2.jar:5.5.2]
[2018/1/31 15:57:43] 	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:114) ~[elasticsearch-5.5.2.jar:5.5.2]
[2018/1/31 15:57:43] 	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:67) ~[elasticsearch-5.5.2.jar:5.5.2]
[2018/1/31 15:57:43] 	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) ~[elasticsearch-5.5.2.jar:5.5.2]
[2018/1/31 15:57:43] 	at org.elasticsearch.cli.Command.main(Command.java:88) ~[elasticsearch-5.5.2.jar:5.5.2]
[2018/1/31 15:57:43] 	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[elasticsearch-5.5.2.jar:5.5.2]
[2018/1/31 15:57:43] 	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[elasticsearch-5.5.2.jar:5.5.2]
[2018/1/31 15:57:43] Caused by: java.lang.RuntimeException: can not run elasticsearch as root
[2018/1/31 15:57:43] 	at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[elasticsearch-5.5.2.jar:5.5.2]
[2018/1/31 15:57:43] 	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:194) ~[elasticsearch-5.5.2.jar:5.5.2]
[2018/1/31 15:57:43] 	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:351) ~[elasticsearch-5.5.2.jar:5.5.2]
[2018/1/31 15:57:43] 	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:123) ~[elasticsearch-5.5.2.jar:5.5.2]
[2018/1/31 15:57:43] 	... 6 more
//报错,新版的es规定不能用root用户启动,这里添加新用户elastic,赋予它elasticsearch-5.5.2/文件夹下所有权限
[2018/1/31 15:59:26] [root@bogon data]# useradd elastic
[2018/1/31 15:59:38] [root@bogon data]# chown -R elastic:elastic /home/es/elasticsearch-5.5.2/
//切换用户
[2018/1/31 15:59:56] [root@bogon data]# su elastic
//尝试开启,是前台开启,有两个警告,之后可能会变成错误,下面会给出解决方案。
[2018/1/31 16:03:06] [elastic@bogon data]$ sh /home/es/elasticsearch-5.5.2/bin/elasticsearch
[2018/1/31 16:03:47] [2018-02-01T00:03:46,793][INFO ][o.e.n.Node               ] [] initializing ...
[2018/1/31 16:03:47] [2018-02-01T00:03:47,734][INFO ][o.e.e.NodeEnvironment    ] [d9nAlza] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [14.3gb], net total_space [17.4gb], spins? [unknown], types [rootfs]
[2018/1/31 16:03:47] [2018-02-01T00:03:47,735][INFO ][o.e.e.NodeEnvironment    ] [d9nAlza] heap size [1.9gb], compressed ordinary object pointers [true]
[2018/1/31 16:03:47] [2018-02-01T00:03:47,739][INFO ][o.e.n.Node               ] node name [d9nAlza] derived from node ID [d9nAlzadRJmeq1ziKnqD5w]; set [node.name] to override
[2018/1/31 16:03:47] [2018-02-01T00:03:47,740][INFO ][o.e.n.Node               ] version[5.5.2], pid[10586], build[b2f0c09/2017-08-14T12:33:14.154Z], OS[Linux/3.10.0-229.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_161/25.161-b12]
[2018/1/31 16:03:47] [2018-02-01T00:03:47,740][INFO ][o.e.n.Node               ] JVM arguments [-Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -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/es/elasticsearch-5.5.2]
[2018/1/31 16:03:57] [2018-02-01T00:03:57,002][INFO ][o.e.p.PluginsService     ] [d9nAlza] loaded module [aggs-matrix-stats]
[2018/1/31 16:03:57] [2018-02-01T00:03:57,015][INFO ][o.e.p.PluginsService     ] [d9nAlza] loaded module [ingest-common]
[2018/1/31 16:03:57] [2018-02-01T00:03:57,015][INFO ][o.e.p.PluginsService     ] [d9nAlza] loaded module [lang-expression]
[2018/1/31 16:03:57] [2018-02-01T00:03:57,015][INFO ][o.e.p.PluginsService     ] [d9nAlza] loaded module [lang-groovy]
[2018/1/31 16:03:57] [2018-02-01T00:03:57,016][INFO ][o.e.p.PluginsService     ] [d9nAlza] loaded module [lang-mustache]
[2018/1/31 16:03:57] [2018-02-01T00:03:57,016][INFO ][o.e.p.PluginsService     ] [d9nAlza] loaded module [lang-painless]
[2018/1/31 16:03:57] [2018-02-01T00:03:57,016][INFO ][o.e.p.PluginsService     ] [d9nAlza] loaded module [parent-join]
[2018/1/31 16:03:57] [2018-02-01T00:03:57,016][INFO ][o.e.p.PluginsService     ] [d9nAlza] loaded module [percolator]
[2018/1/31 16:03:57] [2018-02-01T00:03:57,016][INFO ][o.e.p.PluginsService     ] [d9nAlza] loaded module [reindex]
[2018/1/31 16:03:57] [2018-02-01T00:03:57,016][INFO ][o.e.p.PluginsService     ] [d9nAlza] loaded module [transport-netty3]
[2018/1/31 16:03:57] [2018-02-01T00:03:57,016][INFO ][o.e.p.PluginsService     ] [d9nAlza] loaded module [transport-netty4]
[2018/1/31 16:03:57] [2018-02-01T00:03:57,017][INFO ][o.e.p.PluginsService     ] [d9nAlza] no plugins loaded
[2018/1/31 16:04:03] [2018-02-01T00:04:03,890][INFO ][o.e.d.DiscoveryModule    ] [d9nAlza] using discovery type [zen]
[2018/1/31 16:04:05] [2018-02-01T00:04:05,125][INFO ][o.e.n.Node               ] initialized
[2018/1/31 16:04:05] [2018-02-01T00:04:05,125][INFO ][o.e.n.Node               ] [d9nAlza] starting ...
[2018/1/31 16:04:06] [2018-02-01T00:04:06,589][INFO ][o.e.t.TransportService   ] [d9nAlza] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2018/1/31 16:04:06] [2018-02-01T00:04:06,628][WARN ][o.e.b.BootstrapChecks    ] [d9nAlza] max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2018/1/31 16:04:06] [2018-02-01T00:04:06,628][WARN ][o.e.b.BootstrapChecks    ] [d9nAlza] max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2018/1/31 16:04:07] [2018-02-01T00:04:07,595][INFO ][o.e.m.j.JvmGcMonitorService] [d9nAlza] [gc][2] overhead, spent [473ms] collecting in the last [1.4s]
[2018/1/31 16:04:09] [2018-02-01T00:04:09,888][INFO ][o.e.c.s.ClusterService   ] [d9nAlza] new_master {d9nAlza}{d9nAlzadRJmeq1ziKnqD5w}{Mmosez1wTYe1uF4V6-7ltQ}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2018/1/31 16:04:10] [2018-02-01T00:04:10,037][INFO ][o.e.h.n.Netty4HttpServerTransport] [d9nAlza] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2018/1/31 16:04:10] [2018-02-01T00:04:10,038][INFO ][o.e.n.Node               ] [d9nAlza] started
[2018/1/31 16:04:10] [2018-02-01T00:04:10,073][INFO ][o.e.g.GatewayService     ] [d9nAlza] recovered [0] indices into cluster_state
[2018/1/31 16:05:04] ^C[2018-02-01T00:05:04,925][INFO ][o.e.n.Node               ] [d9nAlza] stopping ...
[2018/1/31 16:05:05] [2018-02-01T00:05:05,063][INFO ][o.e.n.Node               ] [d9nAlza] stopped
[2018/1/31 16:05:05] [2018-02-01T00:05:05,063][INFO ][o.e.n.Node               ] [d9nAlza] closing ...
[2018/1/31 16:05:05] [2018-02-01T00:05:05,120][INFO ][o.e.n.Node               ] [d9nAlza] closed
//ctrl+c,关闭es。追加-d,表示后台开启。
[2018/1/31 16:05:09] [elastic@bogon data]$ sh /home/es/elasticsearch-5.5.2/bin/elasticsearch -d
//查看是否开启成功
[2018/1/31 16:05:57] [elastic@bogon data]$ ps -ef | grep -i elasticsearch
[2018/1/31 16:06:00] elastic   10698      1 51 00:05 pts/1    00:00:25 /home/java/jdk1.8.0_161/bin/java -Xms2g -Xmx2g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -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/es/elasticsearch-5.5.2 -cp /home/es/elasticsearch-5.5.2/lib/* org.elasticsearch.bootstrap.Elasticsearch -d
[2018/1/31 16:06:00] elastic   10716  10473  0 00:05 pts/1    00:00:00 grep --color=auto -i elasticsearch
//curl访问,es默认接口是9200,查看es默认访问结果
[2018/1/31 16:09:16] [elastic@bogon data]$ curl http://localhost:9200
[2018/1/31 16:09:17] {
[2018/1/31 16:09:17]   "name" : "d9nAlza",
[2018/1/31 16:09:17]   "cluster_name" : "elasticsearch",
[2018/1/31 16:09:17]   "cluster_uuid" : "rthPwZPMS0CFFbRXvRem7g",
[2018/1/31 16:09:17]   "version" : {
[2018/1/31 16:09:17]     "number" : "5.5.2",
[2018/1/31 16:09:17]     "build_hash" : "b2f0c09",
[2018/1/31 16:09:17]     "build_date" : "2017-08-14T12:33:14.154Z",
[2018/1/31 16:09:17]     "build_snapshot" : false,
[2018/1/31 16:09:17]     "lucene_version" : "6.6.0"
[2018/1/31 16:09:17]   },
[2018/1/31 16:09:17]   "tagline" : "You Know, for Search"
[2018/1/31 16:09:17] }
…………
//比如集群以及其他机器连接 ,需要修改配置。
//把 network.host 和 http.port 前的备注符号去掉 然后Host改成你的局域网IP即可。重启。
[2018/1/31 16:12:41] [elastic@bogon elasticsearch-5.5.2]$ vi config/elasticsearch.yml 
[2018/1/31 16:14:48] [elastic@bogon elasticsearch-5.5.2]$ ps -ef | grep elasticsearch
[2018/1/31 16:14:49] elastic   10698      1  7 00:05 pts/1    00:00:40 /home/java/jdk1.8.0_161/bin/java -Xms2g -Xmx2g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -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/es/elasticsearch-5.5.2 -cp /home/es/elasticsearch-5.5.2/lib/* org.elasticsearch.bootstrap.Elasticsearch -d
[2018/1/31 16:14:49] elastic   10792  10473  0 00:14 pts/1    00:00:00 grep --color=auto elasticsearch
[2018/1/31 16:15:29] [elastic@bogon elasticsearch-5.5.2]$ kill -9 10698
[2018/1/31 16:15:45] [elastic@bogon elasticsearch-5.5.2]$ sh /home/es/elasticsearch-5.5.2/bin/elasticsearch -d
[2018/1/31 16:16:05] [elastic@bogon elasticsearch-5.5.2]$ ps -ef | grep elasticsearch
[2018/1/31 16:16:15] elastic   10821      1 78 00:15 pts/1    00:00:22 /home/java/jdk1.8.0_161/bin/java -Xms2g -Xmx2g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -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/es/elasticsearch-5.5.2 -cp /home/es/elasticsearch-5.5.2/lib/* org.elasticsearch.bootstrap.Elasticsearch -d
[2018/1/31 16:16:15] elastic   10827  10473  1 00:16 pts/1    00:00:00 grep --color=auto elasticsearch
//修改后测试
[elastic@bogon elasticsearch-5.5.2]$ curl http://192.168.0.154:9200
{
  "name" : "d9nAlza",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "rthPwZPMS0CFFbRXvRem7g",
  "version" : {
    "number" : "5.5.2",
    "build_hash" : "b2f0c09",
    "build_date" : "2017-08-14T12:33:14.154Z",
    "build_snapshot" : false,
    "lucene_version" : "6.6.0"
  },
  "tagline" : "You Know, for Search"
}
//这时浏览器如果还不能访问,说明9200端口没有开发,解决办法是开放端口或者关闭防火墙,linux外层还有保护,关闭防火墙也其实可以接受。这里使用前者。
//查看防火墙状态
[root@bogon elasticsearch-5.5.2]# firewall-cmd --state
running
//查看开放的端口列表
[root@bogon elasticsearch-5.5.2]# firewall-cmd --zone=public --list-ports
7003/tcp 7002/tcp 3306/tcp 24/tcp 7006/tcp 21/tcp 7001/tcp 80/tcp 7005/tcp 7004/tcp 6379/tcp 22/tcp
//发现没有9200 ,添加即可,重启防火墙
[root@bogon elasticsearch-5.5.2]# firewall-cmd --zone=public --add-port=9200/tcp --permanent
success
[root@bogon elasticsearch-5.5.2]# firewall-cmd --reload
success

//下面说三个可能存在问题,部分是使用vmware虚拟机装centos系统的缘故
//1、Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)
//由于elasticsearch5.5默认分配jvm空间大小为2g,修改jvm空间分配
//vi /home/es/elasticsearch-5.5.2/config/jvm.options 
//默认配置,-Xms2g  -Xmx2g
//改成 -Xms512m  -Xmx512m
[root@bogon elasticsearch-5.5.2]# vi /home/es/elasticsearch-5.5.2/config/jvm.options
//2、max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
//修改/etc/security/limits.conf文件,添加或修改如下行: (请切换到root用户 然后强制修改文件)
[2018/1/31 16:21:28] [root@bogon elasticsearch-5.5.2]# vi /etc/security/limits.conf
//3、 max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
//修改 /etc/sysctl.conf 文件,添加 “vm.max_map_count”设置
[2018/1/31 16:23:10] [root@bogon elasticsearch-5.5.2]# vi /etc/sysctl.conf
//使文件生效
[2018/1/31 16:24:38] [root@bogon elasticsearch-5.5.2]# sudo sysctl -p /etc/sysctl.conf
[2018/1/31 16:24:38] vm.max_map_count = 2621441




ES学习经历一,安装和启动_第1张图片

你可能感兴趣的:(linux,ES)