Янусграф в Куберне не может подключиться к Кассандре, работающей как другой сервис - PullRequest
1 голос
/ 29 марта 2019

Я пытаюсь запустить Janusgraph с хранилищем в качестве Cassandra, запущенного в качестве другой службы в том же кластере и Elasticsearch для индексации, снова запущенного в качестве другой службы в том же кластере.

Несмотря на то, что необходимые порты открыты в обеих службах, в журналах janusgraph указано время ожидания соединения при подключении к Cassandra.

23343 [main] WARN  org.apache.tinkerpop.gremlin.server.GremlinServer  - Graph [graph] configured at [conf/gremlin-server/janusgraph.properties] could not be instantiated and will not be available in Gremlin Server.  GraphFactory message: GraphFactory could not instantiate this Graph implementation [class org.janusgraph.core.JanusGraphFactory]
java.lang.RuntimeException: GraphFactory could not instantiate this Graph implementation [class org.janusgraph.core.JanusGraphFactory]
    at org.apache.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:82)
    at org.apache.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:70)
    at org.apache.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:104)
    at org.apache.tinkerpop.gremlin.server.util.DefaultGraphManager.lambda$new$0(DefaultGraphManager.java:57)
    at java.util.LinkedHashMap$LinkedEntrySet.forEach(LinkedHashMap.java:671)
    at org.apache.tinkerpop.gremlin.server.util.DefaultGraphManager.<init>(DefaultGraphManager.java:55)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor.<init>(ServerGremlinExecutor.java:110)
    at org.apache.tinkerpop.gremlin.server.util.ServerGremlinExecutor.<init>(ServerGremlinExecutor.java:89)
    at org.apache.tinkerpop.gremlin.server.GremlinServer.<init>(GremlinServer.java:110)
    at org.apache.tinkerpop.gremlin.server.GremlinServer.main(GremlinServer.java:354)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.tinkerpop.gremlin.structure.util.GraphFactory.open(GraphFactory.java:78)
    ... 13 more
Caused by: java.lang.IllegalArgumentException: Could not instantiate implementation: org.janusgraph.diskstorage.cassandra.astyanax.AstyanaxStoreManager
    at org.janusgraph.util.system.ConfigurationUtil.instantiate(ConfigurationUtil.java:69)
    at org.janusgraph.diskstorage.Backend.getImplementationClass(Backend.java:477)
    at org.janusgraph.diskstorage.Backend.getStorageManager(Backend.java:409)
    at org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.<init>(GraphDatabaseConfiguration.java:1376)
    at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:164)
    at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:133)
    at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:113)
    ... 18 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.janusgraph.util.system.ConfigurationUtil.instantiate(ConfigurationUtil.java:58)
    ... 24 more
Caused by: org.janusgraph.diskstorage.TemporaryBackendException: Temporary failure in storage backend
    at org.janusgraph.diskstorage.cassandra.astyanax.AstyanaxStoreManager.ensureKeyspaceExists(AstyanaxStoreManager.java:619)
    at org.janusgraph.diskstorage.cassandra.astyanax.AstyanaxStoreManager.<init>(AstyanaxStoreManager.java:314)
    ... 29 more
Caused by: com.netflix.astyanax.connectionpool.exceptions.PoolTimeoutException: PoolTimeoutException: [host=cassandra(SERVICE_IP):9160, latency=10001(10001), attempts=1]Timed out waiting for connection
    at com.netflix.astyanax.connectionpool.impl.SimpleHostConnectionPool.waitForConnection(SimpleHostConnectionPool.java:231)
    at com.netflix.astyanax.connectionpool.impl.SimpleHostConnectionPool.borrowConnection(SimpleHostConnectionPool.java:198)
    at com.netflix.astyanax.connectionpool.impl.RoundRobinExecuteWithFailover.borrowConnection(RoundRobinExecuteWithFailover.java:84)
    at com.netflix.astyanax.connectionpool.impl.AbstractExecuteWithFailoverImpl.tryOperation(AbstractExecuteWithFailoverImpl.java:117)
    at com.netflix.astyanax.connectionpool.impl.AbstractHostPartitionConnectionPool.executeWithFailover(AbstractHostPartitionConnectionPool.java:352)
    at com.netflix.astyanax.thrift.ThriftClusterImpl.executeSchemaChangeOperation(ThriftClusterImpl.java:146)
    at com.netflix.astyanax.thrift.ThriftClusterImpl.internalCreateKeyspace(ThriftClusterImpl.java:321)
    at com.netflix.astyanax.thrift.ThriftClusterImpl.addKeyspace(ThriftClusterImpl.java:294)
    at org.janusgraph.diskstorage.cassandra.astyanax.AstyanaxStoreManager.ensureKeyspaceExists(AstyanaxStoreManager.java:614)

Я использую изображение janusgrah v2 и изображение gcr.io/google-samples/cassandra:v13 для Кассандры.

Я также пытался подключиться к порту 9160 cassandra из модуля busybox. Но, похоже, не работает. Но интересная вещь: ping, кажется, работает на имя службы (здесь Кассандра). Но только когда он добирается до telnet на порту 9160 или 9042, я получаю ошибку об отказе в соединении.

Вот Кассандра STS:

apiVersion: v1
kind: Service
metadata:
  labels:
    app: cassandra
  name: cassandra
spec:
  clusterIP: None
  ports:
  - port: 9042
    name: cql
  - port: 9160
    name: thrift
  selector:
    app: cassandra
---    
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: cassandra
  labels:
    app: cassandra
spec:
  serviceName: cassandra
  replicas: 3
  selector:
    matchLabels:
      app: cassandra
  template:
    metadata:
      labels:
        app: cassandra
    spec:
      terminationGracePeriodSeconds: 1800
      #schedulerName: stork       #Check benefits of using STORK as scheduler.
      containers:
      - name: cassandra
        image: gcr.io/google-samples/cassandra:v13
        ports:
          - containerPort: 7000
            name: intra-node
          - containerPort: 7001
            name: tls-intra-node
          - containerPort: 7199
            name: jmx
          - containerPort: 9042
            name: cql
          - containerPort: 9160
            name: thrift
          - containerPort: 9142
            name: transportssl
        resources:
          limits:
            cpu: "1Gi"
            memory: 2Gi
          requests:
            cpu: "500m"
            memory: 1Gi
        securityContext:
          capabilities:
            add:
              - IPC_LOCK
        lifecycle:
          preStop:
            exec:
              command: 
              - /bin/sh
              - -c
              - nodetool drain
        env:
          - name: CASSANDRA_SEEDS
            value: cassandra-0.cassandra.default.svc.cluster.local
          - name: MAX_HEAP_SIZE 
            value: 512M
          - name: HEAP_NEWSIZE
            value: 512M
          - name: CASSANDRA_CLUSTER_NAME
            value: "Cassandra"
          - name: CASSANDRA_DC
            value: "DC1"
          - name: CASSANDRA_RACK
            value: "Rack1"
          - name: CASSANDRA_AUTO_BOOTSTRAP
            value: "false"            
          - name: CASSANDRA_ENDPOINT_SNITCH
            value: GossipingPropertyFileSnitch
          - name: CASSANDRA_RPC_ADDRESS
            value: 0.0.0.0
          - name: CASSANDRA_NUM_TOKENS
            value: "32"
          - name: POD_IP
            valueFrom:
              fieldRef:
                fieldPath: status.podIP
        readinessProbe:
          exec:
            command:
            - /bin/bash
            - -c
            - /ready-probe.sh
          initialDelaySeconds: 15
          timeoutSeconds: 5
        volumeMounts:
        - name: nfs-pvc-cassandra
          mountPath: /srv/nfs/kubedata/janus
      restartPolicy: Always
      volumes:
        - name: nfs-pvc-cassandra
          persistentVolumeClaim:
            claimName: nfs-pvc-cassandra

Каким образом я могу отлаживать это дальше?

Ответы [ 2 ]

0 голосов
/ 20 мая 2019

Как я могу подтвердить, что ваш yaml StatefulSet работает просто отлично, а безголовый сервис создает DNS-имя, направляющее к конечным точкам модулей.Я создал простой модуль nginx для подключения к telnet для проверки.Вот вывод:

Проверьте, существуют ли конечные точки и сервис для cassandra

$ kubectl get svc,ep cassandra
NAME                TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)             AGE
service/cassandra   ClusterIP   None         <none>        9042/TCP,9160/TCP   2h

NAME                  ENDPOINTS                                                   AGE
endpoints/cassandra   10.56.0.10:9160,10.56.3.3:9160,10.56.4.2:9160 + 3 more...   2h

Выполните к соседнему модулю в том же пространстве имен и telnet к сервису и пакетам

$ kubectl  exec -it nginx-79dbd67896-9dwp8 bash

root@nginx-79dbd67896-9dwp8:/# telnet cassandra 9042
Trying 10.56.3.3...
Connected to cassandra.default.svc.cluster.local.
Escape character is '^]'.

telnet> quit
Connection closed.

root@nginx-79dbd67896-9dwp8:/# telnet 10.56.0.10 9042
Trying 10.56.0.10...
Connected to 10.56.0.10.
Escape character is '^]'.

Как видно из службы вывода и модули прослушивают порт 9042, а не 9160, поскольку порт 9160 предназначен для сервера Thrift API Cassandra, который по умолчанию отключен.Для получения дополнительной информации об этой проблеме проверьте https://github.com/docker-library/cassandra/issues/127.Вы должны проверить, как включить Thrift API порт.

Вы можете проверить порты прослушивания на модулях cassandra, выполнив один из этих модулей и выполнив следующие команды:

root@cassandra-0:/# apt update && apt install telnet net-tools
<output omitted>

root@cassandra-0:/# netstat -tulpen
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name    
tcp        0      0 0.0.0.0:9042            0.0.0.0:*               LISTEN      1000       10163244   -                   
tcp        0      0 127.0.0.1:43669         0.0.0.0:*               LISTEN      1000       10162974   -                   
tcp        0      0 10.56.0.10:7000         0.0.0.0:*               LISTEN      1000       10163145   -                   
tcp        0      0 127.0.0.1:7199          0.0.0.0:*               LISTEN      1000       10162973   -                   

Hopeэто помогает!

0 голосов
/ 18 апреля 2019

Если ваш janusgraph работает на вашем хост-компьютере, вам, возможно, придется сделать переадресацию портов ваших сервисов kubernetes, чтобы получить к нему доступ локально. Может быть, вы уже сделали это

...