当前位置: 首页 > 知识库问答 >
问题:

Cassandrasystem_schema密钥空间在创建表时不可修改

郑锦
2023-03-14

我有java应用程序,通过执行查询将应用程序中使用的所有cassandra表初始化为一个。它在本地运行良好,并与Apache Cassandra 3.3远程测试服务器一起运行。然而,当我在具有3个节点的Cassandra 3.3集群的生产中运行它时,它创建了前22个表,并总是在一个特定的表处停止,出现错误

ERROR UNAUTHORIZED: system_schema keyspace is not user-modifiable.

导致此问题的查询是:

创建表,如果不存在userrecom_newusers(userid bigint,时间戳bigint,主键(userid))

它使用键空间“prosolo_logs_moocs”,因此与系统模式无关。

创建这些表的Java代码是:

this.createSchemaIfNotExists(this.getSession(), this.dbName,
                this.dbConfig.replicationFactor);
        Metadata metadata = this.getCluster().getMetadata();
        metadata.getKeyspace(keyspacename).getTables();
        this.getSession().execute("USE "+keyspacename);
        for (String ddl : this.ddls) {
            try {
                this.getSession().execute(ddl);
            } catch (Exception ex) {
                logger.error("Error during the creation of table:"
                        + keyspacename + " for DDL:" + ddl);
                ex.printStackTrace();
            }
        }

完整的跟踪日志是:

    TRACE   [2016-11-27 06:55:31,313] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:71)       [1154641956] CREATE TABLE IF NOT EXISTS userrecom_newusers(userid bigint, timestamp bigint,  PRIMARY KEY (userid))
TRACE   [2016-11-27 06:55:31,313] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:71)       [1154641956] CREATE TABLE IF NOT EXISTS userrecom_newusers(userid bigint, timestamp bigint,  PRIMARY KEY (userid))
TRACE   [2016-11-27 06:55:31,313] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:272)      [1154641956-1] Starting
TRACE   [2016-11-27 06:55:31,313] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:272)      [1154641956-1] Starting
TRACE   [2016-11-27 06:55:31,313] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:280)      [1154641956-1] Querying node /10.0.0.184:9042
TRACE   [2016-11-27 06:55:31,313] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:280)      [1154641956-1] Querying node /10.0.0.184:9042
TRACE   [2016-11-27 06:55:31,313] [localhost-startStop-1] driver.core.Connection (Connection.java:519)      Connection[/10.0.0.184:9042-2, inFlight=1, closed=false], stream 1088, writing request QUERY CREATE TABLE IF NOT EXISTS userrecom_newusers(userid bigint, timestamp bigint,  PRIMARY KEY (userid))([cl=LOCAL_ONE, positionalVals=[], namedVals={}, skip=false, psize=5000, state=null, serialCl=SERIAL])
TRACE   [2016-11-27 06:55:31,313] [localhost-startStop-1] driver.core.Connection (Connection.java:519)      Connection[/10.0.0.184:9042-2, inFlight=1, closed=false], stream 1088, writing request QUERY CREATE TABLE IF NOT EXISTS userrecom_newusers(userid bigint, timestamp bigint,  PRIMARY KEY (userid))([cl=LOCAL_ONE, positionalVals=[], namedVals={}, skip=false, psize=5000, state=null, serialCl=SERIAL])
TRACE   [2016-11-27 06:55:31,313] [cluster3-nio-worker-3] driver.core.Connection (Connection.java:567)      Connection[/10.0.0.184:9042-2, inFlight=1, closed=false], stream 1088, request sent successfully
TRACE   [2016-11-27 06:55:31,313] [cluster3-nio-worker-3] driver.core.Connection (Connection.java:567)      Connection[/10.0.0.184:9042-2, inFlight=1, closed=false], stream 1088, request sent successfully
TRACE   [2016-11-27 06:55:31,315] [cluster3-nio-worker-3] driver.core.Connection (Connection.java:979)      Connection[/10.0.0.184:9042-2, inFlight=1, closed=false], stream 1088, received: ERROR UNAUTHORIZED: system_schema keyspace is not user-modifiable.
TRACE   [2016-11-27 06:55:31,315] [cluster3-nio-worker-3] driver.core.Connection (Connection.java:979)      Connection[/10.0.0.184:9042-2, inFlight=1, closed=false], stream 1088, received: ERROR UNAUTHORIZED: system_schema keyspace is not user-modifiable.
TRACE   [2016-11-27 06:55:31,316] [cluster3-nio-worker-3] driver.core.RequestHandler (RequestHandler.java:166)      [1154641956-1] Setting final result
TRACE   [2016-11-27 06:55:31,316] [cluster3-nio-worker-3] driver.core.RequestHandler (RequestHandler.java:166)      [1154641956-1] Setting final result
ERROR   [2016-11-27 06:55:31,316] [localhost-startStop-1] cassandra.impl.SimpleCassandraClientImpl (CassandraDDLManagerImpl.java:274)       Error during the creation of table:prosolo_logs_mooc for DDL:CREATE TABLE IF NOT EXISTS userrecom_newusers(userid bigint, timestamp bigint,  PRIMARY KEY (userid))
com.datastax.driver.core.exceptions.UnauthorizedException: system_schema keyspace is not user-modifiable.
    at com.datastax.driver.core.exceptions.UnauthorizedException.copy(UnauthorizedException.java:59)
    at com.datastax.driver.core.exceptions.UnauthorizedException.copy(UnauthorizedException.java:25)
    at com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:37)
    at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:245)
    at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:63)
    at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:39)
    at org.prosolo.bigdata.dal.cassandra.impl.CassandraDDLManagerImpl.checkIfTablesExistsAndCreate(CassandraDDLManagerImpl.java:272)
    at org.prosolo.bigdata.dal.cassandra.impl.CassandraDDLManagerImpl.<init>(CassandraDDLManagerImpl.java:39)
    at org.prosolo.bigdata.dal.cassandra.impl.CassandraDDLManagerImpl.<init>(CassandraDDLManagerImpl.java:23)
    at org.prosolo.bigdata.dal.cassandra.impl.CassandraDDLManagerImpl$CassandraDDLManagerImplHolder.<clinit>(CassandraDDLManagerImpl.java:44)
    at org.prosolo.bigdata.dal.cassandra.impl.CassandraDDLManagerImpl.getInstance(CassandraDDLManagerImpl.java:47)
    at org.prosolo.bigdata.app.ContextLoader.contextInitialized(ContextLoader.java:40)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:940)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1816)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.datastax.driver.core.exceptions.UnauthorizedException: system_schema keyspace is not user-modifiable.
    at com.datastax.driver.core.Responses$Error.asException(Responses.java:134)
    at com.datastax.driver.core.DefaultResultSetFuture.onSet(DefaultResultSetFuture.java:179)
    at com.datastax.driver.core.RequestHandler.setFinalResult(RequestHandler.java:184)
    at com.datastax.driver.core.RequestHandler.access$2500(RequestHandler.java:43)
    at com.datastax.driver.core.RequestHandler$SpeculativeExecution.setFinalResult(RequestHandler.java:798)
    at com.datastax.driver.core.RequestHandler$SpeculativeExecution.onSet(RequestHandler.java:617)
    at com.datastax.driver.core.Connection$Dispatcher.channelRead0(Connection.java:1005)
    at com.datastax.driver.core.Connection$Dispatcher.channelRead0(Connection.java:928)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
    at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:266)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:276)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:263)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:318)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:304)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
    at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:831)
    at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:346)
    at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:254)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
    ... 1 more

这个查询从Datastax DevCenter执行得很好。我使用datastax cassandra驱动程序3.0.0。

知道有什么问题吗?

更新:

这是我用来连接群集的代码:

public void connect(String node, int dbPort, String keyspace, int replicationFactor) {
    System.out.println("CONNECTING CASSANDRA:"+node+" keyspace:"+keyspace);
    if (this.session != null) {
        return;
    }
    if (this.cluster != null) {
        return;
    }
    /*cluster = Cluster.builder().addContactPoint(node).build();*/
    this.cluster = Cluster.builder()
            .withPoolingOptions( getPoolingOptions())
            .withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE)
            .withReconnectionPolicy(new ConstantReconnectionPolicy(100L))
            .withPort(dbPort)
            .addContactPoint(node).build();
    Metadata metadata = cluster.getMetadata();
    System.out.printf("Connected to cluster: %s\n",
            metadata.getClusterName());
    for ( Host host : metadata.getAllHosts() ) {
        System.out.printf("Datacenter: %s; Host: %s; Rack: %s\n",
                host.getDatacenter(), host.getAddress(), host.getRack());
    }
    if (keyspace != null) {
        try {
            this.session = this.cluster.connect(keyspace);
        } catch (InvalidQueryException iqu) {
            logger.error(iqu);
            this.session = this.cluster.connect();
            this.createSchemaIfNotExists(this.session, keyspace,
                    replicationFactor);
        }
    } else {
        this.session = this.cluster.connect();
    }
    this.session.execute("USE "+keyspace);
}

在我做了一些改变之后我现在得到了一个例外

Caused by: com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured table logevents

整个错误日志是:

    TRACE   [2016-11-27 20:09:08,775] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:72)       [1994318425] USE prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,775] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:72)       [1994318425] USE prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,775] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:262)      [1994318425-1] Starting
TRACE   [2016-11-27 20:09:08,775] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:262)      [1994318425-1] Starting
TRACE   [2016-11-27 20:09:08,775] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:270)      [1994318425-1] Querying node /10.0.0.182:9042
TRACE   [2016-11-27 20:09:08,775] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:270)      [1994318425-1] Querying node /10.0.0.182:9042
TRACE   [2016-11-27 20:09:08,775] [localhost-startStop-1] driver.core.Connection (Connection.java:472)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false] Setting keyspace prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,775] [localhost-startStop-1] driver.core.Connection (Connection.java:472)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false] Setting keyspace prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,776] [localhost-startStop-1] driver.core.Connection (Connection.java:532)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 384, writing request QUERY USE "prosolo_logs_mooc"([cl=ONE, positionalVals=[], namedVals={}, skip=false, psize=-1, state=null, serialCl=SERIAL])
TRACE   [2016-11-27 20:09:08,776] [localhost-startStop-1] driver.core.Connection (Connection.java:532)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 384, writing request QUERY USE "prosolo_logs_mooc"([cl=ONE, positionalVals=[], namedVals={}, skip=false, psize=-1, state=null, serialCl=SERIAL])
TRACE   [2016-11-27 20:09:08,776] [cluster3-nio-worker-1] driver.core.Connection (Connection.java:580)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 384, request sent successfully
TRACE   [2016-11-27 20:09:08,776] [cluster3-nio-worker-1] driver.core.Connection (Connection.java:580)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 384, request sent successfully
TRACE   [2016-11-27 20:09:08,776] [cluster3-nio-worker-1] driver.core.Connection (Connection.java:986)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 384, received: RESULT set keyspace prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,776] [cluster3-nio-worker-1] driver.core.Connection (Connection.java:986)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 384, received: RESULT set keyspace prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,777] [localhost-startStop-1] driver.core.Connection (Connection.java:532)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 448, writing request QUERY USE prosolo_logs_mooc([cl=LOCAL_ONE, positionalVals=[], namedVals={}, skip=false, psize=5000, state=null, serialCl=SERIAL])
TRACE   [2016-11-27 20:09:08,777] [localhost-startStop-1] driver.core.Connection (Connection.java:532)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 448, writing request QUERY USE prosolo_logs_mooc([cl=LOCAL_ONE, positionalVals=[], namedVals={}, skip=false, psize=5000, state=null, serialCl=SERIAL])
TRACE   [2016-11-27 20:09:08,777] [cluster3-nio-worker-1] driver.core.Connection (Connection.java:580)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 448, request sent successfully
TRACE   [2016-11-27 20:09:08,777] [cluster3-nio-worker-1] driver.core.Connection (Connection.java:580)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 448, request sent successfully
TRACE   [2016-11-27 20:09:08,777] [cluster3-nio-worker-1] driver.core.Connection (Connection.java:986)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 448, received: RESULT set keyspace prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,777] [cluster3-nio-worker-1] driver.core.Connection (Connection.java:986)      Connection[/10.0.0.182:9042-1, inFlight=1, closed=false], stream 448, received: RESULT set keyspace prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,778] [cluster3-nio-worker-1] driver.core.RequestHandler (RequestHandler.java:156)      [1994318425-1] Setting final result
TRACE   [2016-11-27 20:09:08,778] [cluster3-nio-worker-1] driver.core.RequestHandler (RequestHandler.java:156)      [1994318425-1] Setting final result
TRACE   [2016-11-27 20:09:08,778] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:72)       [1035879214] CREATE INDEX IF NOT EXISTS eventtype_id ON logevents (eventtype);
TRACE   [2016-11-27 20:09:08,778] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:72)       [1035879214] CREATE INDEX IF NOT EXISTS eventtype_id ON logevents (eventtype);
TRACE   [2016-11-27 20:09:08,778] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:262)      [1035879214-1] Starting
TRACE   [2016-11-27 20:09:08,778] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:262)      [1035879214-1] Starting
TRACE   [2016-11-27 20:09:08,778] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:270)      [1035879214-1] Querying node /10.0.0.183:9042
TRACE   [2016-11-27 20:09:08,778] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:270)      [1035879214-1] Querying node /10.0.0.183:9042
TRACE   [2016-11-27 20:09:08,778] [localhost-startStop-1] driver.core.Connection (Connection.java:472)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false] Setting keyspace prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,778] [localhost-startStop-1] driver.core.Connection (Connection.java:472)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false] Setting keyspace prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,778] [localhost-startStop-1] driver.core.Connection (Connection.java:532)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 384, writing request QUERY USE "prosolo_logs_mooc"([cl=ONE, positionalVals=[], namedVals={}, skip=false, psize=-1, state=null, serialCl=SERIAL])
TRACE   [2016-11-27 20:09:08,778] [localhost-startStop-1] driver.core.Connection (Connection.java:532)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 384, writing request QUERY USE "prosolo_logs_mooc"([cl=ONE, positionalVals=[], namedVals={}, skip=false, psize=-1, state=null, serialCl=SERIAL])
TRACE   [2016-11-27 20:09:08,779] [cluster3-nio-worker-2] driver.core.Connection (Connection.java:580)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 384, request sent successfully
TRACE   [2016-11-27 20:09:08,779] [cluster3-nio-worker-2] driver.core.Connection (Connection.java:580)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 384, request sent successfully
TRACE   [2016-11-27 20:09:08,779] [cluster3-nio-worker-2] driver.core.Connection (Connection.java:986)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 384, received: RESULT set keyspace prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,779] [cluster3-nio-worker-2] driver.core.Connection (Connection.java:986)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 384, received: RESULT set keyspace prosolo_logs_mooc
TRACE   [2016-11-27 20:09:08,780] [localhost-startStop-1] driver.core.Connection (Connection.java:532)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 448, writing request QUERY CREATE INDEX IF NOT EXISTS eventtype_id ON logevents (eventtype);([cl=LOCAL_ONE, positionalVals=[], namedVals={}, skip=false, psize=5000, state=null, serialCl=SERIAL])
TRACE   [2016-11-27 20:09:08,780] [localhost-startStop-1] driver.core.Connection (Connection.java:532)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 448, writing request QUERY CREATE INDEX IF NOT EXISTS eventtype_id ON logevents (eventtype);([cl=LOCAL_ONE, positionalVals=[], namedVals={}, skip=false, psize=5000, state=null, serialCl=SERIAL])
TRACE   [2016-11-27 20:09:08,780] [cluster3-nio-worker-2] driver.core.Connection (Connection.java:580)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 448, request sent successfully
TRACE   [2016-11-27 20:09:08,780] [cluster3-nio-worker-2] driver.core.Connection (Connection.java:580)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 448, request sent successfully
TRACE   [2016-11-27 20:09:08,781] [cluster3-nio-worker-2] driver.core.Connection (Connection.java:986)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 448, received: ERROR INVALID: unconfigured table logevents
TRACE   [2016-11-27 20:09:08,781] [cluster3-nio-worker-2] driver.core.Connection (Connection.java:986)      Connection[/10.0.0.183:9042-1, inFlight=1, closed=false], stream 448, received: ERROR INVALID: unconfigured table logevents
TRACE   [2016-11-27 20:09:08,781] [cluster3-nio-worker-2] driver.core.RequestHandler (RequestHandler.java:156)      [1035879214-1] Setting final result
TRACE   [2016-11-27 20:09:08,781] [cluster3-nio-worker-2] driver.core.RequestHandler (RequestHandler.java:156)      [1035879214-1] Setting final result
ERROR   [2016-11-27 20:09:08,782] [localhost-startStop-1] cassandra.impl.SimpleCassandraClientImpl (CassandraDDLManagerImpl.java:274)       Error during the creation of table:prosolo_logs_mooc for DDL:CREATE INDEX IF NOT EXISTS eventtype_id ON logevents (eventtype);
com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured table logevents
    at com.datastax.driver.core.exceptions.InvalidQueryException.copy(InvalidQueryException.java:50)
    at com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:37)
    at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:245)
    at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:64)
    at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:39)
    at org.prosolo.bigdata.dal.cassandra.impl.CassandraDDLManagerImpl.checkIfTablesExistsAndCreate(CassandraDDLManagerImpl.java:272)
    at org.prosolo.bigdata.dal.cassandra.impl.CassandraDDLManagerImpl.<init>(CassandraDDLManagerImpl.java:39)
    at org.prosolo.bigdata.dal.cassandra.impl.CassandraDDLManagerImpl.<init>(CassandraDDLManagerImpl.java:23)
    at org.prosolo.bigdata.dal.cassandra.impl.CassandraDDLManagerImpl$CassandraDDLManagerImplHolder.<clinit>(CassandraDDLManagerImpl.java:44)
    at org.prosolo.bigdata.dal.cassandra.impl.CassandraDDLManagerImpl.getInstance(CassandraDDLManagerImpl.java:47)
    at org.prosolo.bigdata.app.ContextLoader.contextInitialized(ContextLoader.java:40)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:940)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1816)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured table logevents
    at com.datastax.driver.core.Responses$Error.asException(Responses.java:136)
    at com.datastax.driver.core.DefaultResultSetFuture.onSet(DefaultResultSetFuture.java:179)
    at com.datastax.driver.core.RequestHandler.setFinalResult(RequestHandler.java:174)
    at com.datastax.driver.core.RequestHandler.access$2600(RequestHandler.java:43)
    at com.datastax.driver.core.RequestHandler$SpeculativeExecution.setFinalResult(RequestHandler.java:793)
    at com.datastax.driver.core.RequestHandler$SpeculativeExecution.onSet(RequestHandler.java:627)
    at com.datastax.driver.core.Connection$Dispatcher.channelRead0(Connection.java:1012)
    at com.datastax.driver.core.Connection$Dispatcher.channelRead0(Connection.java:935)
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:328)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:321)
    at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:266)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:328)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:321)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:328)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:321)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:328)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:321)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1280)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:328)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:890)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:564)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:505)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:419)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:391)
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
    ... 1 more
TRACE   [2016-11-27 20:09:08,783] [localhost-startStop-1] driver.core.RequestHandler (RequestHandler.java:72)       [1037500672] USE prosolo_logs_mooc

更新2:

似乎我遇到的所有问题都与未正确配置的集群有关。尽管nodetool状态指示所有节点都已连接,但有些节点无法访问,并且存在架构不一致。在我解决了这些问题后,一切都很好。

共有1个答案

萧麒
2023-03-14

以下是Java的工作代码:

public static void main(String[] args) {
    try (Cluster cluster = Cluster.builder().addContactPoints("127.0.0.1").withCredentials("username", "password").build(); Session session = cluster.connect("test")) {
        createTableIfNotExist(cluster, session, "test");
    }
}

private static void createTableIfNotExist(Cluster cluster, Session session, String keyspace) {
    Metadata metadata = cluster.getMetadata();
    TableMetadata tableMetadata = metadata.getKeyspace(keyspace).getTable("exp");
    if (tableMetadata == null) {
        session.execute("USE " + keyspace);
        session.execute("CREATE TABLE exp(a int primary key, b int)");
    }
}
 类似资料:
  • 问题内容: 假设我在, 我想抽出时间来创作。是否有类似的东西 ? 问题答案: Redis不存储此信息。 您可以使用单独的密钥:

  • 在我的CI中,我运行一个命令来发布一个应用程序。但如果它是一个不存在的应用程序,我必须创建名称空间、一个秘密并修补serviceaccount。所以我想到了这个: 这是工作,但我认为这不是完美的方式,因为这三个步骤应该只做一次。:只有当应用程序/命名空间/秘密不存在时

  • 问题内容: 我想知道是否有人尝试使用默认键空间构建cassandra docker镜像,但我尝试在BUILD时间内完成该操作,但由于cassandra不在该阶段运行,因此无法正常工作。这类似于以下内容: 我的新方法是从入口点脚本执行此操作,但是,如果其他人有更好的主意,我现在想。 快乐运输:D 问题答案: 今天解决了这个问题。构建映像,该映像将在修改之前附加一个修改过的默认Cassandra 将所

  • Liquibase版本:3.3.2 DB平台:SQL服务器2014 驱动程序:jdbc 4.0 我使用GenerateChangeLog命令从我的数据库生成一组新的部署脚本。许多表都没有NULL列,但当我测试Liquibase部署(更新)列时,它们都可以为空。这导致PK创建失败。 样本更改集: 有什么建议吗?

  • 我已经用这个链接备份了我在卡桑德拉的密钥空间cassandra-backup.sh 为了恢复,我写了一个脚本,从包含快照的备份文件夹中复制内容,并粘贴到 /var/lib/cassandra/data/mykeypsace/下的相应目录中,但是当我看到mykeyspace的表内容时,没有恢复任何内容。例如,备份文件夹:path/mykeyspace/tableOne/snapshot/all-co