Pulsar Shell
Pulsar Shell
Pulsar shell은 Pulsar 클러스터 관리, 메시징 등을 위한 빠르고 유연한 셸이에요. 다른 클러스터 간에 빠르게 전환하는 데 좋고, 클러스터나 테넌트 구성을 즉시 수정할 수 있어요.
출처: 문서
본문
Pulsar shell은 Pulsar 클러스터 관리, 메시징 등을 위한 빠르고 유연한 셸이에요. 다른 클러스터 간에 빠르게 전환하는 데 좋고, 클러스터나 테넌트 구성을 즉시 수정할 수 있어요.
사용 사례 (Use case)
- 관리(Administration): admin 명령 아래에서 모든 Admin API 기능을 찾을 수 있어요.
- 클라이언트(Client): client 명령 아래에서 모든 pulsar-client 기능을 찾을 수 있어요.
Pulsar Shell 설치 (Install Pulsar Shell)
다운로드 페이지에서 tarball을 다운로드하고 추출해요.
curl -LO "https://www.apache.org/dyn/closer.lua/pulsar/pulsar-5.0.0-M2/apache-pulsar-shell-5.0.0-M2-bin.tar.gz?action=download"
tar xzvf apache-pulsar-shell-5.0.0-M2-bin.tar.gz
cd apache-pulsar-shell-5.0.0-M2/
이제 Pulsar shell의 대화형 모드로 들어갈 수 있어요.
./bin/pulsar-shell
Welcome to Pulsar shell!
Service URL: pulsar://localhost:6650/
Admin URL: http://localhost:8080/
Type help to get started or try the autocompletion (TAB button).
Type exit or quit to end the shell session.
default(localhost)>
클러스터에 연결 (Connect to your cluster)
기본적으로 셸은 로컬 Pulsar 인스턴스에 연결하려 해요. 다른 클러스터에 연결하려면 그 클러스터를 Pulsar shell에 등록해야 해요. 구성 파일이 어디에 있는지에 따라 여러 방법으로 할 수 있어요.
note
구성 파일은 유효한
client.conf파일이어야 해요. pulsar-admin, pulsar-client 및 기타 클라이언트 도구에 사용하는 것과 같은 파일이에요.
- Remote URL
- File
- Inline
--url 값은 유효한 원격 파일을 가리켜야 해요.
default(localhost)> config create --url https://<url_to_my_client.conf> mycluster
파일이 로컬 머신에 있으면 --file 옵션을 사용해요.
default(localhost)> config create --file ./my-cluster-my-client.conf mycluster
구성의 내용을 base64로 인코딩하고 --value 옵션으로 지정할 수 있어요.
default(localhost)> config create --value "base64:<client.conf_base64_encoded>" mycluster
클러스터를 구성했으면 현재 클러스터로 설정해요.
default(localhost)> config use mycluster
Welcome to Pulsar shell!
Service URL: pulsar+ssl://mycluster:6651/
Admin URL: https://mycluster:8443/
Type help to get started or try the autocompletion (TAB button).
Type exit or quit to end the shell session.
my-cluster(mycluster)>
명령을 순차적으로 실행 (Run commands sequentially)
여러 관리 명령을 순차적으로 실행하려면 Pulsar shell의 비대화형 모드를 사용할 수 있어요. 예를 들어 정책이 있는 새 테넌트를 설정하려면 보통 여러 pulsar-admin 명령을 실행해야 해요.
new-tenant 테넌트를 그 안에 new-namespace 네임스페이스와 함께 만들고 싶다고 가정해요. Pulsar shell 비대화형 모드로 여러 방법이 있어요.
- Single command
- File
- Unix pipe
-e 옵션으로 여러 줄 명령을 지정해요.
./bin/pulsar-shell -e "
config use my-cluster
admin tenants create new-tenant
admin namespaces create new-tenant/new-namespace
" --fail-on-error
-f 옵션으로 파일 명령을 지정해요.
echo "
# First use my-cluster config
config use my-cluster
# Now it creates a new tenant
admin tenants create new-tenant
# And then it creates a new namespace inside the tenant
admin namespaces create new-tenant/new-namespace
" > setup-shell.txt
./bin/pulsar-shell -f ./setup-shell.txt --fail-on-error
셸이 표준 입력에서 읽게 하려면 - 옵션을 사용해요.
echo "
# First use my-cluster config
config use my-cluster
# Now it creates a new tenant
admin tenants create new-tenant
# And then it creates a new namespace inside the tenant
admin namespaces create new-tenant/new-namespace
" > ./bin/pulsar-shell --fail-on-error -
더 알아보기 (Learn more)
- Pulsar Shell의 더 자세한 사용법은 Pulsar shell 문서를 참고해요.
- 관리 명령은 pulsar-admin 문서를 참고해요.
- 클라이언트 기능은 pulsar-client 문서를 참고해요.