Yu-Jung Cheng
    • 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
    • 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 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
    # Setup Ceph storage via cephadm ###### tags: `ceph` Example of Ceph storage cluster setup via cephadm. I setup Ceph storage for OpenStack to use as "shared" storage which allow "live-migration" of instance. OpenStack setup: https://hackmd.io/v2HFpS2AS8CVXiv_I2svZg (kolla-ansible) #### Environment ``` IP Address hostname Ceph Node ----------------------------------------- 192.168.1.23 nuc111 deploy & mon 192.168.1.24 nuc71 osd 192.168.1.25 nuc72 osd 192.168.1.26 nuc73 osd ``` The nuc111 will be deploy node, and initial ceph monitor host. (cephadm will auto add 2 addtional monitors automatically base on cluster size) The nuc71, nuc72 and nuc73 are OSD hosts, they have additional disk /dev/sdb (usb 3.0 drive) for OSD drive. #### Steps Create **cephadmin** user and set to sudoer ``` root@nuc111:~# useradd -m -s /bin/bash cephadmin root@nuc111:~# passwd cephadmin New password: Retype new password: passwd: password updated successfully root@nuc111:~# echo "cephadmin ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers.d/cephadmin root@nuc111:~# ls /etc/sudoers.d/ cephadmin README root@nuc111:~# chmod 0440 /etc/sudoers.d/cephadmin ``` Install **cephadm** tool ``` root@nuc111:~# apt install cephadm Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: libfwupdplugin1 libisns0 Use 'apt autoremove' to remove them. Recommended packages: docker.io The following NEW packages will be installed: cephadm 0 upgraded, 1 newly installed, 0 to remove and 11 not upgraded. Need to get 58.5 kB of archives. After this operation, 307 kB of additional disk space will be used. Get:1 http://au.archive.ubuntu.com/ubuntu focal-updates/universe amd64 cephadm amd64 15.2.16-0ubuntu0.20.04.1 [58.5 kB] Fetched 58.5 kB in 0s (665 kB/s) Selecting previously unselected package cephadm. (Reading database ... 130835 files and directories currently installed.) Preparing to unpack .../cephadm_15.2.16-0ubuntu0.20.04.1_amd64.deb ... Unpacking cephadm (15.2.16-0ubuntu0.20.04.1) ... Setting up cephadm (15.2.16-0ubuntu0.20.04.1) ... Adding system user cephadm....done ``` **__NOTE__**: or install via curl to fetch most recent version. For example ``` root@node1:~# curl --silent --remote-name --location https://github.com/ceph/ceph/raw/quincy/src/cephadm/cephadm root@node1:~# chmod +x ./cephadm ``` Switch to **cephadmin** user ``` root@nuc111:~# su cephadmin - cephadmin@nuc111:/root$ ``` Bootstrap a new cluster ``` cephadmin@nuc111:~$ sudo cephadm bootstrap --mon-ip 192.168.1.23 Creating directory /etc/ceph for ceph.conf Verifying podman|docker is present... Verifying lvm2 is present... Verifying time synchronization is in place... Unit chrony.service is enabled and running Repeating the final host check... podman|docker (/usr/bin/docker) is present systemctl is present lvcreate is present Unit chrony.service is enabled and running Host looks OK Cluster fsid: 16e21856-6030-11ed-8a24-db02e0e54b22 Verifying IP 192.168.1.23 port 3300 ... Verifying IP 192.168.1.23 port 6789 ... Mon IP 192.168.1.23 is in CIDR network 192.168.1.0/24 Pulling container image quay.io/ceph/ceph:v15... Extracting ceph user uid/gid from container image... Creating initial keys... Creating initial monmap... Creating mon... Waiting for mon to start... Waiting for mon... mon is available Assimilating anything we can from ceph.conf... Generating new minimal ceph.conf... Restarting the monitor... Setting mon public_network... Creating mgr... Verifying port 9283 ... Wrote keyring to /etc/ceph/ceph.client.admin.keyring Wrote config to /etc/ceph/ceph.conf Waiting for mgr to start... Waiting for mgr... mgr not available, waiting (1/10)... mgr not available, waiting (2/10)... mgr not available, waiting (3/10)... mgr not available, waiting (4/10)... mgr not available, waiting (5/10)... mgr is available Enabling cephadm module... Waiting for the mgr to restart... Waiting for Mgr epoch 5... Mgr epoch 5 is available Setting orchestrator backend to cephadm... Generating ssh key... Wrote public SSH key to to /etc/ceph/ceph.pub Adding key to root@localhost's authorized_keys... Adding host nuc111... Deploying mon service with default placement... Deploying mgr service with default placement... Deploying crash service with default placement... Enabling mgr prometheus module... Deploying prometheus service with default placement... Deploying grafana service with default placement... Deploying node-exporter service with default placement... Deploying alertmanager service with default placement... Enabling the dashboard module... Waiting for the mgr to restart... Waiting for Mgr epoch 13... Mgr epoch 13 is available Generating a dashboard self-signed certificate... Creating initial admin user... Fetching dashboard port number... Ceph Dashboard is now available at: URL: https://NUC11ATKC41:8443/ User: admin Password: plur7o63uu You can access the Ceph CLI with: sudo /usr/sbin/cephadm shell --fsid 16e21856-6030-11ed-8a24-db02e0e54b22 -c /etc/ceph/ceph.conf -k /etc/ceph/ceph.client.admin.keyring Please consider enabling telemetry to help improve Ceph: ceph telemetry on For more information see: https://docs.ceph.com/docs/master/mgr/telemetry/ Bootstrap complete. ``` **__NOTE__**: add `--skip-monitoring-stack` option to skip monitoring stack (Prometheus, Grafana, etc...) deploy. **__NOTE__**: add `--cluster-network` to use cluster network. (for example, 192.168.122.0/24) (for newer cephadm version??) https://github.com/ceph/ceph/pull/38911 When login dashbaoard first time, you will be asked to update password. Here I simply update the password. ``` username/password: admin/cephadmin ``` Check Ceph containers ``` cephadmin@nuc111:~$ sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 15225fbe7d8a quay.io/prometheus/alertmanager:v0.20.0 "/bin/alertmanager -…" 3 minutes ago Up 3 minutes ceph-16e21856-6030-11ed-8a24-db02e0e54b22-alertmanager.nuc111 23d37d214780 quay.io/ceph/ceph-grafana:6.7.4 "/bin/sh -c 'grafana…" 3 minutes ago Up 3 minutes ceph-16e21856-6030-11ed-8a24-db02e0e54b22-grafana.nuc111 a506c9016de5 quay.io/prometheus/prometheus:v2.18.1 "/bin/prometheus --c…" 4 minutes ago Up 4 minutes ceph-16e21856-6030-11ed-8a24-db02e0e54b22-prometheus.nuc111 795ec188ff2a quay.io/prometheus/node-exporter:v0.18.1 "/bin/node_exporter …" 4 minutes ago Up 4 minutes ceph-16e21856-6030-11ed-8a24-db02e0e54b22-node-exporter.nuc111 a497030e7c57 quay.io/ceph/ceph:v15 "/usr/bin/ceph-crash…" 5 minutes ago Up 5 minutes ceph-16e21856-6030-11ed-8a24-db02e0e54b22-crash.nuc111 19e955a4dadc quay.io/ceph/ceph:v15 "/usr/bin/ceph-mgr -…" 6 minutes ago Up 6 minutes ceph-16e21856-6030-11ed-8a24-db02e0e54b22-mgr.nuc111.oezajx 6120dd3bf195 quay.io/ceph/ceph:v15 "/usr/bin/ceph-mon -…" 6 minutes ago Up 6 minutes ceph-16e21856-6030-11ed-8a24-db02e0e54b22-mon.nuc111 ``` Check Ceph status ``` cephadmin@nuc111:~$ sudo /usr/sbin/cephadm shell --fsid 16e21856-6030-11ed-8a24-db02e0e54b22 -c /etc/ceph/ceph.conf -k /etc/ceph/ceph.client.admin.keyring Using recent ceph image quay.io/ceph/ceph@sha256:c08064dde4bba4e72a1f55d90ca32df9ef5aafab82efe2e0a0722444a5aaacca root@nuc111:/# sudo ceph -s cluster: id: 16e21856-6030-11ed-8a24-db02e0e54b22 health: HEALTH_WARN OSD count 0 < osd_pool_default_size 3 services: mon: 1 daemons, quorum nuc111 (age 8m) mgr: nuc111.oezajx(active, since 7m) osd: 0 osds: 0 up, 0 in data: pools: 0 pools, 0 pgs objects: 0 objects, 0 B usage: 0 B used, 0 B / 0 B avail pgs: ``` Install Ceph-common package so we can use ceph command to check cluster directly ``` cephadmin@nuc111:~$ sudo cephadm version Using recent ceph image quay.io/ceph/ceph@sha256:c08064dde4bba4e72a1f55d90ca32df9ef5aafab82efe2e0a0722444a5aaacca ceph version 15.2.17 (8a82819d84cf884bd39c17e3236e0632ac146dc4) octopus (stable) cephadmin@nuc111:~$ sudo cephadm add-repo --release octopus Installing repo GPG key from https://download.ceph.com/keys/release.asc... Installing repo file at /etc/apt/sources.list.d/ceph.list... cephadmin@nuc111:~$ sudo cephadm install ceph-common Installing packages ['ceph-common']... ``` ``` cephadmin@nuc111:~$ sudo ceph -s cluster: id: 16e21856-6030-11ed-8a24-db02e0e54b22 health: HEALTH_WARN OSD count 0 < osd_pool_default_size 3 services: mon: 1 daemons, quorum nuc111 (age 12m) mgr: nuc111.oezajx(active, since 12m) osd: 0 osds: 0 up, 0 in data: pools: 0 pools, 0 pgs objects: 0 objects, 0 B usage: 0 B used, 0 B / 0 B avail pgs: ``` Add host label to nuc111 ``` cephadmin@nuc111:~$ sudo ceph orch host ls HOST ADDR LABELS STATUS nuc111 nuc111 cephadmin@nuc111:~$ sudo ceph orch host label add nuc111 _admin Added label _admin to host nuc111 cephadmin@nuc111:~$ sudo ceph orch host ls HOST ADDR LABELS STATUS nuc111 nuc111 _admin ``` Copy public key of Ceph to OSD hosts ``` cephadmin@nuc111:~$ ssh-copy-id -f -i /etc/ceph/ceph.pub root@nuc71 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/etc/ceph/ceph.pub" The authenticity of host 'nuc71 (192.168.1.24)' can't be established. ECDSA key fingerprint is SHA256:jwfxrwrwnLwLblfkfLJC3Yr894+FGQznY8+ylYTNXR8. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes root@nuc71's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'root@nuc71'" and check to make sure that only the key(s) you wanted were added. cephadmin@nuc111:~$ ssh-copy-id -f -i /etc/ceph/ceph.pub root@nuc72 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/etc/ceph/ceph.pub" The authenticity of host 'nuc72 (192.168.1.25)' can't be established. ECDSA key fingerprint is SHA256:9gXSkvu9mZsfNu56cQgMcSYnfEr33h5haoYs8CVxh6E. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes root@nuc72's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'root@nuc72'" and check to make sure that only the key(s) you wanted were added. cephadmin@nuc111:~$ ssh-copy-id -f -i /etc/ceph/ceph.pub root@nuc73 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/etc/ceph/ceph.pub" The authenticity of host 'nuc73 (192.168.1.26)' can't be established. ECDSA key fingerprint is SHA256:4GMMsd+hO9Zh71ZrI/cHneRFoPO3kBuV/f5K7JeMVhY. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes root@nuc73's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'root@nuc73'" and check to make sure that only the key(s) you wanted were added. ``` Add OSD host to cluster and set label ``` cephadmin@nuc111:~$ sudo ceph orch host add nuc71 Added host 'nuc71' cephadmin@nuc111:~$ sudo ceph orch host add nuc72 Added host 'nuc72' cephadmin@nuc111:~$ sudo ceph orch host add nuc73 Added host 'nuc73' cephadmin@nuc111:~$ sudo ceph orch host ls HOST ADDR LABELS STATUS nuc111 nuc111 _admin mon nuc71 nuc71 nuc72 nuc72 nuc73 nuc73 cephadmin@nuc111:~$ sudo ceph orch host label add nuc71 osd Added label osd to host nuc71 cephadmin@nuc111:~$ sudo ceph orch host label add nuc72 osd Added label osd to host nuc72 cephadmin@nuc111:~$ sudo ceph orch host label add nuc73 osd Added label osd to host nuc73 cephadmin@nuc111:~$ sudo ceph orch host ls HOST ADDR LABELS STATUS nuc111 nuc111 _admin mon nuc71 nuc71 osd nuc72 nuc72 osd nuc73 nuc73 osd ``` **__NOTE__**: you could tell cephadm to deploy daemons base on label. For example, to limit monitors run on host with "mon" label. ``` $ sudo ceph orch apply mon --placement="label:mon" ``` Add storage to cluster ``` cephadmin@nuc111:~$ sudo ceph orch daemon add osd nuc71:/dev/sdb Created osd(s) 0 on host 'nuc71' cephadmin@nuc111:~$ sudo ceph orch daemon add osd nuc72:/dev/sdb Created osd(s) 1 on host 'nuc72' cephadmin@nuc111:~$ sudo ceph orch daemon add osd nuc73:/dev/sdb Created osd(s) 2 on host 'nuc73' ``` Check cluster status ``` cephadmin@nuc111:~$ sudo ceph -s cluster: id: 16e21856-6030-11ed-8a24-db02e0e54b22 health: HEALTH_OK services: mon: 3 daemons, quorum nuc111,nuc71,nuc72 (age 119s) mgr: nuc111.oezajx(active, since 36m), standbys: nuc71.pmlfuu osd: 3 osds: 3 up (since 24s), 3 in (since 24s) data: pools: 1 pools, 1 pgs objects: 0 objects, 0 B usage: 3.0 GiB used, 692 GiB / 695 GiB avail pgs: 1 active+clean ``` Dashboard ![](https://i.imgur.com/WQQ1Gfi.png) #### Purging cluster ``` root@nuc111:~# ceph mgr module disable cephadm root@nuc111:~# ceph fsid 16e21856-6030-11ed-8a24-db02e0e54b22 cephadm rm-cluster --force --zap-osds --fsid 16e21856-6030-11ed-8a24-db02e0e54b22 ``` Ref.: https://docs.ceph.com/en/quincy/cephadm/operations/#purging-a-cluster https://www.flamingbytes.com/posts/uninstall-ceph/ #### Troubleshoot The cephadm deploy **Prometheus, Grafana** and related tools by default. It has the "node-exporter" container on each node. However, the container uses a lot of CPU resources in my environment (OSD node, 2 cores Celeron CPU) and affect command to ssh and df, lsblk, etc... commands are very slow (took couple minutes to connect or response). - https://www.mail-archive.com/prometheus-users@googlegroups.com/msg09479.html - https://github.com/prometheus/node_exporter#disabled-by-default To disable/remove the Prometheus rleated services (TBC) ``` $ ceph mgr module disable prometheus $ ceph orch rm node-exporter ``` With "1 stray daemon not managed by cephadm" warning message, restart ceph manager container. - https://lists.ceph.io/hyperkitty/list/ceph-users@ceph.io/thread/N3MVYV7LBEXCBIANAFZAPQXU45OTIY3P/ - https://tracker.ceph.com/issues/50272 #### Reference - https://kifarunix.com/install-and-setup-ceph-storage-cluster-on-ubuntu/ - https://docs.ceph.com/en/latest/cephadm/install/ - https://docs.ceph.com/en/octopus/cephadm/monitoring/ - https://www.flamingbytes.com/posts/uninstall-ceph/ - https://docs.ceph.com/en/quincy/mgr/prometheus/#enabling-prometheus-output

    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