单点部署elasticsearch
获取elasticsearch安装包
使用Ubuntu系统部署
root@elk1:~# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.28-linux-x86_64.tar.gz
root@elk1:~# tar xf elasticsearch-7.17.28-linux-x86_64.tar.gz -C /usr/local/
root@elk1:~# ll /usr/local/elasticsearch-7.17.28/
total 672
drwxr-xr-x 9 root root 4096 Feb 20 09:09 ./
drwxr-xr-x 11 root root 4096 Mar 20 15:08 ../
drwxr-xr-x 2 root root 4096 Feb 20 09:09 bin/
drwxr-xr-x 3 root root 4096 Mar 20 15:08 config/
drwxr-xr-x 8 root root 4096 Feb 20 09:09 jdk/
drwxr-xr-x 3 root root 4096 Feb 20 09:09 lib/
-rw-r--r-- 1 root root 3860 Feb 20 09:04 LICENSE.txt
drwxr-xr-x 2 root root 4096 Feb 20 09:06 logs/
drwxr-xr-x 61 root root 4096 Feb 20 09:09 modules/
-rw-r--r-- 1 root root 640930 Feb 20 09:06 NOTICE.txt
drwxr-xr-x 2 root root 4096 Feb 20 09:06 plugins/
-rw-r--r-- 1 root root 2710 Feb 20 09:04 README.asciidoc
# 解压即用
配置elasticsearch
# 1.elasticsearch配置项
root@elk1:~# grep -E "^(path|network|discovery|cluster)" /usr/local/elasticsearch-7.17.28/config/elasticsearch.yml
cluster.name: xu-es-test
path.data: /var/lib/es7
path.logs: /var/log/es7
network.host: 0.0.0.0
discovery.type: single-node
# 2.创建elasticsearch启动用户,并设置权限
root@elk1:~# useradd -m elastic
root@elk1:~# id elastic
uid=1001(elastic) gid=1001(elastic) groups=1001(elastic)
root@elk1:~# chown elastic:elastic -R /usr/local/elasticsearch-7.17.28/
# 3.创建日志和数据的存放目录
root@elk1:~# install -d /var/{lib,log}/es7 -o elastic -g elastic
root@elk1:~# ll /var/{lib,log}/es7 -d
drwxr-xr-x 2 elastic elastic 4096 Mar 20 15:21 /var/lib/es7/
drwxr-xr-x 2 elastic elastic 4096 Mar 20 15:21 /var/log/es7/
启动elasticsearch
root@elk:~# su - elastic -c "/usr/local/elasticsearch-7.17.28/bin/elasticsearch"
root@elk1:~# netstat -tunlp | grep 9200
tcp6 0 0 :::9200 :::* LISTEN 14972/java
root@elk1:~# netstat -tunlp | grep 9300
tcp6 0 0 :::9300 :::* LISTEN 14972/java
root@elk1:~# curl 127.1:9200
{
"name" : "elk1",
"cluster_name" : "xu-es-test",
"cluster_uuid" : "7Xt2qXOaQ1ednFNN3IqW6g",
"version" : {
"number" : "7.17.28",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "139cb5a961d8de68b8e02c45cc47f5289a3623af",
"build_date" : "2025-02-20T09:05:31.349013687Z",
"build_snapshot" : false,
"lucene_version" : "8.11.3",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
# 通过es提供的api进行访问
root@elk1:~# curl 127.1:9200/_cat/nodes
172.16.1.21 38 45 23 0.49 0.67 0.44 cdfhilmrstw * elk1
卸载es环境
# 停止es
root@elk1:~# kill `ps -ef |grep java | grep -v grep |awk '{print $2}'`
# 卸载安装包、用户、配置目录
root@elk1:~# rm -rf /usr/local/elasticsearch-7.17.28/ /var/{lib,log}/es7/
root@elk1:~# userdel -r elastic
本文来自博客园,作者:Linux小菜鸟,转载请注明原文链接:https://www.cnblogs.com/xuruizhao/p/18784206

浙公网安备 33010602011771号