Skip to content

Commit

Permalink
database
Browse files Browse the repository at this point in the history
  • Loading branch information
chendelin1982 committed Jul 23, 2024
1 parent e74053e commit ab1ce9c
Show file tree
Hide file tree
Showing 20 changed files with 252 additions and 517 deletions.
6 changes: 3 additions & 3 deletions i18n/en/docusaurus-plugin-content-docs/current.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,12 +700,12 @@
"description": "The label for category 集成第三方网关 in sidebar docs"
},
"sidebar.docs.category.管理数据库": {
"message": "管理数据库",
"message": "Manage database",
"description": "The label for category 管理数据库 in sidebar docs"
},
"sidebar.docs.category.管理容器": {
"message": "管理容器",
"description": "The label for category 管理容器 in sidebar docs"
"message": "Manage your container",
"description": "The label for category Manage your container in sidebar docs"
},
"sidebar.docs.category.管理服务器": {
"message": "Manage your server",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import DocCardList from '@theme/DocCardList';
import {useCurrentSidebarCategory} from '@docusaurus/theme-common';

# 使用和管理容器
# Manage and set container

容器技术是 Websoft9 多应用托管平台的核心基础架构组件。因此,在管理应用时,您可能需要执行容器相关的操作。
Container technology is the core infrastructure of Websoft9's multi-application hosting platform.

## 相关指南
## Tutorials

<DocCardList items={useCurrentSidebarCategory().items}/>

## 容器引擎
## Container engines

- [Docker](https://www.docker.com/)
- [Podman](https://podman.io/)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,38 @@ sidebar_position: 6
slug: /container
---

# 容器生命周期与资源管理
# Manage containers resource

Websoft9 控制台是为管理应用的生命周期的而设计。实际托管中,也需要对容器的生命周期进行管理。
The applications hosted by Websoft9 is based on containers, so user need to be familiar with container state and resource management.

## 管理工具
There are several container management tools:

- Docker 官方客户端工具:[docker](https://docs.docker.com/engine/) 命令和 [docker compose](https://docs.docker.com/compose/) 命令
- 可视化 Web 工具:Websoft9 集成 [Portainer](./portainer) 作为唯一个容器可视化管理平台,100% 保持其原生性。
- [docker client commands](https://docs.docker.com/engine/)
- [docker compose](https://docs.docker.com/compose/)
- [Websoft9 Containers](./portainer): Integrated Portainer for container mangement platform
![](./assets/websoft9-containers.png)

Websoft9 控制台的 "网关" 菜单即可进入 Portainer:
![](./assets/websoft9-portainer.png)
## Running container

Websoft9 is fully Docker-compatible, so users can deploy applications consisting of multiple containers directly using [Docker compose templates](https://github.com/Websoft9/docker-library) without relying on the Websoft9 Console.

## 运行容器

Websoft9 完全兼容 Docker,所以用户可以不依赖于 Websoft9 控制台而直接使用 Docker 客户端工具部署由多容器组成的应用。
## Upgrade containers

Websoft9 提供了一个包含 200+ 开源 [Docker compose 模板](https://github.com/Websoft9/docker-library),只需 `docker compose` 命令启动,即可安装任何想要的应用。


## 升级多容器

Docker Compose 升级应用只需运行如下三条命令:
You can use Docker Compose to Upgrade containers by below commands

```
docker-compose down
docker-compose pull
docker-compose up -d
```

## 清空容器日志
## Clear container logs

```
# 获取容器日志路径
# Get the logs path in container
docker inspect --format='{{.LogPath}}' Container_Name
# 清空日志
# Clear the logs
echo "" > log_path
```
Original file line number Diff line number Diff line change
@@ -1,64 +1,83 @@
---
sidebar_position: 1
title: Run commands in container
slug: /inner-container
---

# 在容器内运行命令
# Run commands in the container

用户需要掌握在容器内运行命令的操作,便于更好的实现个性化的托管设置。
When managing Docker containers, you may need to connect to a running container. It is very helpful if you want to see what is happening inside the container. You can use the [docker exec](https://docs.docker.com/reference/cli/docker/container/exec/) command, SSH into a running Docker container, or get a shell to the container.

## 原理
## Concepts

在容器内运行命令之前,先列出几个相关的原理:
Before running commands inside a container, let's list a few related concepts:

- 容器内运行命令与 Linux 虚拟机内运行命令的原理基本一致
- 容器内运行命令改变的是容器的文件系统
- 容器内也可以切换用户
- 容器内改变文件系统后,也需要考虑权限问题
- 容器内安装或下载的软件包,若没有存放到持久化目录中,重建容器后这些增加的文件会丢失
- Running commands in containers is similar to host machine.
- Commands in containers alter the container's filesystem.
- You can change the user account within containers.
- Filesystem changes in containers require permission considerations.
- Software installed in non-persistent directories will be lost after redeploy.

## 进入容器{#docker-exec}
## Method of access to containers{#docker-exec}

进入容器后,默认便可以运行 shell 命令。有两种进入容器的方法:
Two methods for you to access container:

### 登录服务器运行命令{#fromserver}
### Access by docker exec commands{#fromserver}

Docker 自身提供了进入了容器的操作指令 [docker exec](https://docs.docker.com/reference/cli/docker/container/exec/) ,具体步骤:
The `docker exec` command runs a new command in a running container at your host machine.

- 确认容器的 shell 命令环境: bash, sh, ash 三者之一,大部分都是 bash
- 服务器端运行 `docker ps` 找到容器名称,然后运行命令 `docker exec -it container_name bash`
```
# sample1
docker exec -it container_name bash
### 在线运行命令{#fromweb}
# sample2
docker exec -it container_name sh
Websoft9 提供了可视化的在线运行容器命令的功能,它是 **docker exec** 的 Web 实现。
# sample2
docker exec -it container_name ash
1. Websoft9 控制台进入应用的详情页面,在 "容器" 标签页下点击 `<>` 操作
![](./assets/websoft9-myapps-runcmd-websoft9.png)
# sample4
docker run --name mycontainer -d -i -t alpine /bin/sh
```

You should know or try to get the shell environment of your container, it may `bash`, `sh`, or `ash`

### Access container by Websoft9 Console{#fromweb}

2. 在容器命令行控制台,点击 **Connetc** 按钮,开始连接
You can access container by Websoft9 Console which is the implementation of **docker exec** command.

- Command:选择可用的命令执行(三选一,bash 绝大部分情况下都可用)
- user: 默认 root(推荐)
1. Login to Websoft9 Console, go to application mangement from **My Apps**

2. Open the **Containers** tab, click `<>` icon of Actions column
![](./assets/websoft9-myapps-runcmd-websoft9.png)

3. 成功连接,即可开始运行命令
3. It will jump to the **Container console** and you can select the items and **Connect** container
![](./assets/websoft9-container-console.png)

4. Once connection success, you can run shell command from terminal
![](./assets/websoft9-myapps-runcmdss-websoft9.png)

## 安装软件包

容器内安装软件与 Linux 安装软件基本一致:
## Commans samples

### Install packages in the container

Install packages in the container is the same with host machine:

- Install by Linux repo tools: `apt`, `yum`, `dnf`, `pacman`, `zypper`, `apk`
- Download and compile
- Install by languages repo tools: `pip`, `npm`, `yarn`, `gem`

- 操作系统包管理器:apt, yum, dnf, pacman, zypper, apk 等
- 手工下载编译安装
- 程序语言安装包:pip, npm, yarn, gem 等
### Check system settings in the container

## 查看容器内配置
- Process and services: `top`, `ps aux`
- Get users: `cat /etc/passwd`
- Network: `netstat -tulnp`, `ss -tuln`

- 进程与服务:`top`, `ps aux`
- 用户:`cat /etc/passwd`
- 网络:`netstat -tulnp`, `ss -tuln`
## Troubleshoot

## 权限处理
### Container permission issues?

- 如果 Dockerfile 没有创建普通用户,容器就会默认以 root 用户权限运行。
- 容器 root 与宿主机 root 是同一个用户,但容器 root 需加上 `--privileged=true` 才拥有宿主机同等权限
- 容器内可以通过 `su` 切换用户
- If the dockerfile does not create non-root user, the container will run as root by default.
- Container root equals host root, needs `--privileged=true` for same privileges.
- You can switch users within the container using `su`.
Original file line number Diff line number Diff line change
Expand Up @@ -3,74 +3,75 @@ sidebar_position: 2
slug: /docker-server
---

# 设置 Docker 服务端
# Set your Docker

本章介绍使用 Websoft9 托管应用过程中,可能需要对 Docker 服务端进行的设置。
You may need to set your Docker when using Websoft9 for applications hosting.

## 任务指南
## Tutorials


### 安装 Docker{#install}
### Install Docker{#install}

如果您的服务器尚未安装 Docker,请使用如下命令安装它:
If there not have Docker on your server, please run below command to install it.

```
wget -O - https://websoft9.github.io/websoft9/install/install_docker.sh | bash
```

### 更换默认镜像仓库{#imagespeed}
### Add your registry-mirrors{#imagespeed}

Docker 默认从 Dockerhub 下载镜像。如果想更换仓库地址,请参考如下步骤:
You will need to set up docker registry-mirrors if the server is having network issues accessing DockerHub.

1. 自行准备新的仓库地址或选择[第三方镜像仓库](./imagehub)
1. Prepare your [registry mirrors](./imagehub)


2. 向 Docker 配置文件(不存在需新建) */etc/docker/daemon.json* 中插入仓库地址(支持多个)
2. Edit `/etc/docker/daemon.json` and add the **registry-mirrors** key and value, to make the change
```
{
"registry-mirrors": ["https://registry.docker-cn.com","http://hub-mirror.c.163.com"]
}
```
3. 重启 Docker 服务后生效
3. Restart docker service
```
sudo systemctl restart docker
```
### 更改默认存储卷位置{#changepath}
### Change docker volume path{#changepath}
在Docker中,*/var/lib/docker/volumes* 是默认存储卷的位置。如果你的主分区空间有限,你可能会想要更改这个位置。
The default docker volume path is */var/lib/docker/volumes*, you can change it by below steps:
1. 停止 Docker 服务
1. Stop you docker service
```
sudo systemctl stop docker
```
2. 向 Docker 配置文件(不存在需新建) */etc/docker/daemon.json* 中插入 data-root 属性来指定新的目录
2. Edit `/etc/docker/daemon.json` and add the **data-root** key and value, to make the change
```
{
"data-root": "/new/path/to/docker-data"
}
```
3. 将现有的 Docker 数据移动到新位置
3. Move the data to new path
```
sudo mv /var/lib/docker /new/path/to/docker-data
```
4. 重启服务后生效
## 相关内容
- [Docker 服务端配置参数](./parameter#path)
- [Docker 命令行](./parameter#cmd)
- [开启 Docker API 外部访问](https://docs.docker.com/reference/cli/dockerd/#daemon-socket-option)
## 参考文档
- [Docker 官方文档](https://docs.docker.com/)
4. Restart docker service
```
sudo systemctl restart docker
```
## 故障{#troubleshoot}
## Related topics
#### docker-containerd.socket: timeout?
- [Docker parameters](./parameter#path)
- [Docker CLI](./parameter#cmd)
- [Enable Docker API](https://docs.docker.com/reference/cli/dockerd/#daemon-socket-option)
- [Docker docs](https://docs.docker.com/)
请关闭 SELinux,如果 SELinux 开启会导致 docker 无法启动。
## Troubleshoot{#troubleshoot}
#### Windows 中 Docker 无法启动?
### docker-containerd.socket: timeout?
检查您的 Windows 是否安装了 360 之类的安全软件,如果有请卸载它。
Please turn off SELinux. If SELinux is on, docker will not start.
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ slug: /database
import DocCardList from '@theme/DocCardList';
import {useCurrentSidebarCategory} from '@docusaurus/theme-common';

# 创建、连接和管理数据库
# Create, connect and manage databases

Websoft9 托管平台在设计上专注于为用户提供数据库的灵活使用和管理。不论是与应用捆绑启动的数据库,独立运行的数据库服务,还是第三方数据库实例,平台都能够提供一个集中的、[可视化的管理接口](./dbtools)
Websoft9 focuses on flexible database usage and management. Whether it's an application's database, standalone database service, or third-party database instance, the platform offers a [Graphical and centralized interface](./dbtools).

这样的设计使得数据库的维护和操作变得简洁而直观,无论数据库的部署形式如何,用户都能从同一平台上获得一致的管理体验。
This design simplifies and streamlines database maintenance and operations. Regardless of deployment form, users receive a consistent management experience from the same platform.

## 指南
## Tutorials

<DocCardList items={useCurrentSidebarCategory().items}/>

## 问题
## Troubleshoot

#### 应用默认的数据库形式?
#### Where is the application's database?

Websoft9 默认为每个应用捆绑一个包含独立配置的数据库实例,不同应用的数据库是独立运行的,应用间数据互不干扰。
Websoft9 create independent database container for application which need database. The data between applications do not interfere with each other.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sidebar_position: 2.0
slug: /connectdb
---

# 连接应用的数据库
# Connect App database

Websoft9 提供了两种数据库连接方式:Web 在线连接和本地客户端连接。

Expand Down
Loading

0 comments on commit ab1ce9c

Please sign in to comment.