Ошибка Кассандры: NoHostAvailableError часто
У меня есть одна машина CentOS по сети. В котором я пытался подключить Cassandra, используя NodeJS через express-cassandra node_module. И когда я запускаю свое приложение, оно выдает мне следующий журнал ошибок.
0|app | 2018-03-07T14:49:21.329 ERROR cassandra 4456 {
NoHostAvailableError: All host(s) tried for query failed. First host tried,
127.0.0.1:9160: OperationTimedOutError: The host 127.0.0.1:9160 did not
reply before timeout 12000 ms. See innerErrors.
0|app | at whilstEnded
(/opt/cisco/sprint5_node/node_modules/cassandra-driver/lib/control-
connection.js:231:25)
0|app | at next (/opt/cisco/sprint5_node/node_modules/cassandra-
driver/lib/utils.js:842:14)
0|app | at borrowConnectionCallback
(/opt/cisco/sprint5_node/node_modules/cassandra-driver/lib/control-
connection.js:226:9)
0|app | at HostConnectionPool.create.err
(/opt/cisco/sprint5_node/node_modules/cassandra-driver/lib/host-connection-
pool.js:71:16)
0|app | at Object.onceWrapper (events.js:315:30)
0|app | at emitOne (events.js:116:13)
0|app | at HostConnectionPool.emit (events.js:211:7)
0|app | at whilstEnded
(/opt/cisco/sprint5_node/node_modules/cassandra-driver/lib/host-connection-
pool.js:173:23)
0|app | at next (/opt/cisco/sprint5_node/node_modules/cassandra-
driver/lib/utils.js:839:14)
0|app | at HostConnectionPool.<anonymous>
(/opt/cisco/sprint5_node/node_modules/cassandra-driver/lib/utils.js:851:9)
0|app | at Object.onceWrapper (events.js:315:30)
0|app | at emitOne (events.js:121:20)
0|app | at HostConnectionPool.emit (events.js:211:7)
0|app | at attemptOpenCallback
(/opt/cisco/sprint5_node/node_modules/cassandra-driver/lib/host-connection-
pool.js:223:21)
0|app | at Connection.errorConnecting
(/opt/cisco/sprint5_node/node_modules/cassandra-
driver/lib/connection.js:225:3)
0|app | at Socket.socketError
(/opt/cisco/sprint5_node/node_modules/cassandra-
driver/lib/connection.js:146:10)
0|app | name: 'NoHostAvailableError',
0|app | info: 'Represents an error when a query cannot be performed
because no host is available or could be reached by the driver.',
Я пытался изменить rpc_address, listen_address с помощью других ссылок, но все еще сталкивается с проблемой.
Это код для привязки моделей
cassandra_model.setDirectory(path.resolve() + '/app' + '/models')
.bind({
clientOptions: {
contactPoints: [config.cassandra.ip],
protocolOptions: { port: config.cassandra.port },
keyspace: config.cassandra.keyspace,
queryOptions: { consistency: cassandra_model.consistencies.one },
socketOptions: { readTimeout: 0 }
},
ormOptions: {
defaultReplicationStrategy: {
class: 'SimpleStrategy',
replication_factor: 1
},
migration: 'alter',
createKeyspace: true
}
}, function onError(err) {
cassandra_model.timeuuid()
if (err) {
logger.error(err);
}
else {
logger.info('Cassandra_model initialized!');
}
});
Приведенный выше код работает нормально. Теперь я хочу подключиться к пространству клавиш без привязки моделей. так попробовал следующий код.
var ExpressCassandra = require('express-cassandra');
var models = ExpressCassandra.createClient({
clientOptions: {
contactPoints: [config.cassandra.ip],
protocolOptions: { port: 9042 },
keyspace: config.cassandra.keyspace,
queryOptions: { consistency: ExpressCassandra.consistencies.one }
},
ormOptions: {
defaultReplicationStrategy: {
class: 'SimpleStrategy',
replication_factor: 1
},
migration: 'safe',
}
}, function onError(err) {
cassandra_model.timeuuid()
if (err) {
logger.error(err);
}
else {
logger.info('Cassandra initialized!');
}
});
но я не могу подключиться к Кассандре. Что-то я не так делаю здесь?