> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> ClickHouse gRPC 인터페이스에 대한 문서

# gRPC 인터페이스

<div id="grpc-interface-introduction">
  ## 소개
</div>

ClickHouse는 [gRPC](https://grpc.io/) 인터페이스를 지원합니다. 이는 HTTP/2와 [Protocol Buffers](https://en.wikipedia.org/wiki/Protocol_Buffers)를 사용하는 오픈 소스 원격 프로시저 호출 시스템입니다. ClickHouse의 gRPC 구현은 다음을 지원합니다.

* SSL;
* 인증;
* 세션;
* 압축;
* 동일한 채널을 통한 병렬 쿼리;
* 쿼리 취소;
* 진행 상황 및 로그 확인;
* 외부 테이블.

이 인터페이스 사양은 [clickhouse\_grpc.proto](https://github.com/ClickHouse/ClickHouse/blob/master/src/Server/grpc_protos/clickhouse_grpc.proto)에 설명되어 있습니다.

<div id="grpc-interface-configuration">
  ## gRPC 구성
</div>

gRPC 인터페이스를 사용하려면 기본 [서버 구성](/ko/concepts/features/configuration/server-config/configuration-files)에서 `grpc_port`를 설정하십시오. 다른 구성 옵션은 아래 예시를 참조하십시오.

```xml theme={null}
<grpc_port>9100</grpc_port>
    <grpc>
        <enable_ssl>false</enable_ssl>

        <!-- 다음 두 파일은 SSL이 활성화된 경우에만 사용됩니다 -->
        <ssl_cert_file>/path/to/ssl_cert_file</ssl_cert_file>
        <ssl_key_file>/path/to/ssl_key_file</ssl_key_file>

        <!-- 서버가 클라이언트에 인증서를 요청하는지 여부 -->
        <ssl_require_client_auth>false</ssl_require_client_auth>

        <!-- 다음 파일은 ssl_require_client_auth=true인 경우에만 사용됩니다 -->
        <ssl_ca_cert_file>/path/to/ssl_ca_cert_file</ssl_ca_cert_file>

        <!-- 기본 압축 알고리즘 (클라이언트가 별도의 알고리즘을 지정하지 않은 경우 적용됩니다. QueryInfo의 result_compression 참조).
             지원 알고리즘: none, deflate, gzip, stream_gzip -->
        <compression>deflate</compression>

        <!-- 기본 압축 수준 (클라이언트가 별도의 수준을 지정하지 않은 경우 적용됩니다. QueryInfo의 result_compression 참조).
             지원 수준: none, low, medium, high -->
        <compression_level>medium</compression_level>

        <!-- 송수신 메시지 크기 제한(바이트 단위). -1은 무제한을 의미합니다 -->
        <max_send_message_size>-1</max_send_message_size>
        <max_receive_message_size>-1</max_receive_message_size>

        <!-- 상세 로그를 확인하려면 활성화하십시오 -->
        <verbose_logs>false</verbose_logs>
    </grpc>
```

<div id="grpc-client">
  ## 내장 클라이언트
</div>

제공된 [사양](https://github.com/ClickHouse/ClickHouse/blob/master/src/Server/grpc_protos/clickhouse_grpc.proto)을 사용하여 gRPC가 지원하는 모든 프로그래밍 언어로 클라이언트를 작성할 수 있습니다.
또는 내장 Python 클라이언트를 사용할 수 있습니다. 이 클라이언트는 리포지토리의 [utils/grpc-client/clickhouse-grpc-client.py](https://github.com/ClickHouse/ClickHouse/blob/master/utils/grpc-client/clickhouse-grpc-client.py)에 있습니다. 내장 클라이언트를 사용하려면 Python 모듈 [grpcio and grpcio-tools](https://grpc.io/docs/languages/python/quickstart)가 필요합니다.

클라이언트는 다음 인수를 지원합니다.

* `--help` – 도움말 메시지를 표시한 후 종료합니다.
* `--host HOST, -h HOST` – 서버 이름입니다. 기본값은 `localhost`입니다. IPv4 또는 IPv6 주소도 사용할 수 있습니다.
* `--port PORT` – 연결할 포트입니다. 이 포트는 ClickHouse 서버 구성에서 활성화되어 있어야 합니다(`grpc_port` 참조). 기본값은 `9100`입니다.
* `--user USER_NAME, -u USER_NAME` – 사용자 이름입니다. 기본값은 `default`입니다.
* `--password PASSWORD` – 비밀번호입니다. 기본값은 빈 문자열입니다.
* `--query QUERY, -q QUERY` – 비대화형 모드에서 처리할 쿼리입니다.
* `--database DATABASE, -d DATABASE` – 기본 데이터베이스입니다. 지정하지 않으면 서버 설정에 지정된 현재 데이터베이스가 사용됩니다(기본값은 `default`).
* `--format OUTPUT_FORMAT, -f OUTPUT_FORMAT` – 결과 출력 [포맷](/ko/reference/formats)입니다. 대화형 모드의 기본값은 `PrettyCompact`입니다.
* `--debug` – 디버그 정보 표시를 활성화합니다.

대화형 모드로 클라이언트를 실행하려면 `--query` 인수 없이 호출하십시오.

일괄 모드에서는 `stdin`을 통해 쿼리 데이터를 전달할 수 있습니다.

**클라이언트 사용 예시**

다음 예시에서는 테이블을 생성하고 CSV 파일의 데이터를 로드합니다. 그런 다음 테이블의 내용을 쿼리합니다.

```bash title="Query" theme={null}
./clickhouse-grpc-client.py -q "CREATE TABLE grpc_example_table (id UInt32, text String) ENGINE = MergeTree() ORDER BY id;"
echo -e "0,Input data for\n1,gRPC protocol example" > a.csv
cat a.csv | ./clickhouse-grpc-client.py -q "INSERT INTO grpc_example_table FORMAT CSV"

./clickhouse-grpc-client.py --format PrettyCompact -q "SELECT * FROM grpc_example_table;"
```

```text title="Response" theme={null}
┌─id─┬─text──────────────────┐
│  0 │ Input data for        │
│  1 │ gRPC protocol example │
└────┴───────────────────────┘
```
