我正在尝试将表单提交保存到DynamoDB表中,但是,我遇到了本地连接问题。我现在正在本地运行DynamoDB,但稍后我想将其移回可从Elastic Beanstalk访问的普通DDB实例。
我已经将dynamodb-local
下载并解压缩到一个目录中,并运行了java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
命令,以确保我位于适当的目录中。当我运行命令时,得到以下信息:
Initializing DynamoDB Local with the following configuration:
Port: 8000
InMemory: false
DbPath: null
SharedDb: true
shouldDelayTransientStatuses: false
CorsParams: *
这时,我尝试将表单提交到app.js
中的POST端点,但是在运行DynamoDB local的终端上出现此重复错误:
Jan 12, 2019 1:24:25 PM com.almworks.sqlite4java.Internal log
WARNING: [sqlite] cannot open DB[1]:
com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: java.lang.UnsatisfiedLinkError: C:\cygwin64\home\Administrator\dynamodb_local_latest\DynamoDBLocal_lib\sqlite4java-win32-x64.dll: Access is denied
Jan 12, 2019 1:24:25 PM com.almworks.sqlite4java.Internal log
SEVERE: [sqlite] SQLiteQueue[shared-local-instance.db]: error running job queue
com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: java.lang.UnsatisfiedLinkError: C:\cygwin64\home\Administrator\dynamodb_local_latest\DynamoDBLocal_lib\sqlite4java-win32-x64.dll: Access is denied
at com.almworks.sqlite4java.SQLite.loadLibrary(SQLite.java:97)
at com.almworks.sqlite4java.SQLiteConnection.open0(SQLiteConnection.java:1441)
at com.almworks.sqlite4java.SQLiteConnection.open(SQLiteConnection.java:282)
at com.almworks.sqlite4java.SQLiteConnection.open(SQLiteConnection.java:293)
at com.almworks.sqlite4java.SQLiteQueue.openConnection(SQLiteQueue.java:464)
at com.almworks.sqlite4java.SQLiteQueue.queueFunction(SQLiteQueue.java:641)
at com.almworks.sqlite4java.SQLiteQueue.runQueue(SQLiteQueue.java:623)
at com.almworks.sqlite4java.SQLiteQueue.access$000(SQLiteQueue.java:77)
at com.almworks.sqlite4java.SQLiteQueue$1.run(SQLiteQueue.java:205)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.UnsatisfiedLinkError: C:\cygwin64\home\Administrator\dynamodb_local_latest\DynamoDBLocal_lib\sqlite4java-win32-x64.dll: Access is denied
at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
at java.base/java.lang.ClassLoader$NativeLibrary.load(Unknown Source)
at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(Unknown Source)
at java.base/java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.base/java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.base/java.lang.Runtime.load0(Unknown Source)
at java.base/java.lang.System.load(Unknown Source)
at com.almworks.sqlite4java.Internal.tryLoadFromPath(Internal.java:340)
at com.almworks.sqlite4java.Internal.loadLibraryX(Internal.java:117)
at com.almworks.sqlite4java.SQLite.loadLibrary(SQLite.java:95)
... 9 more
在运行Node worker集群的终端中,我从每个worker(8)得到以下错误输出,然后是DDB错误:
Failed to create table in DB.
{ Error: connect ECONNREFUSED 127.0.0.1:8000
at Object.exports._errnoException (util.js:1022:11)
at exports._exceptionWithHostPort (util.js:1045:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:14)
message: 'connect ECONNREFUSED 127.0.0.1:8000',
code: 'NetworkingError',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 8000,
region: 'us-west-2',
hostname: 'localhost',
retryable: true,
time: 2019-01-12T20:31:00.742Z }
DDB Error: NetworkingError: connect ECONNREFUSED 127.0.0.1:8000
我保证我会完成这项工作。这是我用于创建DDB表的代码(我将const ddb = new AWS.DynamoDB()
作为参数传递给app.js
):
const AWS = require('aws-sdk');
function createDDBTable(ddb, tableName) {
// console.log('ddb:\n',ddb);
const tableParams = {
AttributeDefinitions: [
{
AttributeName: 'email',
AttributeType: 'S'
},
{
AttributeName: 'id',
AttributeType: 'S'
}
],
KeySchema: [
{
AttributeName: 'email',
KeyType: 'HASH'
},
{
AttributeName: 'id',
KeyType: 'RANGE'
}
],
ProvisionedThroughput: {
ReadCapacityUnits: 8,
WriteCapacityUnits: 8
},
TableName: tableName,
StreamSpecification: {
StreamEnabled: false
}
};
ddb.createTable(tableParams, (err, data) => {
if(err) console.error('Failed to create table in DB.\n', err);
else console.log('Success creating table!', data);
})
}
module.exports = createDDBTable;
我对我要去的地方不知所措。我所有的验证和端点都可以正常工作,但是,当需要创建表时,我的代码使我无法克服错误。我也觉得可能需要稍微调整options.config
文件,但是我不确定如何设置格式。在此先感谢您的帮助!我试图彻底解决自己的问题,但请告知我是否可以继续做其他事情。