CentOS 7 安装 ElasticSearch

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.0.rpm
rpm --install elasticsearch-5.6.0.rpm
systemctl enable elasticsearch
systemctl start 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:
# /root/elasticsearch-5.6.0/hs_err_pid19703.log
vi /etc/elasticsearch/jvm.options
或
vi config/jvm.options
-Xms2g
-Xmx2g
修改为:
-Xms256m
-Xmx256m

./bin/elasticsearch

curl --proxy "" http://localhost:9200/?pretty

修改Elasticsearch的配置,使其支持外网访问:
vi config/elasticsearch.yml
network.host: 0.0.0.0

报错:
Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root
添加专门的用户
useradd elastic
passwd elastic
chown -R elastic:elastic elasticsearch-5.6.0/

报错:
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
修改/etc/sysctl.conf配置文件
cat /etc/sysctl.conf | grep vm.max_map_count
vm.max_map_count=262144
如果不存在则添加
echo "vm.max_map_count=262144" >>/etc/sysctl.conf
sysctl -p