- 安装准备(准备jdk8,elasticsearch-7.15.0安装包)
资源传送门:安装包下载 - 安装jdk(上传jdk包到服务器:/opt)
> tar -xvf jdk-8u191-linux-x64.tar.gz > mv jdk1.8.0_191 jdk > vim /etc/profile //profile 文件加入jdk配置 export JAVA_HOME=/opt/jdk export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/ export PATH=$PATH:$JAVA_HOME/bin >source /etc/profile //配置及时生效 >java -version java version "1.8.0_191" Java(TM) SE Runtime Environment (build 1.8.0_191-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode) //表示jdk安装成功
- 创建用户和组
//创建用户es及用户组es //创建用户组 > groupadd es //创建用户并指定主目录和用户组 > useradd -g es -d /opt/es es //设置密码 > passwd es 更改用户 es 的密码 。 新的 密码: 无效的密码: 密码少于 8 个字符 重新输入新的 密码: passwd:所有的身份验证令牌已经成功更新。
- 安装es(使用es账号上传elasticsearch-7.15.0到/opt/es目录下)
> tar -xvf elasticsearch-7.15.0-linux-x86_64_01.tar.gz //使用mv把加压好的文件名改成elasticsearch >mv elasticsearch-7.15.0 elasticsearch >cd /opt/es/elasticsearch/config >vim elasticsearch.yml //把配置改成自己的 # ======================== 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: escluster # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # node.name: node01 # # 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: /opt/es/elasticsearch/data # # Path to log files: # path.logs: /opt/es/elasticsearch/logs # # ----------------------------------- Memory ----------------------------------- # # Lock the memory on startup: # #bootstrap.memory_lock: true # # 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: # network.host: 10.99.2.77 # # By default Elasticsearch listens for HTTP traffic on the first free port it # finds starting at 9200. Set a specific HTTP port here: # http.port: 9200 transport.tcp.port: 9300 transport.tcp.compress: true # # 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: ["10.99.2.77"] # # Bootstrap the cluster using an initial set of master-eligible nodes: # cluster.initial_master_nodes: ["node01"] # # For more information, consult the discovery and cluster formation module documentation. # # ---------------------------------- Various ----------------------------------- # # Require explicit names when deleting indices: # #action.destructive_requires_name: true node.master: true node.data: true
配置说明
核心配置简述 Elasticsearch核心配置 cluster.name:集群名称(随意) node.name: 节点名称(随意) path.data:数据存储的位置,这个目录暂时没有创建,稍后不上 path.logs: 日志存储的位置 network.host: 允许访问的IP,0.0.0.0表示所有,为了安全,可以指定允许访问的IP,并且可以设置多个 http.port: 端口号 cluster.initial_master_nodes: 集群中初始化的主节点,这里与node.name即可 action.auto_create_index: 开始自动创建索引,7.14.0版本开始推荐配置这个属性 ———————————————— 版权声明:本文为CSDN博主「gblfy」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/weixin_40816738/article/details/120426766
- 环境配置、资源分配(切换到root用户执行下面操作)
//资源分配 > vim /etc/security/limits.conf # End of file * soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4096 //内核参数配置 > vim /etc/sysctl.conf vm.max_map_count=262145 //刷新配置 > sysctl -p vm.max_map_count=262145
- 启动并验证(切换到es用户)
>us es //前台启动测试 > cd /opt/es/elasticsearch/bin > ./elasticsearch
启动不报错后再浏览器输入:http://10.99.2.77:9200/
- 如果有跨域问题
//结束前台进程后 > cd /opt/es/elasticsearch/bin > ./elasticsearch -d -p pid
- 如果有跨域问题(编辑elasticsearch.yml)
> cd /opt/es/elasticsearch/config > vim elasticsearch.yml http.cors.enabled: true http.cors.allow-origin: "*"



