ElasticSearch-7.5.1安装部署-备份

一、说明

本文档基于centos7.6操作系统;如有错误,欢迎留言指正!

二、环境说明

1、全套资料下载

永久有效:ElasticSearch-7.5.1
提取码:oizb

2、虚拟机:

192.168.44.131   2核4G
192.168.44.132   2核4G
192.168.44.133   2核4G

3、端口开放

firewall-cmd --permanent --zone=public --add-port=9200/tcp
firewall-cmd --permanent --zone=public --add-port=9300/tcp
firewall-cmd --permanent --zone=public --add-port=5601/tcp
firewall-cmd --reload

三、开始部署

1、上传安装包至服务器

在这里插入图片描述

2、解压

tar -xvf  elasticsearch-7.5.1-linux-x86_64.tar.gz

在这里插入图片描述

3、修改系统配置文件

3.1 编辑 /etc/sysctl.conf文件

Elasticsearch默认使用mappfs / niofs混合目录来存储索引。默认操作系统对mmap计数的限制可能过低,这可能会导致内存不足的异常

vim /etc/sysctl.conf  

文件加入配置

vm.max_map_count=262144

在这里插入图片描述
刷新配置

sysctl -p

在这里插入图片描述

3.2 修改/etc/security/limits.conf文件
vim /etc/security/limits.conf

加入/修改如下配置

* hard nofile 65536
* soft nofile 65536
* soft nproc 65535
* hard nproc 65535
* soft nproc 65535

在这里插入图片描述

4、配置JDK

4.1 将jDK上传至 /usr/local/java目录下,解压

在这里插入图片描述

4.2 配置环境变量
vim /etc/profile
export JAVA_HOME=/usr/local/java/jdk1.8.0_212
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin

在这里插入图片描述
重新加载

source /etc/profile

5、 修改ElaticSearch配置文件

集群名称(可默认)

cluster.name: elasticsearch-cluster

节点名称
每一台不能一样
192.168.44.131

node.name: node-1

192.168.44.132

node.name: node-2

192.168.44.133

node.name: node-3

数据目录、日志目录、备份目录

path.data: /opt/elasticsearch-7.5.1/data
path.repo: /opt/elasticsearch-7.5.1/es-back
path.logs: /opt/elasticsearch-7.5.1/logs

节点ID
每一台写自己的IP

network.host: 192.168.44.131

集群节点配置

discovery.seed_hosts: ["192.168.44.131", "192.168.44.132","192.168.44.133"]
cluster.initial_master_nodes: ["node-1", "node-2","node3"]

开启x-pack验证

xpack.security.enabled: true

6、启动

6.1 创建用户
useradd es
6.2 授权

如果配置了不同的数据目录、日志目录、备份目录,响应的也需要授权

chown -R es:es elasticsearch-7.5.1
6.3 启动
在这里插入代码片

7、设置密码

7.1 创建密码(启动过程中创建)
cd /opt/elasticsearch-7.5.1/bin
./elasticsearch-setup-passwords interactive
[es@localhost bin]$ ./elasticsearch-setup-passwords interactive
future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/java/jdk1.8.0_212/jre] does not meet this requirement
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,logstash_system,beats_system,remote_monitoring_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]y


Enter password for [elastic]: 
Reenter password for [elastic]: 
Enter password for [apm_system]: 
Reenter password for [apm_system]: 
Enter password for [kibana]: 
Reenter password for [kibana]: 
Enter password for [logstash_system]: 
Reenter password for [logstash_system]: 
Enter password for [beats_system]: 
Reenter password for [beats_system]: 
Enter password for [remote_monitoring_user]: 
Reenter password for [remote_monitoring_user]: 
Changed password for user [apm_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]
[es@localhost bin]$ 
7.2 创建证书
bin/elasticsearch-certutil ca 

执行后会生成证书:
在这里插入图片描述
将该证书拷贝至…/config/下,创建certs目录,放到certs下,此时注意,如果你是root用户创建的,拷贝后一定要授权给es用户
在这里插入图片描述
接着在做配置:

vim elasticsearch.yml

加入下面证书配置(三台都配置一样的)

xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12
xpack.security.transport.ssl.enabled: true
7.3 重新启动ES
./elasticsearch -d
7.4 访问验证

输入用户名和密码后出现下面信息则为成功
在这里插入图片描述
在这里插入图片描述

8、设置开机自启动

编写启动脚本

cd /etc/init.d/
vim es
#!/bin/bash
#
#chkconfig: 345 63 37
#description: elasticsearch
#processname: elasticsearch

ES_HOME=/opt/elasticsearch-7.5.1

case $1 in
  start)
    su - es -c "$ES_HOME/bin/elasticsearch -d -p pid"
    echo "elasticsearch is started"
    ;;
  stop)
    pid=`cat $ES_HOME/pid`
    kill -9 $pid
    echo "elasticsearch is stopped"
    ;;
  restart)
    pid=`cat $ES_HOME/pid`
    kill -9 $pid
    echo "elasticsearch is stopped"
    sleep 1
    su - es -c "$ES_HOME/bin/elasticsearch -d -p pid"
    echo "elasticsearch is started"
    ;;
  *)
    echo "start|stop|restart"
    ;;
esac
exit 0
chmod +x es
chkconfig --add elasticsearch

重启后看es是否启动。至此ES安装完成

8、设置开机自启动

编写启动脚本

cd /etc/init.d/
vim es
#!/bin/bash
#
#chkconfig: 345 63 37
#description: elasticsearch
#processname: elasticsearch

ES_HOME=/opt/elasticsearch-7.5.1

case $1 in
  start)
    su - es -c "$ES_HOME/bin/elasticsearch -d -p pid"
    echo "elasticsearch is started"
    ;;
  stop)
    pid=`cat $ES_HOME/pid`
    kill -9 $pid
    echo "elasticsearch is stopped"
    ;;
  restart)
    pid=`cat $ES_HOME/pid`
    kill -9 $pid
    echo "elasticsearch is stopped"
    sleep 1
    su - es -c "$ES_HOME/bin/elasticsearch -d -p pid"
    echo "elasticsearch is started"
    ;;
  *)
    echo "start|stop|restart"
    ;;
esac
exit 0
chmod +x es
chkconfig --add elasticsearch

重启后看es是否启动。至此ES安装完成

四、安装kibana

kiban就不用集群了

1. 上传kibana安装包,解压

[root@synda-oa opt]# ll
total 232892
drwxr-xr-x. 11 es   es         192 Feb 12 20:31 elasticsearch-7.5.1
drwxr-xr-x. 13 root root       266 Feb 12 21:03 kibana-7.5.1-linux-x86_64
-rw-r--r--.  1 root root 238481011 Feb 12 21:02 kibana-7.5.1-linux-x86_64.tar.gz
[root@synda-oa opt]# pwd
/opt
[root@synda-oa opt]# 

2. 配置kibana

修改config/kibana.yml文件中以下配置即可

server.host: "0.0.0.0"
elasticsearch.hosts: ["http://192.168.44.131:9200","http://192.168.44.132:9200","http://192.168.44.133:9200"]
elasticsearch.username: "kibana"
elasticsearch.password: "Masterpassw0rd!"
i18n.locale: "en"

启动kibana
我们不用es用户启动了

./kibana  --allow-root 

访问: http:192.168.44.131:5601,输入前面安装es时elastic用户的用户名密码登录
在这里插入图片描述
在这里就可以输入查询语句开始使用了
在这里插入图片描述

3、设置开机启动

3.注册服务
新建kibana.service文件

vim /usr/lib/systemd/system/kibana.service

填入以下内容

[Unit]
Description=kibana
After=network.target

[Service]
Type=simple
User=elasticsearch
ExecStart=/usr/local/kibana-7.10.1/bin/kibana
PrivateTmp=true

[Install]
WantedBy=multi-user.target

:wq保存

  1. 设置开机启动
systemctl enable kibana.service 

五、设置快照

1. 创建存储库

选择共享文件系统,输入名称

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

1. 创建快照存储库

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
这时我们可以点击此处立即创建快照
在这里插入图片描述

六、elasticdump使用

1. 安装node

上传后解压node

[root@localhost opt]# ll
total 14460
drwxr-xr-x. 11 es   es        220 Feb 12 20:29 elasticsearch-7.5.1
-rw-r--r--.  1 root root   106742 Feb 12 21:28 elasticsearch-dump-6.67.0.tar.gz
drwxr-xr-x.  6 1001 1001      108 Jun 17  2020 node-v12.18.1-linux-x64
-rw-r--r--.  1 root root 14695604 Feb 12 21:28 node-v12.18.1-linux-x64.tar.xz
[root@localhost opt]# pwd
/opt
[root@localhost opt]# 

配置node环境变量

vim /etc/profile

加入如下内容

export NODE_HOME=/opt/node-v14.16.1-linux-x64
export PATH=$PATH:$NODE_HOME/bin

测试安装

[root@localhost node-v12.18.1-linux-x64]# node -v
v12.18.1
[root@localhost node-v12.18.1-linux-x64]# npm -v
6.14.5
[root@localhost node-v12.18.1-linux-x64]# 

安装完成后,安装elasticdump
这里只是我这么安装,因为可以连接外网,后面我会导出来,离线安装

npm install elasticdump -g

此过程可能会慢很多
在这里插入图片描述
安装完成
在这里插入图片描述

检查:

elasticdump --help

在这里插入图片描述

此时在线的安装已经完成
但是很多时候内网环境并没有网络下载安装,所以我们需要将elasticdump 导出

2. 导出npm 缓存

(1)导出安装好的缓存

```java
npm config get cache  # 查看缓存位置
tar -cf npm-cache.tar .npm 压缩缓存
```
[root@localhost ~]# pwd
/root
[root@localhost ~]# ll
total 16884
-rw-------. 1 root root     1722 Oct 25 14:43 anaconda-ks.cfg
-rw-------. 1 root root        0 Jan 14 17:14 nohup.out
-rw-r--r--. 1 root root 17285120 Feb 12 21:40 npm-cache.tar
[root@localhost ~]# tar -cf npm-cache.tar .npm 

(2)使用时,将该 npm-cache.tar包解压到相同的目录下,再次运行

npm install elasticdump -g

即可安装

3. elasticdump 使用

使用可以参考官网,这里不再详述
elasticdump 使用

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

synda@hzy

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

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

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

打赏作者

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

抵扣说明:

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

余额充值