linux centos7安装部署安装Elasticsearch并后台启动

centos7安装部署安装Elasticsearch


前言

为什么要使用“Elastic Stack”   
 它到底是什么?它是一组快速且高度可扩展的组件(Elasticsearch、Kibana、Beats、Logstash 等),
 它们共同使您能够安全地从任何来源以任何格式获取数据,
 然后对其进行搜索、分析和可视化。
	官网地址:
	https://www.elastic.co/cn/
	tar包地址
	https://www.elastic.co/cn/downloads/past-releases/elasticsearch-7-17-3

一、安装环境?

jdk1.8、elasticsearch-7.17.3-linux-x86_64

二、安装及启动步骤

1、解压 elasticsearch-7.17.3-linux-x86_64.tar

1:切换到/opt/software 目录
	cd /opt/software
2:创建es目录
	mkdir es
3:将elasticsearch-7.17.3-linux-x86_64.tar上传至 /opt/software/es
4:解压缩es安装包
	tar -zxvf elasticsearch-7.17.3-linux-x86_64.tar	
5、修改配置文件
	cd /opt/software/es/elasticsearch-7.17.3 /config
	vim elasticsearch.yml                                --编辑es配置文件
	单机如下图配置所示  									--##EDIT下为修改部分
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#集群名称
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#节点信息
# Use a descriptive name for the node:
##EDIT
node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#关闭自检程序
##EDIT
bootstrap.memory_lock: false
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#网络配置
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
##EDIT
network.host: 本机ip
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
##EDIT
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#自发现配置新节点向集群报到的主机名
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
##EDIT
cluster.initial_master_nodes: ["node-1"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
#
# ---------------------------------- Security ----------------------------------
#
#                                 *** WARNING ***
#
# Elasticsearch security features are not enabled by default.
# These features are free, but require configuration changes to enable them.
# This means that users don’t have to provide credentials and can get full access
# to the cluster. Network connections are also not encrypted.
#
# To protect your data, we strongly encourage you to enable the Elasticsearch security features. 
# Refer to the following documentation for instructions.
#
# https://www.elastic.co/guide/en/elasticsearch/reference/7.16/configuring-stack-security.html
#增加跨域配置
##EDIT
http.cors.enabled: true
http.cors.allow-origin: "*"

6、修改jvm.options配置文件

################################################################
##
## JVM configuration
##
################################################################
##
## WARNING: DO NOT EDIT THIS FILE. If you want to override the
## JVM options in this file, or set any additional options, you
## should create one or more files in the jvm.options.d
## directory containing your adjustments.
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/7.17/jvm-options.html
## for more information.
##
################################################################



################################################################
## IMPORTANT: JVM heap size
################################################################
##
## The heap size is automatically configured by Elasticsearch
## based on the available memory in your system and the roles
## each node is configured to fulfill. If specifying heap is
## required, it should be done through a file in jvm.options.d,
## and the min and max should be set to the same value. For
## example, to set the heap to 4 GB, create a new file in the
## jvm.options.d directory containing these lines:
##EDIT
-Xms512m
-Xmx512m
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/7.17/heap-size.html
## for more information
##
################################################################


################################################################
## Expert settings
################################################################
##
## All settings below here are considered expert settings. Do
## not adjust them unless you understand what you are doing. Do
## not edit them in this file; instead, create a new file in the
## jvm.options.d directory containing your adjustments.
##
################################################################

## GC configuration
8-13:-XX:+UseConcMarkSweepGC
8-13:-XX:CMSInitiatingOccupancyFraction=75
8-13:-XX:+UseCMSInitiatingOccupancyOnly

## G1GC Configuration
# NOTE: G1 GC is only supported on JDK version 10 or later
# to use G1GC, uncomment the next two lines and update the version on the
# following three lines to your version of the JDK
# 10-13:-XX:-UseConcMarkSweepGC
# 10-13:-XX:-UseCMSInitiatingOccupancyOnly
14-:-XX:+UseG1GC

## JVM temporary directory
-Djava.io.tmpdir=${ES_TMPDIR}

## heap dumps

# generate a heap dump when an allocation from the Java heap fails; heap dumps
# are created in the working directory of the JVM unless an alternative path is
# specified
-XX:+HeapDumpOnOutOfMemoryError

# exit right after heap dump on out of memory error. Recommended to also use
# on java 8 for supported versions (8u92+).
9-:-XX:+ExitOnOutOfMemoryError

# specify an alternative path for heap dumps; ensure the directory exists and
# has sufficient space
-XX:HeapDumpPath=data

# specify an alternative path for JVM fatal error logs
-XX:ErrorFile=logs/hs_err_pid%p.log

## JDK 8 GC logging
8:-XX:+PrintGCDetails
8:-XX:+PrintGCDateStamps
8:-XX:+PrintTenuringDistribution
8:-XX:+PrintGCApplicationStoppedTime
8:-Xloggc:logs/gc.log
8:-XX:+UseGCLogFileRotation
8:-XX:NumberOfGCLogFiles=32
8:-XX:GCLogFileSize=64m

# JDK 9+ GC logging
9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m

7、创建用户并赋予权限,不能再root用户下启动
useradd 用户名
passwd 用户名 随后会提示输入密码
赋予权限
cd /opt/software/es
chown -R 用户名:用户名 ./ —chown将指定文件的拥有者改为指定的用户或组,
usermod -g root 用户 —将当前用户添加至root组
8、elasticsearch 启动的时候要求当前用户最大线程数至少为 4096 个线程,修改当前用户最大线程数
如下所示
显示 当前用户拥有线程数 ulimit -a

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 3834                  -----此处为当前用户线程数
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 3834
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

修改线程数
vim /etc/security/limits.conf
文件末尾加入 如下三行

用户名 soft nofile 65536
用户名 hard nofile 65536
用户名  -  nproc  65535

2、 前台启动elasticsearch

cd /opt/software/es/elasticsearch-7.17.3/bin
./elasticsearch                                            --前台启动es
http://ip:9200											   --访问es网址
如下
{
  "name" : "node-1",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "933ymxObQnKVmo3j6jXp0g",
  "version" : {
    "number" : "7.17.3",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "5ad023604c8d7416c9eb6c0eadb62b14e766caff",
    "build_date" : "2022-04-19T08:11:19.070913226Z",
    "build_snapshot" : false,
    "lucene_version" : "8.11.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
前台启动成功

3、 后台启动elasticsearch

后台启动

./bin/elasticsearch -d                                    
  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
您好!要安装 CentOS 操作系统,可以按照以下步骤进行: 1. 首先,从 CentOS 官方网站下载 CentOS 的安装镜像文件。您可以访问 https://www.centos.org/download/ 下载适合您的机器的版本。 2. 下载完成后,将安装镜像文件写入到可启动安装介质上。您可以使用光盘、USB 驱动器或虚拟机等方式启动。 3. 启动计算机并选择从安装介质启动。您可能需要在计算机启动时按下特定的键(如 F2、F10 或 Del)来进入启动菜单或 BIOS 设置界面,然后选择正确的启动设备。 4. 一旦从安装介质启动,您将进入 CentOS 安装程序的界面。按照提示选择适合您的语言、时区和键盘布局。 5. 在安装程序中,选择磁盘分区和安装位置。您可以选择手动分区或使用默认设置。请注意,安装 CentOS 将清除磁盘上的所有数据,请确保已备份重要文件。 6. 设置 root 用户密码和普通用户账户。为了安全起见,建议使用强密码,并为每个用户提供不同的密码。 7. 接下来,选择要安装的软件包组。您可以根据需要选择不同的软件包组,或者使用默认的 Minimal 安装来开始。 8. 安装过程可能需要一些时间。安装完成后,您将被提示重新启动计算机。 9. 重新启动后,您可以登录到 CentOS 操作系统,并开始使用它。 请注意,这只是一个基本的安装过程概述。根据您的具体需求和环境,可能还有其他配置步骤需要完成。建议在安装前参考 CentOS 的官方文档或其他可靠资源,以获取更详细的安装说明和指导。祝您安装顺利!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

@小白—

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值