0
我試圖約6GB的遷移是由數百個集合來DynamoDB的蒙戈數據。我已經使用AWS PHP SDK編寫了一些腳本,並且能夠移植非常小的集合,但是當我嘗試擁有超過20k個文檔(仍然是所有事情考慮的非常小的集合)時,它要麼花費大量時間,要麼靜靜地失敗。
是否有人從Mongo(或任何其他NoSQL DB)獲取數據並將其遷移到Dynamo或任何其他NoSQL數據庫中有一些提示/技巧。我覺得這應該是相對容易的,因爲文件非常平坦/簡單。
任何想法/建議將不勝感激!
謝謝!
的header.php
<?
require './aws-autoloader.php';
require './MongoGet.php';
set_time_limit(0);
use \Aws\DynamoDb\DynamoDbClient;
$client = \Aws\DynamoDb\DynamoDbClient::factory(array(
'key' => 'MY_KEY',
'secret' => 'MY_SECRET',
'region' => 'MY_REGION',
'base_url' => 'http://localhost:8000'
));
$collection = "AccumulatorGasPressure4093_raw";
function nEcho($str) {
echo "{$str}<br>\n";
}
echo "<pre>";
測試store.php
<?
include('test-header.php');
nEcho("Creating table(s)...");
// create test table
$client->createTable(array(
'TableName' => $collection,
'AttributeDefinitions' => array(
array(
'AttributeName' => 'id',
'AttributeType' => 'N'
),
array(
'AttributeName' => 'count',
'AttributeType' => 'N'
)
),
'KeySchema' => array(
array(
'AttributeName' => 'id',
'KeyType' => 'HASH'
),
array(
'AttributeName' => 'count',
'KeyType' => 'RANGED'
)
),
'ProvisionedThroughput' => array(
'ReadCapacityUnits' => 10,
'WriteCapacityUnits' => 20
)
));
$result = $client->describeTable(array(
'TableName' => $collection
));
nEcho("Done creating table...");
nEcho("Getting data from Mongo...");
// instantiate class and get data
$mGet = new MongoGet();
$results = $mGet->getData($collection);
nEcho ("Done retrieving Mongo data...");
nEcho ("Inserting data...");
$i = 0;
foreach($results as $result) {
$insertResult = $client->putItem(array(
'TableName' => $collection,
'Item' => $client->formatAttributes(array(
'id' => $i,
'date' => $result['date'],
'value' => $result['value'],
'count' => $i
)),
'ReturnConsumedCapacity' => 'TOTAL'
));
$i++;
}
nEcho("Done Inserting, script ending...");
如果這些表正在被限制,那麼確實很容易。查看顯示器圖表,告訴您受限請求的數量和消耗的吞吐量。 – kurtzbot 2014-10-01 21:00:36