티스토리 뷰

Cloud

GlusterFS & Heketi on Rhel7 설치 2

naleejang 2021. 1. 13. 14:22

이전 포스팅에서 Glusterfs를 설치하기 위해 vm를 생성하고, vm의 환경설정을 해주었다. 그리고, glusterfs 패키지를 설치하고, 첫번째 glusterfs 서버인 gfs-server1에서 gfs-server2와 gfs-server3을 peer로 등록해 주었다. 이번에는 glusterfs의 API 서버가 될 heketi 서버를 설치하고 glusterfs와 연동 작업해 보도록 하겠다.

4. Heketi API 서버 설치

앞에서 우리는 heketi 서버용 vm를 생성하고 환경설정을 완료하였다. 앞서 설정한 heketi 서버에 접속하여 heketi를 설치해 보자.

4.1 Heketi 패키지 설치

이미 앞에서 서브스크립션을 등록하고 필요한 패키지 레파지토리를 활성화하였다. 이때 활성화한 rh-gluster-3-for-rhel-7-server-rpms 레파지토리에는 glusterfs 관련 패키지 뿐만 아니라 heketi와 관련된 패키지도 포함되어 있다. 따라서, yum install 명령어를 이용해 아래와 같이 heketi 와 heketi-client 를 설치한다.

[root@heketi ~]# yum install heketi heketi-client -y

4.2 Heketi SSH 인증키 생성 및 복사

heketi 패키지가 설치되면 ssh-keygen을 이용하여 heketi 전용 ssh key를 생성하고, 이를 gfs-server1, gfs-server2, gfs-server3으로 ssh-copy-id 명령어를 이용하여 ssh key를 복사한다. 그리고, 사전에 생성한 heketi_key의 소유권을 heketi로 변경한다.

[root@heketi ~]# ssh-keygen -f /etc/heketi/heketi_key -t rsa -N ''
[root@heketi ~]# ssh-copy-id -i /etc/heketi/heketi_key root@gfs-server1
[root@heketi ~]# ssh-copy-id -i /etc/heketi/heketi_key root@gfs-server2
[root@heketi ~]# ssh-copy-id -i /etc/heketi/heketi_key root@gfs-server3
[root@heketi ~]# chown heketi:heketi /etc/heketi/heketi_key*

4.3 Heketi와 GlusterFS 연동을 위한 환경설정 파일 생성

이번에는 heketi 환경설정을 한다. /etc/heketi 디렉터리에 보면 heketi.json 이라는 파일을 확인할 수 있다. heketi.json 파일을 열어 아래와 같이 jwt 섹션의 admin key와 user key를 설정해 준다. 여기서는 기억하기 좋게 keypassword로 설정했다. 실제 운영환경에서는 좀 더 복잡한 패스워드를 사용하는 것이 좋다. 그리고, 하단의 executor를 ssh로 설정하고 sshexec 섹션의 keyfile을 heketi ssh key가 존재하는 경로로 변경한다.

[root@heketi ~]# cat /etc/heketi/heketi.json 
...
  "_jwt": "Private keys for access",
  "jwt": {
    "_admin": "Admin has access to all APIs",
    "admin": {
      "_key_comment": "Set the admin key in the next line",
      "key": "keypassword"
    },
    "_user": "User only has access to /volumes endpoint",
    "user": {
      "_key_comment": "Set the user key in the next line",
      "key": "keypassword"
    }
  },
...
    "executor": "ssh",

    "_sshexec_comment": "SSH username and private key file information",
    "sshexec": {
      "keyfile": "/etc/heketi/heketi_key",
      "user": "root",
      "port": "22",
      "fstab": "/etc/fstab"
    },

이렇게 변경된 heketi.json 파일의 전체 내용은 아래와 같다.

[root@heketi ~]# cat /etc/heketi/heketi.json 
{
  "_port_comment": "Heketi Server Port Number",
  "port": "8080",

  "_enable_tls_comment": "Enable TLS in Heketi Server",
  "enable_tls": false,

  "_cert_file_comment": "Path to a valid certificate file",
  "cert_file": "",

  "_key_file_comment": "Path to a valid private key file",
  "key_file": "",

  "_use_auth": "Enable JWT authorization. Please enable for deployment",
  "use_auth": false,

  "_jwt": "Private keys for access",
  "jwt": {
    "_admin": "Admin has access to all APIs",
    "admin": {
      "_key_comment": "Set the admin key in the next line",
      "key": "keypassword"
    },
    "_user": "User only has access to /volumes endpoint",
    "user": {
      "_key_comment": "Set the user key in the next line",
      "key": "keypassword"
    }
  },

  "_backup_db_to_kube_secret": "Backup the heketi database to a Kubernetes secret when running in Kubernetes. Default is off.",
  "backup_db_to_kube_secret": false,

  "_profiling": "Enable go/pprof profiling on the /debug/pprof endpoints.",
  "profiling": false,

  "_glusterfs_comment": "GlusterFS Configuration",
  "glusterfs": {
    "_executor_comment": [
      "Execute plugin. Possible choices: mock, ssh",
      "mock: This setting is used for testing and development.",
      "      It will not send commands to any node.",
      "ssh:  This setting will notify Heketi to ssh to the nodes.",
      "      It will need the values in sshexec to be configured.",
      "kubernetes: Communicate with GlusterFS containers over",
      "            Kubernetes exec api."
    ],
    "executor": "ssh",

    "_sshexec_comment": "SSH username and private key file information",
    "sshexec": {
      "keyfile": "/etc/heketi/heketi_key",
      "user": "root",
      "port": "22",
      "fstab": "/etc/fstab"
    },

    "_db_comment": "Database file name",
    "db": "/var/lib/heketi/heketi.db",
    "_refresh_time_monitor_gluster_nodes": "Refresh time in seconds to monitor Gluster nodes",
    "refresh_time_monitor_gluster_nodes": 120,

    "_start_time_monitor_gluster_nodes": "Start time in seconds to monitor Gluster nodes when the heketi comes up",
    "start_time_monitor_gluster_nodes": 10,

    "_loglevel_comment": [
      "Set log level. Choices are:",
      "  none, critical, error, warning, info, debug",
      "Default is warning"
    ],
    "loglevel" : "debug",

    "_auto_create_block_hosting_volume": "Creates Block Hosting volumes automatically if not found or exsisting volume exhausted",
    "auto_create_block_hosting_volume": true,

    "_block_hosting_volume_size": "New block hosting volume will be created in size mentioned, This is considered only if auto-create is enabled.",
    "block_hosting_volume_size": 500,

    "_block_hosting_volume_options": "New block hosting volume will be created with the following set of options. Removing the group gluster-block option is NOT recommended. Additional options can be added next to it separated by a comma.",
    "block_hosting_volume_options": "group gluster-block",

    "_pre_request_volume_options": "Volume options that will be applied for all volumes created. Can be overridden by volume options in volume create request.",
    "pre_request_volume_options": "",

    "_post_request_volume_options": "Volume options that will be applied for all volumes created. To be used to override volume options in volume create request.",
    "post_request_volume_options": ""
  }
}
[root@heketi ~]# 

4.4 Heketi 서비스 시작

이제 환경설정을 했으니, heketi 서비스를 활성화하고 heketi 서비스를 시작해보자. 그리고, curl 을 이용하여 rest api를 호출할 수 있는지 확인해 보자. 아래와 같이 http://heketi:8080/hello 를 호출하면, Hello from Heketi 가 응답한다. 여기서 heketi 는 사전에 heketi 서버의 IP와 호스트명을 /etc/hosts에 추가해 주었기 때문에 호스트명으로 테스트가 가능한 것이다.

[root@heketi ~]# systemctl enable heketi
[root@heketi ~]# systemctl start heketi

# curl을 이용하여 web 서비스 확인
[root@heketi ~]# curl http://heketi:8080/hello
Hello from Heketi

4.5 Heketi 서비스 토폴로지 생성 및 로딩

heketi 서비스를 시작했다면 glusterfs를 연동할 볼륨정보를 가지고 있는 토폴로지를 생성한다. /etc/heketi 디렉토리 아래에 topology.json 이라는 파일을 생성하고, 아래 내용을 복사하여 붙여넣은 뒤 해당 glusterfs 서버 정보를 아래와 같이 변경해 준다. 그리고, heketi-cli topology load 명령어를 이용하여 생성한 topology.json 파일을 로딩하여 gluster 서버의 볼륨 정보를 추가한다. 이때 heketi.json의 jwt 섹션에서 설정한 admin 과 admin 패스워드를 사용하여 계정 정보를 함께 넣어주어야 한다.

# gfs-server에 대한 볼륨 정보를 설정하기 위해 토폴리지 생성
[root@heketi ~]# cat /etc/heketi/topology.json 
{
  "clusters": [
    {
      "nodes": [
        {
          "node": {
            "hostnames": {
              "manage": [
                "gfs-server1"
              ],
              "storage": [
                "192.168.0.200"
              ]
            },
            "zone": 1
          },
          "devices": [
            "/dev/vdb",
            "/dev/vdc"
          ]
        },
        {
          "node": {
            "hostnames": {
              "manage": [
                "gfs-server2"
              ],
              "storage": [
                "192.168.0.201"
              ]
            },
            "zone": 1
          },
          "devices": [
            "/dev/vdb",
            "/dev/vdc"
          ]
        },
        {
          "node": {
            "hostnames": {
              "manage": [
                "gfs-server3"
              ],
              "storage": [
                "192.168.0.202"
              ]
            },
            "zone": 1
          },
          "devices": [
            "/dev/vdb",
            "/dev/vdc"
          ]
        }
      ]
    }
  ]
}

# heketi-cli 명령어를 이용하여 topology 추가
[root@heketi ~]# heketi-cli topology load --user admin --secret keypassword --json=topology.json
Creating cluster ... ID: 07b117c8766c7e92fa69f6d8bdc2b594
Allowing file volumes on cluster.
Allowing block volumes on cluster.
Creating node gluster01 ... ID: 2065ccfb-7309-45ee-b554-7085fe56f6af
Adding device /dev/vdb ... OK
Adding device /dev/vdc ... OK
Creating node gluster02 ... ID: 2bc17aea-e256-4ae2-a100-eaba1c7b6efc
Adding device /dev/vdb ... OK
Adding device /dev/vdc ... OK
Creating node gluster03 ... ID: afdfdf44-3999-4f3d-bb4d-6845f56f65a7
Adding device /dev/vdb ... OK
Adding device /dev/vdc ... OK

4.6 Heketi 서비스 테스트

이제 그럼 heketi 를 이용하여 볼륨이 생성되는지 테스트를 해보자. 먼저 heketi 인증정보를 환경변수로 등록한다. 그리고, heketi-cli 명령어를 이용해 클러스터 목록, 노드 목록을 확인하고, 노드 상세정보를 확인할 수 있다. 또한, heketi-cli volume create 명령어를 이용하여 1GB짜라 볼륨도 생성해 보자. 그리고, heketi-cli volume list 명령어로 생성된 볼륨을 확인할 수 있다.

# heketi 인증정보을 환경변수로 등록
[root@heketi ~]# vi .bashrc
export HEKETI_CLI_SERVER=http://heketi:8080
export HEKETI_CLI_USER=admin
export HEKETI_CLI_KEY="keypassword"
[root@heketi ~]# source .bashrc

# heketi-cli 명령어를 통해 클러스터 목록과 노드 목록 확인
[root@heketi ~]# heketi-cli cluster list
Clusters:
Id:07b117c8766c7e92fa69f6d8bdc2b594 [file][block]
[root@heketi ~]# 
[root@heketi ~]# heketi-cli node list
Id:6f82880deb9da92e8a0f15d9b8792222 Cluster:07b117c8766c7e92fa69f6d8bdc2b594
Id:a91826a51c6af6b4690c9b274ec36758 Cluster:07b117c8766c7e92fa69f6d8bdc2b594
Id:c4a803deaf59f8fbcf714452d9eb8f45 Cluster:07b117c8766c7e92fa69f6d8bdc2b594

# heketi-cli node info 명령어를 통해 노드 정보 확인
[root@heketi ~]# heketi-cli node info 6f82880deb9da92e8a0f15d9b8792222
Node Id: 6f82880deb9da92e8a0f15d9b8792222
State: online
Cluster Id: 07b117c8766c7e92fa69f6d8bdc2b594
Zone: 1
Management Hostname: gfs-server1
Storage Hostname: 192.168.0.200
Devices:
Id:7e512134e56ce698bf0e20be626031e5   Name:/dev/vdb            State:online    Size (GiB):9       Used (GiB):2       Free (GiB):7       Bricks:2       
Id:a5ea08039b6003683b9cb24048c25074   Name:/dev/vdc            State:online    Size (GiB):9       Used (GiB):0       Free (GiB):9       Bricks:0       
[root@heketi ~]# 

# heketi-cli volume create 명령어를 이용해 1GB 볼륨 생성 테스트
[root@heketi ~]# heketi-cli volume create --size=1
Name: vol_f0f23878af47091bc6ee9c88be36f6f9
Size: 1
Volume Id: f0f23878af47091bc6ee9c88be36f6f9
Cluster Id: 07b117c8766c7e92fa69f6d8bdc2b594
Mount: 192.168.0.200:vol_f0f23878af47091bc6ee9c88be36f6f9
Mount Options: backup-volfile-servers=192.168.0.202,192.168.0.201
Block: false
Free Size: 0
Reserved Size: 0
Block Hosting Restriction: (none)
Block Volumes: []
Durability Type: replicate
Distribute Count: 1
Replica Count: 3
[root@heketi ~]# 

# 생성된 볼륨 목록 확인
[root@heketi ~]# heketi-cli volume list
Id:f0f23878af47091bc6ee9c88be36f6f9    Cluster:07b117c8766c7e92fa69f6d8bdc2b594    Name:vol_f0f23878af47091bc6ee9c88be36f6f9
[root@heketi ~]# 

이렇게 해서 이번 포스팅에서는 heketi 서버를 설치하고 glusterfs 와 연동하여 glusterfs에 볼륨을 생성해 보았다. 다음 포스팅에서는 heketi 서버에 kubernetes와 연동하여 pod에 볼륨을 붙여보도록 하겠다.

'Cloud' 카테고리의 다른 글

Hypervisor KVM 모니터링하기 1  (2) 2021.03.06
GlusterFS & Heketi on Rhel7 설치 3  (0) 2021.01.13
GlusterFS & Heketi on Rhel7 설치 1  (0) 2021.01.13
Kubernetes Cluster on Rhel7 설치 2  (1) 2020.12.31
Kubernetes Cluster on Rhel7 설치 1  (0) 2020.12.31
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함