下载:
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.7.0.tar.gz
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.0.tar.gz
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.2-linux-x86_64.tar.gz
解压:
tar -zxvf elasticsearch-6.7.0.tar.gz
# 可使用mv 命令修改名称
添加es专用用户:
useradd elasticsearch
# 给用户设置密码,连输两次确认
passwd elasticsearch
设置权限:
chown elasticsearch:elasticsearch ./es -R
chown -hR elasticsearch ./es
# -R:递归文件夹中所有文件,注意设置权限时必须使用root账户,否则不生效
修改配置:
进入config文件夹修改elasticsearch.yml
network.host: 192.168.0.1 IP修改为实际访问ip,可能启动会报错
也可以直接将IP修改为 0.0.0.0
修改jvm.options:
// 根据实际情况进行修改
-Xms1g -Xms128m
-Xmx1g -Xmx128m
启动
# es不能用root用户直接启动,
su 命令切换到添加的es用户
进入到bin目录下运行:
./elasticsearch # 该命令在退出或者关闭窗口时自动停止服务
./elasticsearch -d # 后台运行
启动会出现如下错误:
# 不切换用户用报错
2019-04-01T14:42:29,623o.e.b.ElasticsearchUncaughtExceptionHandler 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:163) ~[elasticsearch-6.7.0.jar:6.7.0] at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-6.7.0.jar:6.7.0] at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.7.0.jar:6.7.0] at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.7.0.jar:6.7.0] at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.7.0.jar:6.7.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:116) ~[elasticsearch-6.7.0.jar:6.7.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.7.0.jar:6.7.0]Caused by: java.lang.RuntimeException: can not run elasticsearch as root at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:103) ~[elasticsearch-6.7.0.jar:6.7.0] at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:170) ~[elasticsearch-6.7.0.jar:6.7.0] at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.7.0.jar:6.7.0] at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.7.0.jar:6.7.0] ... 6 more
# 不修改yml network.host 参数导致的
# 在confg文件夹下elasticsearch.yml中修改为network.host: 0.0.0.0
org.elasticsearch.bootstrap.StartupException: BindTransportException[Failed to bind to [9300-9400]]; nested: BindException[Cannot assign requested address]; at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-6.7.0.jar:6.7.0] at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-6.7.0.jar:6.7.0] at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.7.0.jar:6.7.0] at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.7.0.jar:6.7.0] at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.7.0.jar:6.7.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:116) ~[elasticsearch-6.7.0.jar:6.7.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.7.0.jar:6.7.0]Caused by: org.elasticsearch.transport.BindTransportException: Failed to bind to [9300-9400] at org.elasticsearch.transport.TcpTransport.bindToPort(TcpTransport.java:408) ~[elasticsearch-6.7.0.jar:6.7.0] at org.elasticsearch.transport.TcpTransport.bindServer(TcpTransport.java:375) ~[elasticsearch-6.7.0.jar:6.7.0] at org.elasticsearch.transport.netty4.Netty4Transport.doStart(Netty4Transport.java:136) ~[?:?] at org.elasticsearch.xpack.core.security.transport.netty4.SecurityNetty4Transport.doStart(SecurityNetty4Transport.java:127) ~[?:?] at org.elasticsearch.xpack.security.transport.netty4.SecurityNetty4ServerTransport.doStart(SecurityNetty4ServerTransport.java:46) ~[?:?] at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:72) ~[elasticsearch-6.7.0.jar:6.7.0] at org.elasticsearch.transport.TransportService.doStart(TransportService.java:228) ~[elasticsearch-6.7.0.jar:6.7.0] at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:72) ~[elasticsearch-6.7.0.jar:6.7.0] at org.elasticsearch.node.Node.start(Node.java:741) ~[elasticsearch-6.7.0.jar:6.7.0] at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:269) ~[elasticsearch-6.7.0.jar:6.7.0] at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) ~[elasticsearch-6.7.0.jar:6.7.0] at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.7.0.jar:6.7.0] ... 6 moreCaused by: java.net.BindException: Cannot assign requested address at sun.nio.ch.Net.bind0(Native Method) ~[?:?] at sun.nio.ch.Net.bind(Net.java:433) ~[?:?] at sun.nio.ch.Net.bind(Net.java:425) ~[?:?] at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) ~[?:?] at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:130) ~[?:?] at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:562) ~[?:?] at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1358) ~[?:?] at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:501) ~[?:?] at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:486) ~[?:?] at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:1019) ~[?:?] at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:258) ~[?:?] at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:366) ~[?:?] at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) ~[?:?] at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404) ~[?:?] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:474) ~[?:?] at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:909) ~[?:?] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_141]
报错:
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方式:
切换root用户,修改 /etc/sysctl.conf
vim /etc/sysctl.conf
文件最后添加一行
vm.max_map_count=262144
保存退出,加载配置
sysctl -p
报错:
max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
解决方式:
vim /etc/security/limits.conf
修改为:
* soft nofile 65536
* hard nofile 65536
报错:
ERROR: bootstrap checks failed
解决方式:
在elasticsearch.yml中配置,在Memory下面,没有的话直接添加即可:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
docker 中出现问题 bootstrap checks failed
找到配置文件
find / -name "elasticsearch.yml"
查看下面参数是否存在,否则添加即可
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
cluster.initial_master_nodes: ["node-1"]
插件安装问题:
设置密码: bin目录下运行 ./elasticsearch-plugin install x-pack 报错: Exception in thread "main" java.lang.IllegalStateException: duplicate plugin: /opt/elasticsearch/plugins/.installing-33639110701911475/core at org.elasticsearch.plugins.PluginInfo.extractAllPlugins(PluginInfo.java:162) at org.elasticsearch.plugins.PluginsService.getPluginBundles(PluginsService.java:324) at org.elasticsearch.plugins.InstallPluginCommand.jarHellCheck(InstallPluginCommand.java:600) at org.elasticsearch.plugins.InstallPluginCommand.loadPluginInfo(InstallPluginCommand.java:588) at org.elasticsearch.plugins.InstallPluginCommand.installMetaPlugin(InstallPluginCommand.java:667) at org.elasticsearch.plugins.InstallPluginCommand.install(InstallPluginCommand.java:621) at org.elasticsearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:223) at org.elasticsearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:212) at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) at org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:75) at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) at org.elasticsearch.cli.Command.main(Command.java:90) at org.elasticsearch.plugins.PluginCli.main(PluginCli.java:48) 原因:重复安装插件 方式一: 卸载插件: ./elasticsearch-plugin remove 插件名称 方式二: 在plugin中找到对应插件直接删除,重新安装
x-pack 安装成功
在bin目录中和plugins中会产生文件夹 ,然后在bin目录下设置密码
设置密码:./x-pack/setup-passwords interactive
设置多个密码,最好设置一样的,用户名默认是:elastic
应该是6.7左右+的版本默认就安装了x-pack,直接在bin目录中设置密码即可:
./elasticsearch-setup-passwords interactive
Cluster state has not been recovered yet, cannot write to the [null] index
解决方式:yml node块中的
node.name: node-1 # 放开注释
Discovery块中的
cluster.initial_master_nodes: ["node-1"]
集成源码地址:
如果使用root账户启动es启动失败之后,再次切换账号启动还是失败:
Caused by: java.lang.IllegalStateException: failed to obtain node locks, tried [[/opt/elasticsearch-6.7.0/data]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:300) ~[elasticsearch-6.7.0.jar:6.7.0]
at org.elasticsearch.node.Node.<init>(Node.java:296) ~[elasticsearch-6.7.0.jar:6.7.0]
at org.elasticsearch.node.Node.<init>(Node.java:266) ~[elasticsearch-6.7.0.jar:6.7.0]
at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:212) ~[elasticsearch-6.7.0.jar:6.7.0]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:212) ~[elasticsearch-6.7.0.jar:6.7.0]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.7.0.jar:6.7.0]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.7.0.jar:6.7.0]
... 6 more
可将data下nodes下的所有文件删除之后再次使用es账户启动即可
java.nio.file.NoSuchFileException: plugin-descriptor.properties
下载对应版本IK
Tags · medcl/elasticsearch-analysis-ik · GitHub+版本号
下载zip用idea 打开项目mvn 打包
E:\wdz\tools\ik\elasticsearch-analysis-ik-5.5.0\elasticsearch-analysis-ik-5.5.0\target\releases下的zip包上传至es服务plugins 下的ik文件夹下解压即可