问题:
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
[root@localhost logs]# adduser es
[root@localhost logs]# passwd es
Changing password for user es.
New password:
BAD PASSWORD: The password is shorter than 7 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@localhost soft]# chown -R es elasticsearch-6.1.1
[root@localhost soft]# chown -R es file
[root@localhost soft]# su es
[es@localhost bin]$ ./elasticsearch
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
[2018-01-10T14:30:10,728][INFO ][o.e.n.Node ] [node-1] initializing ...
[2018-01-10T14:30:10,954][INFO ][o.e.e.NodeEnvironment ] [node-1] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [41.7gb], net total_space [45gb], types [rootfs]
[2018-01-10T14:30:10,955][INFO ][o.e.e.NodeEnvironment ] [node-1] heap size [503.6mb], compressed ordinary object pointers [true]
[2018-01-10T14:30:10,956][INFO ][o.e.n.Node ] [node-1] node name [node-1], node ID [6mBr8gIiRiy3IXtZBE1p6A]
[2018-01-10T14:30:10,956][INFO ][o.e.n.Node ] [node-1] version[6.1.1], pid[29969], build[bd92e7f/2017-12-17T20:23:25.338Z], OS[Linux/3.10.0-693.el7.x86_64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_131/25.131-b12]
[2018-01-10T14:30:10,956][INFO ][o.e.n.Node ] [node-1] JVM arguments [-Xms512m, -Xmx512m, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/opt/soft/elasticsearch-6.1.1, -Des.path.conf=/opt/soft/elasticsearch-6.1.1/config]
[2018-01-10T14:30:13,063][INFO ][o.e.p.PluginsService ] [node-1] loaded module [aggs-matrix-stats]
[2018-01-10T14:30:13,063][INFO ][o.e.p.PluginsService ] [node-1] loaded module [analysis-common]
[2018-01-10T14:30:13,064][INFO ][o.e.p.PluginsService ] [node-1] loaded module [ingest-common]
[2018-01-10T14:30:13,064][INFO ][o.e.p.PluginsService ] [node-1] loaded module [lang-expression]
[2018-01-10T14:30:13,064][INFO ][o.e.p.PluginsService ] [node-1] loaded module [lang-mustache]
[2018-01-10T14:30:13,064][INFO ][o.e.p.PluginsService ] [node-1] loaded module [lang-painless]
[2018-01-10T14:30:13,064][INFO ][o.e.p.PluginsService ] [node-1] loaded module [mapper-extras]
[2018-01-10T14:30:13,064][INFO ][o.e.p.PluginsService ] [node-1] loaded module [parent-join]
[2018-01-10T14:30:13,064][INFO ][o.e.p.PluginsService ] [node-1] loaded module [percolator]
[2018-01-10T14:30:13,064][INFO ][o.e.p.PluginsService ] [node-1] loaded module [reindex]
[2018-01-10T14:30:13,064][INFO ][o.e.p.PluginsService ] [node-1] loaded module [repository-url]
[2018-01-10T14:30:13,064][INFO ][o.e.p.PluginsService ] [node-1] loaded module [transport-netty4]
[2018-01-10T14:30:13,065][INFO ][o.e.p.PluginsService ] [node-1] loaded module [tribe]
[2018-01-10T14:30:13,065][INFO ][o.e.p.PluginsService ] [node-1] no plugins loaded
[2018-01-10T14:30:16,339][INFO ][o.e.d.DiscoveryModule ] [node-1] using discovery type [zen]
[2018-01-10T14:30:17,426][INFO ][o.e.n.Node ] [node-1] initialized
[2018-01-10T14:30:17,426][INFO ][o.e.n.Node ] [node-1] starting ...
[2018-01-10T14:30:17,699][INFO ][o.e.t.TransportService ] [node-1] publish_address {192.168.20.168:9300}, bound_addresses {[::]:9300}
[2018-01-10T14:30:17,721][INFO ][o.e.b.BootstrapChecks ] [node-1] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2018-01-10T14:30:17,801][INFO ][o.e.n.Node ] [node-1] stopping ...
[2018-01-10T14:30:17,871][INFO ][o.e.n.Node ] [node-1] stopped
[2018-01-10T14:30:17,871][INFO ][o.e.n.Node ] [node-1] closing ...
[2018-01-10T14:30:17,886][INFO ][o.e.n.Node ] [node-1] closed
问题:
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
解决方法:切换到root用户,进入vi /etc/security/limits.conf ,增加配置(保存后注意切回work用户的时候才能生效,sudo 修改的不能立即生效):
es soft nofile 819200
es hard nofile 819200
问题:
ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2018-01-10T15:09:44,884][INFO ][o.e.n.Node ] [node-1] stopping ...
[2018-01-10T15:09:44,954][INFO ][o.e.n.Node ] [node-1] stopped
[2018-01-10T15:09:44,955][INFO ][o.e.n.Node ] [node-1] closing ...
[2018-01-10T15:09:44,970][INFO ][o.e.n.Node ] [node-1] closed
[es@localhost bin]$ cat /etc/sysctl.conf | grep vm.max_map_count
[es@localhost bin]$ echo "vm.max_map_count=262144" >>/etc/sysctl.conf
bash: /etc/sysctl.conf: Permission denied
[es@localhost bin]$ su root
Password:
[root@localhost bin]# echo "vm.max_map_count=262144" >>/etc/sysctl.conf
[root@localhost bin]# cat /etc/sysctl.conf | grep vm.max_map_count
vm.max_map_count=262144
问题:
Elasticsearch在linux下使用命令sh elasticsearch start,按键ctrl+c的时候程序就会stop掉,如何将程序在后台启动呢?
需要使用:./elasticsearch -d
这时执行的时候会出现没有权限./elasticsearch: Permission denied
需要授权执行命令:chmod +x bin/elasticsearch
再次执行./elasticsearch -d即可启动
使用ps aux|grep elasticsearch可以查看是否启动