gdjlc

培养良好的习惯,每天一点一滴的进步,终将会有收获。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

1、上传Elastiscsearch安装压缩包到服务器/opt目录上

2、修改内核参数max_map_count
max_map_count包含限制一个进程可以拥有的VMA(虚拟内存区域)的数量

vim /etc/sysctl.conf

在最后添加下面一行

vm.max_map_count = 262144

加载配置生效

sysctl -p

查看当前值

sysctl -a|grep vm.max_map_count

3、解压Elastiscsearch安装包、重命名

cd /opt
tar -zxvf elasticsearch-5.6.9.tar.gz
mv elasticsearch-5.6.9 elasticsearch

4、创建Elasticsearch用户组、用户、创建日志和数据目录、授权

groupadd elasticsearch
useradd elasticsearch -g elasticsearch
mkdir {elasticsearch/logs,elasticsearch/data}
chown -R elasticsearch:elasticsearch elasticsearch

5、修改配置

vim /opt/elasticsearch/config/elasticsearch.yml

修改里面---Network---这一块的2行配置

network.host: 0.0.0.0

http.port: 9200

6、配置系统配置文件

vim /etc/sysconfig/elasticsearch

添加如下内容,其中路径根据实际情况填写:

################################
# Elasticsearch
################################

# Elasticsearch home directory
ES_HOME=/opt/elasticsearch

# Elasticsearch Java path
JAVA_HOME=/usr/local/jdk   

# Elasticsearch configuration directory
CONF_DIR=/opt/elasticsearch/config

# Elasticsearch data directory
DATA_DIR=/opt/elasticsearch/data

# Elasticsearch logs directory
LOG_DIR=/opt/elasticsearch/logs

# Elasticsearch PID directory
PID_DIR=/opt/elasticsearch

# Additional Java OPTS
#ES_JAVA_OPTS=

# Configure restart on package upgrade (true, every other setting will lead to not restarting)
#RESTART_ON_UPGRADE=true

################################
# Elasticsearch service
################################

# SysV init.d
#
# When executing the init script, this user will be used to run the elasticsearch service.
# The default value is 'elasticsearch' and is declared in the init.d file.
# Note that this setting is only used by the init script. If changed, make sure that
# the configured user can read and write into the data, work, plugins and log directories.
# For systemd service, the user is usually configured in file /usr/lib/systemd/system/elasticsearch.service
ES_USER=elasticsearch
ES_GROUP=elasticsearch

# The number of seconds to wait before checking if Elasticsearch started successfully as a daemon process
ES_STARTUP_SLEEP_TIME=5

################################
# System properties
################################

# Specifies the maximum file descriptor number that can be opened by this process
# When using Systemd, this setting is ignored and the LimitNOFILE defined in
# /usr/lib/systemd/system/elasticsearch.service takes precedence
MAX_OPEN_FILES=65536

# The maximum number of bytes of memory that may be locked into RAM
# Set to "unlimited" if you use the 'bootstrap.memory_lock: true' option
# in elasticsearch.yml.
# When using systemd, LimitMEMLOCK must be set in a unit file such as
# /etc/systemd/system/elasticsearch.service.d/override.conf.
MAX_LOCKED_MEMORY=unlimited

# Maximum number of VMA (Virtual Memory Areas) a process can own
# When using Systemd, this setting is ignored and the 'vm.max_map_count'
# property is set at boot time in /usr/lib/sysctl.d/elasticsearch.conf
MAX_MAP_COUNT=262144

7、调大用户的软限制和硬限制的值

vim /etc/security/limits.conf

在最后面添加

*    soft    nofile    65536
*    hard   nofile    65536

8、切换用户、启动服务

su elasticsearch
cd /opt/elasticsearch/bin
./elasticsearch -d

9、浏览器访问:http://IP:9200,正常会输出一段JSON内容。

 

备注:
上面配置的端口号9200系统默认不允许进行远程连接,需要在防火墙中设置9200允许远程连接。
可参考此文章开启:https://www.cnblogs.com/gdjlc/p/15740783.html

posted on 2021-12-27 17:00  gdjlc  阅读(178)  评论(0编辑  收藏  举报