Linux 安装和配置Elastiscsearch
2021/12/28 7:08:42
本文主要是介绍Linux 安装和配置Elastiscsearch,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
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.host的内网IP地址根据实际填写):
cluster.name: my-application node.name: node-1 network.host: 内网IP地址
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、配置Elastiscsearch系统服务启动
vim /usr/lib/systemd/system/elasticsearch.service
添加如下内容,其中路径根据实际情况填写:
[Unit] Description=Elasticsearch Documentation=http://www.elastic.co Wants=network-online.target After=network-online.target [Service] Environment=ES_HOME=/opt/elasticsearch Environment=CONF_DIR=/opt/elasticsearch/config Environment=DATA_DIR=/opt/elasticsearch/data Environment=LOG_DIR=/opt/elasticsearch/logs Environment=PID_DIR=/opt/elasticsearch EnvironmentFile=-/etc/sysconfig/elasticsearch WorkingDirectory=/opt/elasticsearch User=elasticsearch Group=elasticsearch ExecStartPre=/opt/elasticsearch/bin/elasticsearch-systemd-pre-exec ExecStart=/opt/elasticsearch/bin/elasticsearch \ -p ${PID_DIR}/elasticsearch.pid \ --quiet \ -Edefault.path.logs=${LOG_DIR} \ -Edefault.path.data=${DATA_DIR} \ -Edefault.path.conf=${CONF_DIR} # StandardOutput is configured to redirect to journalctl since # some error messages may be logged in standard output before # elasticsearch logging system is initialized. Elasticsearch # stores its logs in /var/log/elasticsearch and does not use # journalctl by default. If you also want to enable journalctl # logging, you can simply remove the "quiet" option from ExecStart. StandardOutput=journal StandardError=inherit # Specifies the maximum file descriptor number that can be opened by this process LimitNOFILE=65536 # Specifies the maximum number of processes LimitNPROC=2048 # Specifies the maximum size of virtual memory LimitAS=infinity # Specifies the maximum file size LimitFSIZE=infinity # Disable timeout logic and wait until process is stopped TimeoutStopSec=0 # SIGTERM signal is used to stop the Java process KillSignal=SIGTERM # Send the signal only to the JVM rather than its control group KillMode=process # Java process is never killed SendSIGKILL=no # When a JVM receives a SIGTERM signal it exits with code 143 SuccessExitStatus=143 [Install] WantedBy=multi-user.target # Built for distribution-5.6.9 (distribution)
8、重新加载新的服务、设置开机自启、启动服务、关闭服务、查看启动状态
systemctl daemon-reload systemctl enable elasticsearch systemctl start elasticsearch systemctl stop elasticsearch systemctl status elasticsearch
这篇关于Linux 安装和配置Elastiscsearch的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-23linux 系统宝塔查看网站访问的命令是什么?-icode9专业技术文章分享
- 2024-11-12如何创建可引导的 ESXi USB 安装介质 (macOS, Linux, Windows)
- 2024-11-08linux的 vi编辑器中搜索关键字有哪些常用的命令和技巧?-icode9专业技术文章分享
- 2024-11-08在 Linux 的 vi 或 vim 编辑器中什么命令可以直接跳到文件的结尾?-icode9专业技术文章分享
- 2024-10-22原生鸿蒙操作系统HarmonyOS NEXT(HarmonyOS 5)正式发布
- 2024-10-18操作系统入门教程:新手必看的基本操作指南
- 2024-10-18初学者必看:操作系统入门全攻略
- 2024-10-17操作系统入门教程:轻松掌握操作系统基础知识
- 2024-09-11Linux部署Scrapy学习:入门级指南
- 2024-09-11Linux部署Scrapy:入门级指南