Skip to content

Instantly share code, notes, and snippets.

@vanduc95
Last active October 15, 2020 11:45
Show Gist options
  • Save vanduc95/a17f80d0636badd9aa002f2b493b777b to your computer and use it in GitHub Desktop.
Save vanduc95/a17f80d0636badd9aa002f2b493b777b to your computer and use it in GitHub Desktop.

Revisions

  1. vanduc95 revised this gist Oct 9, 2017. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions install Ceph Luminous on Ubuntu 16.04.md
    Original file line number Diff line number Diff line change
    @@ -299,7 +299,12 @@
    5 hdd 0.01459 osd.5 up 1.00000 1.00000
    ```

    # Tham khảo
    [1] https://github.com/infn-bari-school/cloud-storage-tutorials/wiki/Ceph-cluster-installation-(jewel-on-Ubuntu-xenial)

    [2] http://docs.ceph.com/docs/master/start/quick-start-preflight/

    [3] https://linoxide.com/ubuntu-how-to/create-ceph-cluster-ubuntu-16-04/

  2. vanduc95 renamed this gist Oct 9, 2017. 1 changed file with 0 additions and 0 deletions.
  3. vanduc95 revised this gist Oct 9, 2017. 1 changed file with 13 additions and 37 deletions.
    50 changes: 13 additions & 37 deletions install Ceph Luminous.md
    Original file line number Diff line number Diff line change
    @@ -243,7 +243,19 @@
    ceph-deploy osd create ceph1:vdc ceph2:vdc ceph3:vdc
    ```

    ## 4. Kiểm tra
    ## 4. Enable Dashboard
    - Trong phiên bản Luminous, có tích hợp thêm `dashboard plugin` cung cấp giao diện đồ họa hiển thị tổng quan status của các thành phần trong Ceph cluster. `dashboard plugin` được quản lí bới **ceph-mgr**.

    - Để enable dashboard, sử dụng câu lệnh sau:
    ```
    ceph mgr module enable dashboard
    ```

    - Truy cập http://192.168.20.91:7000 để sử dụng dashboard.

    ![enter image description here](https://i.imgur.com/e9jI6tN.png)

    ## 5. Kiểm tra
    - Kiểm tra trạng thái Ceph cluster
    ```
    ceph -s
    @@ -293,39 +305,3 @@


    ## 4. Kiểm tra
    - Kiểm tra trạng thái Ceph Cluster

    - Kết quả:

    ```sh
    cluster 31154d30-b0d3-4411-9178-0bbe367a5578
    health HEALTH_OK
    monmap e2: 3 mons at {ceph1=10.10.20.77:6789/0,ceph2=10.10.20.78:6789/0,ceph3=10.10.20.79:6789/0}
    election epoch 6, quorum 0,1,2 ceph1,ceph2,ceph3
    osdmap e14: 6 osds: 6 up, 6 in
    flags sortbitwise,require_jewel_osds
    pgmap v57: 0 pgs, 0 pools, 0 bytes data, 0 objects
    196 MB used, 179 GB / 179 GB avail

    ```

    - Kiểm tra trạng thái các OSD

    ```sh
    ceph osd tree
    ```

    Kết quả:

    ```sh
    ID WEIGHT TYPE NAME UP/DOWN REWEIGHT PRIMARY-AFFINITY
    -1 0 root default
    0 0 osd.0 up 1.00000 1.00000
    1 0 osd.1 up 1.00000 1.00000
    2 0 osd.2 up 1.00000 1.00000
    3 0 osd.3 up 1.00000 1.00000
    4 0 osd.4 up 1.00000 1.00000
    5 0 osd.5 up 1.00000 1.00000
    ```

  4. vanduc95 revised this gist Oct 7, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install Ceph Luminous.md
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@
    <a name="1.2"> </a>
    ### 1.2 Các tham số phần cứng đối với các node

    ![Ceph hardware](https://i.imgur.com/GZpMHVt.png)
    ![Ceph hardware](https://i.imgur.com/hTiY18E.png)

    ### Chú ý khi lựa chọn OS và lựa chọn dải mạng

  5. vanduc95 revised this gist Oct 7, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install Ceph Luminous.md
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@
    <a name="1.2"> </a>
    ### 1.2 Các tham số phần cứng đối với các node

    ![Ceph hardware](../images/ceph_jewel_manual/Cauhinh_phancung.jpg)
    ![Ceph hardware](https://i.imgur.com/GZpMHVt.png)

    ### Chú ý khi lựa chọn OS và lựa chọn dải mạng

  6. vanduc95 revised this gist Oct 7, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install Ceph Luminous.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@
    ### 1.1 Mô hình mạng
    - Mô hình đầy đủ

    ![Ceph Jewel Topo](../images/ceph_jewel_manual/Jewel_topo.jpg)
    ![Ceph Jewel Topo](https://i.imgur.com/JkbcA9y.png)

    <a name="1.2"> </a>
    ### 1.2 Các tham số phần cứng đối với các node
  7. vanduc95 revised this gist Oct 7, 2017. 1 changed file with 17 additions and 16 deletions.
    33 changes: 17 additions & 16 deletions install Ceph Luminous.md
    Original file line number Diff line number Diff line change
    @@ -130,24 +130,25 @@
    root@ceph1:~# chronyc sources
    ```

    - Kết quả như sau

    ```sh
    210 Number of sources = 3
    MS Name/IP address Stratum Poll Reach LastRx Last sample
    ===============================================================================
    ^+ 220.231.122.105 3 6 17 16 +12ms[+4642us] +/- 139ms
    ^** 103.245.79.2 2 6 17 17 -10ms[ -12ms] +/- 176ms
    ^? routerida1.soprano-asm.ne 0 6 0 10y +0ns[ +0ns] +/- 0ns
    ```
    - Kết quả như sau
    ```
    210 Number of sources = 3
    MS Name/IP address Stratum Poll Reach LastRx Last sample
    ===============================================================================
    ^+ 220.231.122.105 3 6 17 16 +12ms[+4642us] +/- 139ms
    ^** 103.245.79.2 2 6 17 17 -10ms[ -12ms] +/- 176ms
    ^? routerida1.soprano-asm.ne 0 6 0 10y +0ns[ +0ns] +/- 0ns
    ```

    ### 2.3. Tạo user `cephuser`
    ```
    useradd -d /home/cephuser -m cephuser
    passwd cephuser
    - Tạo user và gán quyền
    ```
    useradd -d /home/cephuser -m cephuser
    passwd cephuser

    echo "cephuser ALL = (root) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/cephuser
    chmod 0440 /etc/sudoers.d/cephuser
    ```
    echo "cephuser ALL = (root) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/cephuser
    chmod 0440 /etc/sudoers.d/cephuser
    ```

    ## 3. Thực hiện cài đặt trên node `ceph1`

  8. vanduc95 revised this gist Oct 7, 2017. 2 changed files with 330 additions and 15 deletions.
    15 changes: 0 additions & 15 deletions f.md
    Original file line number Diff line number Diff line change
    @@ -1,15 +0,0 @@
    ## 3. Thực hiện cài đặt trên node `ceph1`

    - Khai báo repo

    ```
    wget -q -O- 'https://download.ceph.com/keys/release.asc' | sudo apt-key add -
    echo deb https://download.ceph.com/debian-luminous/ $(lsb_release -sc) main | sudo tee /etc/apt/sources.list.d/ceph.list
    ```

    - Update và cài đặt pakage `ceph-deploy`
    ```
    apt-get -y update
    apt-get install ceph-deploy
    ```

    330 changes: 330 additions & 0 deletions install Ceph Luminous.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,330 @@
    # Hướng dẫn cài đặt Ceph Luminous
    ******

    <a name="I."> </a>
    # I. Cài đặt cơ bản
    ******
    <a name="1"> </a>
    ## 1. Chuẩn bị môi trường
    <a name="1.1"> </a>
    ### 1.1 Mô hình mạng
    - Mô hình đầy đủ

    ![Ceph Jewel Topo](../images/ceph_jewel_manual/Jewel_topo.jpg)

    <a name="1.2"> </a>
    ### 1.2 Các tham số phần cứng đối với các node

    ![Ceph hardware](../images/ceph_jewel_manual/Cauhinh_phancung.jpg)

    ### Chú ý khi lựa chọn OS và lựa chọn dải mạng

    ```
    - OS: Ubuntu Server 16.04 64 bit, kernel 4.4.0-62-generic
    - Các dải mạng:
    - Management Network: sử dụng để quản lý (ssh) các máy chủ và để các máy chủ tải các gói cài đặt từ Internet.
    - Data Network: sử dụng để các máy client có thể truy cập và sử dụng tài nguyên lưu trữ trên Ceph.
    - Replication Network: Sử dụng để nhân bản dữ liệu giữa các node Ceph.
    - Ổ cứng:
    - Label của các ổ cứng trong hướng dẫn này là vda, vdb, vdc.
    ```

    <a name="2"> </a>
    ## 2. Cài đặt các thành phần chung trên tất cả các node
    ===
    - Lưu ý:
    - Đăng nhập với quyền root trên tất cả các bước cài đặt.
    - Các thao tác sửa file trong hướng dẫn này sử dụng lệnh `nano`
    - Thực hiện trên tất cả các node trong cluster

    ### 2.1. Thiết lập và cài đặt các gói cơ bản
    **Hướng dẫn dưới đây cài trên node `ceph1`, node `ceph2`, `ceph3` cài tương tự**

    - Chạy lệnh để cập nhật các gói phần mềm và cài gói phần mêm phụ thuộc

    ```sh
    apt-get update && apt-get -y upgrade
    apt-get install python-minimal
    ```

    - Thiết lập địa chỉ IP cho từng node
    - Dùng lệnh `nano` để sửa file `/etc/network/interfaces` với nội dung như sau.

    ```sh
    # Interface MGNT
    auto eth0
    iface eth0 inet static
    address 192.168.20.91
    gateway 192.168.20.254
    netmask 255.255.255.0
    dns-nameservers 8.8.8.8

    # Interface PUB
    auto eth1
    iface eth1 inet static
    address 10.10.10.91
    netmask 255.255.255.0

    # Interface REP
    auto eth2
    iface eth2 inet static
    address 10.10.20.91
    netmask 255.255.255.0
    ```

    - Khởi động lại card mạng sau khi thiết lập IP tĩnh

    ```sh
    ifdown -a && ifup -a
    ```

    - Cấu hình hostname
    - Dùng `nano` sửa file `/etc/hostname` với tên là `ceph1`

    ```sh
    ceph1
    ```

    - Cập nhật file `/etc/hosts` để phân giải từ IP sang hostname và ngược lại, nội dung như sau

    ```sh
    127.0.0.1 localhost
    127.0.1.1 ceph1

    10.10.10.91 ceph1
    10.10.10.92 ceph2
    10.10.10.93 ceph3
    ```

    ### 2.2. Cài đặt NTP
    - Cài gói `chrony`

    ```sh
    apt-get -y install chrony
    ```

    - Mở file `/etc/chrony/chrony.conf` và tìm các dòng dưới

    ```sh
    pool 2.debian.pool.ntp.org offline iburst

    ```

    - Thay bằng các dòng sau

    ```sh
    server 1.vn.pool.ntp.org iburst
    server 0.asia.pool.ntp.org iburst
    server 3.asia.pool.ntp.org iburst
    ```

    - Khởi động lại dịch vụ NTP

    ```sh
    service chrony restart
    ```

    - Kiểm tra lại hoạt động của NTP bằng lệnh dưới

    ```sh
    root@ceph1:~# chronyc sources
    ```

    - Kết quả như sau

    ```sh
    210 Number of sources = 3
    MS Name/IP address Stratum Poll Reach LastRx Last sample
    ===============================================================================
    ^+ 220.231.122.105 3 6 17 16 +12ms[+4642us] +/- 139ms
    ^** 103.245.79.2 2 6 17 17 -10ms[ -12ms] +/- 176ms
    ^? routerida1.soprano-asm.ne 0 6 0 10y +0ns[ +0ns] +/- 0ns
    ```
    ### 2.3. Tạo user `cephuser`
    ```
    useradd -d /home/cephuser -m cephuser
    passwd cephuser
    echo "cephuser ALL = (root) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/cephuser
    chmod 0440 /etc/sudoers.d/cephuser
    ```

    ## 3. Thực hiện cài đặt trên node `ceph1`

    - Khai báo repo
    ```
    wget -q -O- 'https://download.ceph.com/keys/release.asc' | sudo apt-key add -
    echo deb https://download.ceph.com/debian-luminous/ $(lsb_release -sc) main | sudo tee /etc/apt/sources.list.d/ceph.list
    ```

    - Update và cài đặt pakage `ceph-deploy`
    ```
    apt-get -y update
    apt-get install ceph-deploy
    ```

    - Chuyển tới user `cephuser` và tạo key
    ```
    su - cephuser

    ssh-keygen -t rs
    ```

    - Kết qủa
    ```
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa):
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /home/ubuntu/.ssh/id_rsa.
    Your public key has been saved in /home/ubuntu/.ssh/id_rsa.pub.
    The key fingerprint is:
    SHA256:S4UVTlj5Y2g88FHfFnzwZ46wzOFseMkZljDidkr5n+c ubuntu@ubuntu-KVM
    The key's randomart image is:
    +---[RSA 2048]----+
    | .oB+. oo |
    | .oBoo o +o|
    | *+++* . B|
    | o =*O+B =.|
    | S.oo%.. .|
    | . . + . |
    | . o . |
    | o |
    | E |
    +----[SHA256]-----+
    ```

    - Copy ssh key tới tất cả các node
    ```
    ssh-copy-id cephuser@ceph1
    ssh-copy-id cephuser@ceph2
    ssh-copy-id cephuser@ceph3
    ```

    - Tạo thư mục chứa các file cấu hình và quản lí của Ceph cluster. Sau đó cài đặt MON trên cả 3 node ceph
    ```
    mkdir cluster
    cd cluster
    ceph-deploy new ceph1 ceph2 ceph3
    ```

    - Thêm các dòng sau vào file `ceph.conf` vừa tạo:
    ```
    osd pool default size = 2
    public network = 10.10.10.0/24
    cluster network = 10.10.20.0/24
    ```

    - Cài đặt Ceph. Các pakage và file cấu hình sẽ được cài đặt trên tất cả các node
    ```
    ceph-deploy install --release luminous ceph1 ceph2 ceph3
    ```

    - Cài đặt và cấu hình Ceph monitor trên các node
    ```
    ceph-deploy mon create-initial
    ```

    - Copy key tới các node Ceph và phân quyền
    ```
    ceph-deploy admin ceph1 ceph2 ceph3
    sudo chmod +r /etc/ceph/ceph.client.admin.keyring
    ```

    - Deploy a manager daemon
    ```
    ceph-deploy mgr create ceph1 ceph2 ceph3
    ```

    - Thiết lập các OSD. Trong mô hình của chúng ta, mỗi node gồm 3 partion vda vdb và vdc. Chúng ta sẽ sử dụng vdb và vdc làm các OSD.
    ```
    ceph-deploy osd create ceph1:vdb ceph2:vdb ceph3:vdb
    ceph-deploy osd create ceph1:vdc ceph2:vdc ceph3:vdc
    ```

    ## 4. Kiểm tra
    - Kiểm tra trạng thái Ceph cluster
    ```
    ceph -s
    ```

    - Kết quả:
    ```
    cluster:
    id: ddb94b0b-f4f2-4792-a0c5-adc0e84eaca2
    health: HEALTH_OK
    services:
    mon: 3 daemons, quorum ceph1,ceph2,ceph3
    mgr: ceph1(active), standbys: ceph2, ceph3
    osd: 6 osds: 6 up, 6 in
    data:
    pools: 0 pools, 0 pgs
    objects: 0 objects, 0 bytes
    usage: 6337 MB used, 85216 MB / 91553 MB avail
    pgs:
    ```

    - Kiểm tra trạng thái OSD
    ```
    ceph osd tree
    ```
    - Kết qủa:
    ```
    ID CLASS WEIGHT TYPE NAME STATUS REWEIGHT PRI-AFF
    -1 0.08752 root default
    -3 0.02917 host ceph1
    0 hdd 0.01459 osd.0 up 1.00000 1.00000
    3 hdd 0.01459 osd.3 up 1.00000 1.00000
    -5 0.02917 host ceph2
    1 hdd 0.01459 osd.1 up 1.00000 1.00000
    4 hdd 0.01459 osd.4 up 1.00000 1.00000
    -7 0.02917 host ceph3
    2 hdd 0.01459 osd.2 up 1.00000 1.00000
    5 hdd 0.01459 osd.5 up 1.00000 1.00000
    ```





    ## 4. Kiểm tra
    - Kiểm tra trạng thái Ceph Cluster

    - Kết quả:

    ```sh
    cluster 31154d30-b0d3-4411-9178-0bbe367a5578
    health HEALTH_OK
    monmap e2: 3 mons at {ceph1=10.10.20.77:6789/0,ceph2=10.10.20.78:6789/0,ceph3=10.10.20.79:6789/0}
    election epoch 6, quorum 0,1,2 ceph1,ceph2,ceph3
    osdmap e14: 6 osds: 6 up, 6 in
    flags sortbitwise,require_jewel_osds
    pgmap v57: 0 pgs, 0 pools, 0 bytes data, 0 objects
    196 MB used, 179 GB / 179 GB avail

    ```

    - Kiểm tra trạng thái các OSD

    ```sh
    ceph osd tree
    ```

    Kết quả:

    ```sh
    ID WEIGHT TYPE NAME UP/DOWN REWEIGHT PRIMARY-AFFINITY
    -1 0 root default
    0 0 osd.0 up 1.00000 1.00000
    1 0 osd.1 up 1.00000 1.00000
    2 0 osd.2 up 1.00000 1.00000
    3 0 osd.3 up 1.00000 1.00000
    4 0 osd.4 up 1.00000 1.00000
    5 0 osd.5 up 1.00000 1.00000
    ```

  9. vanduc95 created this gist Oct 7, 2017.
    15 changes: 15 additions & 0 deletions f.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    ## 3. Thực hiện cài đặt trên node `ceph1`

    - Khai báo repo

    ```
    wget -q -O- 'https://download.ceph.com/keys/release.asc' | sudo apt-key add -
    echo deb https://download.ceph.com/debian-luminous/ $(lsb_release -sc) main | sudo tee /etc/apt/sources.list.d/ceph.list
    ```

    - Update và cài đặt pakage `ceph-deploy`
    ```
    apt-get -y update
    apt-get install ceph-deploy
    ```