- 首先下载
elasticsearch包下载地址:点击跳转官网
#集群名称
cluster.name: myes
#节点名字
node.name: myes01
#数据位置
path.data: /usr/java/elk/elasticsearch-5.5.1/espath/data
#日志位置
path.logs: /usr/java/elk/elasticsearch-5.5.1/espath/logs
#本机ip
network.host: 192.168.80.123
#可以选取的节点(如果是多台就["lijie","lijie1","lijie2"])但是必须是基数个
discovery.zen.ping.unicast.hosts: ["lijie"]
#这两个配置是支持跨域访问用的
http.cors.allow-origin: "/.*/"
http.cors.enabled: true
- 启动es
/usr/java/elk/elasticsearch-5.5.1/bin/elasticsearch -d
报错:
Elasticsearch requires at least Java 8 but your Java version from /usr/java/jdk1.7.0_79/bin/java does not meet this requirement
[WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [myes01] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:127) ~[elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:114) ~[elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:67) ~[elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) ~[elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.cli.Command.main(Command.java:88) ~[elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[elasticsearch-5.5.1.jar:5.5.1]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:194) ~[elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:351) ~[elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:123) ~[elasticsearch-5.5.1.jar:5.5.1]
- 启动失败,查看日志:
java.lang.UnsupportedOperationException: seccomp unavailable: requires kernel 3.5+ with CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER compiled in
at org.elasticsearch.bootstrap.SystemCallFilter.linuxImpl(SystemCallFilter.java:350) ~[elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.SystemCallFilter.init(SystemCallFilter.java:638) ~[elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.JNANatives.tryInstallSystemCallFilter(JNANatives.java:245) [elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.Natives.tryInstallSystemCallFilter(Natives.java:113) [elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:111) [elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:194) [elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:351) [elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:123) [elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:114) [elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:67) [elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) [elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.cli.Command.main(Command.java:88) [elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) [elasticsearch-5.5.1.jar:5.5.1]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) [elasticsearch-5.5.1.jar:5.5.1]
查看内核版本:
[root@lijie ~]# cat /proc/version
Linux version 2.6.32-431.el6.x86_64 (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Fri Nov 22 03:15:09 UTC 2013
问题:
linux的内核版本过低
- 升级linux内核
首先导入publicKey:
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
然后执行
rpm -Uvh http://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm
安装kmod-r8168
yum install -y kmod-r8168
然后:
yum --enablerepo=elrepo-kernel install kernel-lt -y
然后:
vi /etc/grub.conf
#将第一个default的值改为0 -> default=0
然后重启:
reboot
重启后再查看内核版本:
[root@lijie ~]# cat /proc/version
Linux version 3.10.107-1.el6.elrepo.x86_64 (mockbuild@Build64R6) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) ) #1 SMP Tue Jun 27 10:57:54 EDT 2017
重新启动,还是报错,查看日志文件:
bootstrap checks Failed
[1]: max file descriptors [4096] for elasticsearch process is too low,increase to at least [65536]
[2]: max number of threads [1024] for user [hadoop] is too low,increase to at least [2048]
[3]: max virtual memory areas vm.max_map_count [65530] is too low,increase to at least [262144]
其中[1]: max file descriptors [4096] for elasticsearch process is too low,increase to at least [65536]
解决方法:
#用root用户执行
vi /etc/security/limits.conf
#添加
* soft nofile 65536
* hard nofile 131072
其中[2]: max number of threads [1024] for user [hadoop] is too low,increase to at least [2048]
解决方法:
#用root用户执行
vi /etc/security/limits.d/90-nproc.conf
#修改
* soft nproc 1024 为 2048
其中[3]: max virtual memory areas vm.max_map_count [65530] is too low,increase to at least [262144]
解决方法:
#用root用户执行
vi /etc/sysctl.conf
#添加一条配置:
vm.max_map_count=262144
#然后执行:
sysctl -p
解决上面的错误之后重启elasticsearch
/usr/java/elk/elasticsearch-5.5.1/bin/elasticsearch -d
注意事项: 用root用户做完上面的修改后再切回普通用户,这样上面的配置才能生效,不然还是会报错
查看日志:
[2017-08-10T13:38:32,471][INFO ][o.e.t.TransportService ] [myes01] publish_address {192.168.80.123:9300},bound_addresses {192.168.80.123:9300}
[2017-08-10T13:38:32,574][INFO ][o.e.b.BootstrapChecks ] [myes01] bound or publishing to a non-loopback or non-link-local address,enforcing bootstrap checks
[2017-08-10T13:38:33,245][WARN ][o.e.m.j.JvmGcMonitorService] [myes01] [gc][2] overhead,spent [625ms] collecting in the last [1s]
[2017-08-10T13:38:36,327][INFO ][o.e.c.s.ClusterService ] [myes01] new_master {myes01}{4B84juCUSKqRiddNlMOuCw}{sBOoIcHPTZmCt5O3olccrg}{192.168.80.123}{192.168.80.123:9300},reason: zen-disco-elected-as-master ([0] nodes joined)
[2017-08-10T13:38:36,444][INFO ][o.e.g.GatewayService ] [myes01] recovered [0] indices into cluster_state
[2017-08-10T13:38:36,446][INFO ][o.e.h.n.Netty4HttpServerTransport] [myes01] publish_address {192.168.80.123:9200},bound_addresses {192.168.80.123:9200}
[2017-08-10T13:38:36,446][INFO ][o.e.n.Node ] [myes01] started
终于启动成功!
返回:
{
"name" : "myes01","cluster_name" : "myes","cluster_uuid" : "N74wJcOMTAGkyANd9_qpvA","version" : { "number" : "5.5.1","build_hash" : "19c13d0","build_date" : "2017-07-18T20:44:24.823Z","build_snapshot" : false,"lucene_version" : "6.6.0" },"tagline" : "You Know,for Search" }
安装特别简单,就是新版本的安装可能会遇到上述的问题.
安装sql插件(详见 :https://github.com/NLPchina/elasticsearch-sql/):
[hadoop@lijie elasticsearch-5.5.1]$ ./bin/elasticsearch-plugin install https://github.com/@H_301_1130@NLPchina/elasticsearch-sql/releases/download/5.5.1.0/elasticsearch-sql-5.5.1.0.zip
[hadoop@lijie site-server]$ wget https://github.com/@H_301_1130@NLPchina/elasticsearch-sql/releases/download/5.4.1.0/es-sql-site-standalone.zip
[hadoop@lijie site-server]$ unzip es-sql-site-standalone.zip
下载nodejs(http://nodejs.cn/download/):
上传解压:
[root@lijie nodejs]# xz -d node-v8.7.0-linux-x64.tar.xz
[root@lijie nodejs]# tar -xvf node-v8.7.0-linux-x64.tar
然后创建软链接:
[root@lijie node-v8.7.0-linux-x64]# ln -s /usr/nodejs/node-v8.7.0-linux-x64/bin/npm /usr/local/bin/
[root@lijie node-v8.7.0-linux-x64]# ln -s /usr/nodejs/node-v8.7.0-linux-x64/bin/node /usr/local/bin/
[root@lijie node-v8.7.0-linux-x64]# node -v
v8.7.0
在site-server目录下:
[hadoop@lijie site-server]$ npm install express --save
[hadoop@lijie site-server]$ node node-server.js
最后重启es并且查询:
#访问
http://192.168.80.123:9200/_sql?sql=select * from school where score > 90