Altinity / clickhouse-operator

Altinity Kubernetes Operator for ClickHouse creates, configures and manages ClickHouse® clusters running on Kubernetes
https://altinity.com
Apache License 2.0
1.94k stars 466 forks source link

Why do I not see the cluster configuration information when I enter the pod to view the configuration file after installing the clickhouse cluster using the operator? #1569

Closed liaocanjie closed 4 days ago

liaocanjie commented 4 days ago

I went into the pod to check the relevant configuration, and it felt like a default configuration cat config.xml|grep remote_server

<remote_servers>
        <default>
            <shard>
                <replica>
                    <host>localhost</host>
                    <port>9000</port>
                </replica>
            </shard>
        </default>
    </remote_servers>

I can create a distributed table, but I get an error when I use it.

SELECT * FROM test.distributed_table
0 rows in set. Elapsed: 0.028 sec. 

Received exception from server (version 23.8.16):
Code: 516. DB::Exception: Received from localhost:9000. 
DB::Exception: Received from chi-clickhouse-cluster-clickhouse-clt-0-0:9000. 
DB::Exception: default: Authentication failed: 
password is incorrect, or there is no user with such name.

If you have installed ClickHouse and forgot password you can reset 
it in the configuration file.
The password for default user is typically 
located at /etc/clickhouse-server/users.d/default-password.xml
and deleting this file will reset the password.
See also /etc/clickhouse-server/users.xml on the server where ClickHouse is installed.

. (AUTHENTICATION_FAILED)
liaocanjie commented 4 days ago

My yaml file content is as follows:

apiVersion: "clickhouse.altinity.com/v1"
kind: "ClickHouseInstallation"
metadata:
  name: "clickhouse-cluster"
spec:
  defaults:
    templates:
      podTemplate: pod-template
      serviceTemplate: svc-template
      dataVolumeClaimTemplate: clickhouse-data-pvc
      logVolumeClaimTemplate: clickhouse-logs-pvc
  configuration:
    zookeeper:
      nodes:
        - host: zookeeper.zkns
    users:
      default/password: qwerty
      default/networks/ip:
        - 0.0.0.0/0
        - '::/0'
      testuser/password: qwerty
      testuser/networks/ip:
        - 0.0.0.0/0
        - '::/0'
    clusters:
      - name: "clickhouse-clt"
        layout:
          shardsCount: 2
          replicasCount: 1
  templates:
    podTemplates:
      - name: pod-template
        spec:
          containers:
            - name: clickhouse
              image: clickhouse/clickhouse-server:23.8
              # Container has explicitly specified resource requests
              resources:
                requests:
                  cpu: "500m"
                  memory: "1Gi"
                limits:
                  cpu: "500m"
                  memory: "1Gi"
              # Container has explicitly specified ports
              ports:
                - name: http
                  containerPort: 8123
                - name: tcp
                  containerPort: 9000
              volumeMounts:
                - name: clickhouse-data-pvc
                  mountPath: /var/lib/clickhouse
                - name: clickhouse-logs-pvc
                  mountPath: /var/log/clickhouse-server
    volumeClaimTemplates:
      - name: clickhouse-data-pvc
        spec:
          storageClassName: longhorn
          accessModes:
            - ReadWriteOnce
          resources:
            requests:
              storage: 30Gi
      - name: clickhouse-logs-pvc
        spec:
          storageClassName: longhorn
          accessModes:
            - ReadWriteOnce
          resources:
            requests:
              storage: 10Gi
    serviceTemplates:
      - name: svc-template
        metadata:
          annotations:
            metallb.universe.tf/allow-shared-ip: key-to-share-172.16.36.61
        spec:
          type: LoadBalancer
          ports:
            - name: http
              port: 8123
              targetPort: 8123
            - name: tcp
              port: 9000
              targetPort: 9000
Slach commented 4 days ago

cat config.xml|grep remote_server

Look to /etc/clickhouse-server/config.d/chop-generated-remote_servers.xml and SELECT * FROM system.clusters

users: default/password: qwerty

if you use engine=Distributed('default',db.table) during table creation, then authorization failed expected behavior

you changed password for default user but no defined

<remote_servers>
  <default>
     <secret/>
  </default>
</remote_servers>

look to

better use CREATE TABLE ... ENGINE=Distributed('{cluster}',db.table) {cluster} defined properly with secret inside /etc/clickhouse-server/config.d/chop-generated-remote_servers.xml