molliezhang
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 在 KubeSphere 中部署 ClickHouse 集群 [![hackmd-github-sync-badge](https://hackmd.io/2CbEsAMfSZS-IkBzhEmklg/badge)](https://hackmd.io/2CbEsAMfSZS-IkBzhEmklg) [ClickHouse](https://clickhouse.tech/) 是一款用于联机分析 (OLAP) 的列式数据库管理系统 (DBMS)。[RadonDB ClickHouse](https://github.com/radondb/radondb-clickhouse-kubernetes) 是一款深度定制的 ClickHouse 集群应用,完美保持了 ClickHouse 集群功能特性,并具备集群自动管理、集群数据重分布、高性能低成本等优势功能特性。 本教程演示了如何在 KubeSphere 上部署 ClickHouse Operator 和 ClickHouse 集群。 ## 准备工作 - 请确保[已启用 OpenPitrix 系统](https://kubesphere.io/zh/docs/pluggable-components/app-store/)。 - 您需要创建一个企业空间、一个项目和一个用户帐户 (`project-regular`) 供本教程操作使用。该帐户需要是平台普通用户,并邀请至项目中赋予 `operator` 角色作为项目操作员。本教程中,请以 `project-regular` 身份登录控制台,在企业空间 `demo-workspace` 中的 `demo-project` 项目中进行操作。有关更多信息,请参见[创建企业空间、项目、帐户和角色](https://kubesphere.io/zh/docs/quick-start/create-workspace-and-project/)。 - 请确保 KubeSphere 项目网关已开启外网访问。有关更多信息,请参见[项目网关](https://kubesphere.io/zh/docs/project-administration/project-gateway/)。 ## 动手实验 ### 步骤 1:部署 ClickHouse Operator 1. 以 `admin` 身份登录 KubeSphere 的 Web 控制台,并使用**工具箱**中的 **Kubectl** 执行以下命令来安装 ClickHouse Operator。建议至少准备 2 个可用集群节点。 ```bash kubectl apply -f https://raw.githubusercontent.com/radondb/radondb-clickhouse-kubernetes/main/clickhouse-operator-install.yml ``` > ClickHouse Operator 将会被安装在 `kube-system` 命名空间下,因此一个 Kubernetes 集群只需要安装一次 ClickHouse Operator。 **预期结果** ```powershell customresourcedefinition.apiextensions.k8s.io/clickhouseinstallations.clickhouse.altinity.com configured customresourcedefinition.apiextensions.k8s.io/clickhouseinstallationtemplates.clickhouse.altinity.com created customresourcedefinition.apiextensions.k8s.io/clickhouseoperatorconfigurations.clickhouse.altinity.com created serviceaccount/clickhouse-operator created clusterrolebinding.rbac.authorization.k8s.io/clickhouse-operator-kube-system created configmap/etc-clickhouse-operator-files created configmap/etc-clickhouse-operator-confd-files created configmap/etc-clickhouse-operator-configd-files created configmap/etc-clickhouse-operator-templatesd-files created configmap/etc-clickhouse-operator-usersd-files created deployment.apps/clickhouse-operator created service/clickhouse-operator-metrics created ``` 2. 执行如下命令可查看 ClickHouse Operator 资源状态。 ```bash kubectl get all --selector=app=clickhouse-operator -n kube-system ``` **预期结果** ```powershell NAME READY STATUS RESTARTS AGE pod/clickhouse-operator-644fcb8759-9tfcx 2/2 Running 0 4m32s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/clickhouse-operator-metrics ClusterIP 10.96.72.49 <none> 8888/TCP 4m32s NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/clickhouse-operator 1/1 1 1 4m32s NAME DESIRED CURRENT READY AGE replicaset.apps/clickhouse-operator-644fcb8759 1 1 1 4m32s ``` ### 步骤 2:添加应用仓库 1. 以 `ws-admin` 身份登录 KubeSphere 的 Web 控制台。在企业空间中,进入**应用管理**下的**应用仓库**页面,点击**添加仓库**。 ![add-repo](deploy-clickhouse/add-repo.png) 2. 在出现的对话框中,输入 `clickhouse` 作为应用仓库名称,输入 `https://radondb.github.io/radondb-clickhouse-kubernetes/` 作为仓库的 URL。点击**验证**以验证 URL。在 URL 旁边呈现一个绿色的对号,验证通过后,点击**确定**继续。 ![add-clickhouse](deploy-clickhouse/add-clickhouse.png) 3. 将仓库成功导入到 KubeSphere 之后,在列表中可查看 ClickHouse 仓库。 ![repo-added](deploy-clickhouse/repo-added.png) ### 步骤 3:部署 ClickHouse 集群 1. 以 `project-regular` 身份登录 KubeSphere 的 Web 控制台。在 `demo-project` 项目中,进入**应用负载**下的**应用**页面,点击**部署新应用**。 ![click-deploy-new-app](deploy-clickhouse/click-deploy-new-app.png) 2. 在对话框中,选择**来自应用模板**。 ![from-app-templates](deploy-clickhouse/from-app-templates.png) 3. 从下拉菜单中选择 `clickhouse` 应用仓库 ,然后点击 **clickhouse-cluster**。 ![clickhouse-cluster](deploy-clickhouse/clickhouse-cluster.png) 4. 在**配置文件**选项卡,可以直接通过控制台查看配置信息,也可以通过下载默认 `values.yaml` 文件查看。在**版本**列框下,选择一个版本号,点击**部署**以继续。 ![chart-tab](deploy-clickhouse/chart-tab.png) 5. 在**基本信息**页面,确认应用名称、应用版本以及部署位置。点击**下一步**以继续。 ![basic-info](deploy-clickhouse/basic-info.png) 6. 在**应用配置**页面,可以编辑 `values.yaml` 文件,也可以直接点击**部署**使用默认配置。 ![click-deploy](deploy-clickhouse/click-deploy.png) 7. 等待 ClickHouse 集群正常运行。可在**工作负载**下的**应用**页面,查看部署的应用。 ![app-running](deploy-clickhouse/app-running.png) ### 步骤 4:查看 ClickHouse 集群状态 1. 以 `project-regular` 身份登录 KubeSphere 的 Web 控制台。 2. 进入**应用负载**下的**工作负载**页面,点击**有状态副本集**,查看集群状态。 ![statefulsets-running](deploy-clickhouse/statefulsets-running.png) 进入一个有状态副本集群详情页面,点击**监控**标签页,可查看一定时间范围内的集群指标。 ![statefulset-monitoring](deploy-clickhouse/statefulset-monitoring.png) 3. 进入**应用负载**下的**容器组**页面,可查看所有状态的容器。 ![pods-running](deploy-clickhouse/pods-running.png) 4. 进入**存储管理**下的**存储卷**页面,可查看存储卷,所有组件均使用了持久化存储。 ![volumes](deploy-clickhouse/volumes.png) 查看某个存储卷用量信息,以其中一个数据节点为例,可以看到当前存储的存储容量和剩余容量等监控数据。 ![volume-status](deploy-clickhouse/volume-status.png) 5. 在项目**概览**页面,可查看当前项目资源使用情况。 ![project-overview](deploy-clickhouse/project-overview.png) ### 步骤 5:访问 ClickHouse 集群 1. 以 `admin` 身份登录 KubeSphere 的 Web 控制台,将鼠标悬停在右下角的锤子图标上,选择 **Kubectl**。 2. 打开终端窗口,执行如下命令,并输入 ClickHouse 集群用户名和密码。 ```bash kubectl edit chi <app name> -n <project name> ``` > 以下命令示例中 **app name** 为 `clickhouse-app` ,**project name** 为 `demo-project`。 ![get-username-password](deploy-clickhouse/get-username-password.png) 3. 执行如下命令,访问 ClickHouse 集群,并可通过 `show databases` 命令查看数据库。 ```bash kubectl exec -it <pod name> -n <project name> -- clickhouse-client --user=<user name> --password=<user password> ``` > - 以下命令示例中 **pod name** 为 `chi-clickhouse-app-all-nodes-0-1-0` ,**project name** 为 `demo-project`,**user name** 为 `clickhouse`,**password** 为 `clickh0use0perator`。 > > - 可在**应用负载**的**容器组**下获取 **pod name**。 ![use-clickhouse](deploy-clickhouse/use-clickhouse.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully