opensuse安装es8

环境:
Os:opensuse leap 16
es:8.16.6

1.获取安装介质
https://www.elastic.co/downloads/past-releases?product=elasticsearch

 

2.创建中间件安装目录和数据文件、日志文件目录
[root@hadoop-slave1 soft]# mkdir -p /usr/local/services
[root@hadoop-slave1 soft]# mkdir -p /home/middle/elasticsearch/data
[root@hadoop-slave1 soft]# mkdir -p /home/middle/elasticsearch/logs

 

3.创建用户和用户组
[root@pg1 elasticsearch]# groupadd -g 1500 elasticsearch
[root@pg1 elasticsearch]# useradd -u 1500 -g elasticsearch elasticsearch
[root@pg1 elasticsearch]# passwd elasticsearch

 

4.上传到服务器
解压缩并创建数据目录
[root@localhost soft]# cd /soft
[root@localhost soft]# tar -xvf elasticsearch-8.16.6-linux-x86_64.tar.gz
[root@localhost soft]# mv elasticsearch-8.16.6 /usr/local/services/elasticsearch

 

5.将elasticsearch目录权限修改为elasticsearch
[root@hadoop-slave1 config]# cd /usr/local/services
[root@hadoop-slave1 services]# chown -R elasticsearch:elasticsearch ./elasticsearch
同时修改数据文件和日志文件目录给到elasticsearch

[root@hadoop-slave1 services]# cd /home/middle
[root@hadoop-slave1 middle]# chown -R elasticsearch:elasticsearch ./elasticsearch

 

6.创建备份目录
su - root
mkdir -p /home/middle/esbak
chown -R elasticsearch:elasticsearch /home/middle/esbak/

 

7.生成ca文件
生成证书:

su - elasticsearch
[elasticsearch@rac01 bin]$ cd /usr/local/services/elasticsearch/bin
[elasticsearch@master bin]$ ./elasticsearch-certutil ca
一路回车

[elasticsearch@rac01 bin]$./elasticsearch-certutil cert --ca elastic-stack-ca.p12
一路回车

[elasticsearch@localhost bin]$ cd /usr/local/services/elasticsearch
[elasticsearch@master elasticsearch]$ ls
[elasticsearch@localhost elasticsearch]$ ls
bin elastic-certificates.p12 jdk LICENSE.txt modules plugins
config elastic-stack-ca.p12 lib logs NOTICE.txt README.asciidoc

 


这个时候会生成 elastic-certificates.p12 和 elastic-stack-ca.p12 这2个文件
将这两个文件拷贝到config目录下面
[elasticsearch@master elasticsearch]$ mv elastic-certificates.p12 ./config/
[elasticsearch@master elasticsearch]$ mv elastic-stack-ca.p12 ./config/

 

8.修改配置文件

[root@hadoop-slave1 middle]# su - elasticsearch
[elasticsearch@hadoop-slave1 ~]$ cd /usr/local/services/elasticsearch/config
[elasticsearch@hadoop-slave1 config]$ vi elasticsearch.yml
node.name: node01
path.data: /home/middle/elasticsearch/data
path.logs: /home/middle/elasticsearch/logs
network.host: 192.168.1.104
http.port: 19200
##transport.port: 9400 ##不单独指定,默认是9300
path.repo: /home/middle/esbak
discovery.seed_hosts: ["192.168.1.104"]
##初始化参数,启动后去掉该参数 进行重新启动
cluster.initial_master_nodes: ["192.168.1.104"]
##安全认证
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12

##第三方中间件配置参数,看情况需要
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type

 

9.修改jvm参数( /usr/local/services/elasticsearch/config/jvm.options)

################################################################
## 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,
## which should be named with .options suffix, 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:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/8.16/heap-size.html
## for more information
##
################################################################
-Xms4g
-Xmx4g

 

10.系统参数设置
每个节点上都要执行,这里确保每台机器都能启动
[root@rac01 middle]# su - elasticsearch
[elasticsearch@rac01 ~]$ ulimit -Hn
65536

检查是否是65536,不是的话修改修改
/etc/security/limits.conf,该文件最后加入

* soft nofile 65536
* hard nofile 65536


配置 vm.max_map_count
echo "vm.max_map_count=262144" | sudo tee -a /etc/sysctl.conf
sysctl -p

 

11.启动
su - elasticsearch
[elasticsearch@hadoop-slave1 ~]$ cd /usr/local/services/elasticsearch/bin
./elasticsearch -d

 

12.验证
这个时候登陆会报错误

elasticsearch@localhost:/usr/local/services/elasticsearch/bin> curl http://192.168.1.104:19200/?pretty
{
  "error" : {
    "root_cause" : [
      {
        "type" : "security_exception",
        "reason" : "missing authentication credentials for REST request [/?pretty]",
        "header" : {
          "WWW-Authenticate" : [
            "Basic realm=\"security\", charset=\"UTF-8\"",
            "ApiKey"
          ]
        }
      }
    ],
    "type" : "security_exception",
    "reason" : "missing authentication credentials for REST request [/?pretty]",
    "header" : {
      "WWW-Authenticate" : [
        "Basic realm=\"security\", charset=\"UTF-8\"",
        "ApiKey"
      ]
    }
  },
  "status" : 401
}

 

12.安装安全认证(我这里密码全部设置为 elastic)
su - elasticsearch
cd /usr/local/services/elasticsearch/bin
./elasticsearch-setup-passwords interactive

 

13.再次验证
curl -u elastic:elastic http://192.168.1.104:19200/?pretty
curl -u elastic:elastic -X GET "192.168.1.104:19200/_cat/indices?v"

 

14.去掉参数后重新启动
[elasticsearch@hadoop-slave1 ~]$ cd /usr/local/services/elasticsearch/config
[elasticsearch@hadoop-slave1 config]$ vi elasticsearch.yml
##cluster.initial_master_nodes: ["192.168.1.104"]

kill掉相应进程
[elasticsearch@hadoop-slave1 ~]$ cd /usr/local/services/elasticsearch/bin
./elasticsearch -d

posted @ 2026-06-24 11:04  slnngk  阅读(4)  评论(0)    收藏  举报