Skip to content

Commit

Permalink
vault backup: 2024-10-15 14:58:44
Browse files Browse the repository at this point in the history
Affected files:
.obsidian/workspace.json
_posts/pool/2024-10-08.md
_posts/pool/2024-10-15-Elasticsearch远程docker部署.md
  • Loading branch information
cmgzn committed Oct 15, 2024
1 parent 4c8ca5f commit a1819d4
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 6 deletions.
17 changes: 11 additions & 6 deletions .obsidian/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
"id": "a7dc62ad9734e7f6",
"type": "leaf",
"state": {
"type": "diff-view",
"type": "markdown",
"state": {
"file": "_posts/engineering/2024-09-09-linux新机器安装nvidia驱动.md",
"staged": false
"file": "_posts/pool/2024-10-15-Elasticsearch远程docker部署.md",
"mode": "source",
"source": false
}
}
}
Expand Down Expand Up @@ -84,6 +85,7 @@
"state": {
"type": "backlink",
"state": {
"file": "_posts/pool/2024-10-15-Elasticsearch远程docker部署.md",
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical",
Expand All @@ -100,6 +102,7 @@
"state": {
"type": "outgoing-link",
"state": {
"file": "_posts/pool/2024-10-15-Elasticsearch远程docker部署.md",
"linksCollapsed": false,
"unlinkedCollapsed": true
}
Expand All @@ -121,7 +124,9 @@
"type": "leaf",
"state": {
"type": "outline",
"state": {}
"state": {
"file": "_posts/pool/2024-10-15-Elasticsearch远程docker部署.md"
}
}
},
{
Expand Down Expand Up @@ -170,6 +175,8 @@
},
"active": "a7dc62ad9734e7f6",
"lastOpenFiles": [
"_posts/pool/2024-10-08.md",
"_posts/pool/2024-10-15-Elasticsearch远程docker部署.md",
"_posts/engineering/2024-09-09-linux新机器安装nvidia驱动.md",
"_posts/pool/2024-09-25.md",
"_posts/brain/2024-09-06-github_page+obsidian实现个人笔记云管理.md",
Expand Down Expand Up @@ -201,8 +208,6 @@
"assets/Excalidraw",
"_posts/engineering/2024-08-13-脚本内指定GPU部署.md",
"_posts/engineering/2024-08-13-两台Linux机器传文件.md",
"_posts/engineering/2024-08-13-conda环境库信息导出与复原.md",
"_posts/engineering/2024-08-13-linux服务器离线安装anaconda.md",
"_posts/debug",
"assets/img",
"assets/新建文件夹",
Expand Down
7 changes: 7 additions & 0 deletions _posts/pool/2024-10-08.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title:
author: X
date: "2024-10-08 10:39:05 +0800"
categories:
tags:
---
169 changes: 169 additions & 0 deletions _posts/pool/2024-10-15-Elasticsearch远程docker部署.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
---
title: Elasticsearch远程docker部署
author: X
date: 2024-10-15 14:27:40 +0800
categories:
- engineering
- 数据库
tags:
- Elasticsearch
- docker
- linux
---
# 安装docker
没什么好说的,国内参考这个:

[如何在 Ubuntu 22.04 LTS 中安装 Docker 和 Docker Compose](https://www.cnblogs.com/carmi/p/17939025)

中间因为试了其他方法,出了一些冲突,去`etc/apt`下面挨个翻一遍,把docker相关全删了,重新跑一下。

省流:

## 1. 更新ubuntu
```bash
sudo apt update
sudo apt upgrade
sudo apt full-upgrade
```

这里因为之前装nvidia驱动时乱搞,多装了一个版本,所以也出错了,照例循着报错去`etc/apt`把不对的依赖删了就行了。删之前检查一下确定是不用的驱动版本。

## 2. 添加Docker库

首先,安装必要的证书并允许 apt 包管理器使用以下命令通过 HTTPS 使用存储库:

```bash
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg lsb-release
```

然后,运行下列命令添加 Docker 的官方 GPG 密钥:

```bash
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
```

添加 Docker 官方库:

```bash
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
```

使用命令更新 Ubuntu 源列表:

```bash
sudo apt update
```

## 3. 安装 Docker

这里只摘取安装最新版本的方法:

运行下列命令在 Ubuntu 22.04 LTS 服务器中安装最新 Docker CE:

```bash
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin
```

手动选择版本的方法看原文。

安装完成后,运行如下命令验证 Docker 服务是否在运行:

```bash
sudo systemctl status docker
```

如果没有运行,运行以下命令运行 Docker 服务:

```bash
sudo systemctl start docker
```

使 Docker 服务在每次重启时自动启动:

```bash
sudo systemctl enable docker
```

可以使用以下命令查看已安装的 Docker 版本:

```bash
sudo docker version
```

## 4. 测试docker

原文有点小错误,实际是运行:

```bash
sudo docker run hello-world
```

上述命令会下载一个 Docker 测试镜像,并在容器内执行一个 “hello_world” 样例程序。

这里不出意外会有网络问题,参考[docker国内镜像源配置及走代理设置](https://blog.csdn.net/Lichen0196/article/details/137355517)设置一下:

`/etc/docker/daemon.json`处,没有的话自行创建。

```bash
sudo vim /etc/docker/daemon.json
```

填写:
```json
{
"registry-mirrors": [
"https://registry.docker-cn.com",
"https://docker.mirrors.ustc.edu.cn",
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com",
"https://ccr.ccs.tencentyun.com"
]
}
```

重启docker,注意由于走的是守护程序daemon,所以daemon进程也需要重启。

```bash
sudo systemctl daemon-reload #重启daemon进程
sudo systemctl restart docker #重启docker
```

最后验证:
```bash
docker info
```

检查info里面是否包含:
```plain
Registry Mirrors:
https://docker.mirrors.ustc.edu.cn/
http://hub-mirror.c.163.com/
https://mirror.ccs.tencentyun.com/
https://registry.docker-cn.com/
```


# 从Docker安装Elasticsearch

[官方教程](https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html)

按步骤走就可以。需要注意,创建容器时需要调整一下自己需要的设置,示例提供的设置需要https验证,以及开启了试用,只想用基础版的可以取消。最后多方调试,苯人用的设置如下:

```bash
sudo docker run -p 9200:9200 -p 9300:9300 -d --name es01 --network elastic \
-e ELASTIC_PASSWORD=$ELASTIC_PASSWORD \
-e "discovery.type=single-node" \
-e "xpack.security.http.ssl.enabled=false" \
-e "xpack.license.self_generated.type=basic" \
docker.elastic.co/elasticsearch/elasticsearch:8.15.2
```

这种方法下密码可以通过环境变量自己指定,并且关掉了https验证以及试用版。REST API测试:

```bash
curl -u elastic:$ELASTIC_PASSWORD http://localhost:9200
```

利用vscode转发端口到本地,本地也可以顺畅联通。

表面看起来很简单,实际为了找到合适的设置,笔者遭老罪了^v^...

0 comments on commit a1819d4

Please sign in to comment.