加载 JSON 文件到 couchbase 服务器

Load JSON file to couchbase server

我有 JSON 大小为 1.5GB 的文件,我需要将其上传到 Couchbase 服务器存储桶。我使用以下命令加载。

cbdocloader -n 10.5.2.117:8091 -u Administrator -p password -b mybucket ../samples/gamesim.zip

不幸的是,由于内存问题,它断了。有人可以建议更好的方法或最佳方法来解决这个问题吗?我的机器有 15GB 内存和 Intel Xeon CPU,速度为 2.50GHz。

提前致谢, Tismon Varghese.

我使用了一个小的 java 程序来实现它。你可以参考这个 link http://architects.dzone.com/articles/sql-nosql-copy-your-data-mysql 使用此程序迁移了一个大型 MySQL 数据库 table(28Lac 记录)(您可以使用此程序迁移整个数据库,甚至是所有数据库)。

MySQL OS : Ubuntu 14.04(亚马逊实例) 内存:7.4G

Couchbase OS : Ubuntu 14.04(亚马逊实例) 内存:15G(2xlarge 实例) Java : java 版本“1.7.0_79”
Note: Memory eaten up while using a Amazone machine with Memory 7.4G

第 1 步。从 github (https://github.com/tgrall/couchbase-sql-importer) 下载 couchbase-sql-importer 到 Couchase 服务器,在您的主文件夹中的某个位置并解压缩。

第三步。从 http://downloads.mysql.com/archives/c-j/ 下载 'mysql-connector-java-5.1.25-bin.jar' 到 'couchbase-sql-importer-master'(解压文件夹)。从 mysql 站点下载 jar 文件时,您需要 select 从下拉列表中选择 jar fie 版本。

Step4.Download 'CouchbaseSqlImporter.jar' 从 https://www.dropbox.com/s/pcnwukw2j8xe2d2/CouchbaseSqlImporter.jar 到文件夹 'couchbase-sql-importer-master'。

Step5.Edit fie 'import.properties' 喜欢,

## SQL Information ##
sql.connection=jdbc:mysql://mysql_server_ip:3306/database_name
sql.username=mysql_user_name
sql.password=myql_password

## Couchbase Information ##
cb.uris=http://localhost:8091/pools
cb.bucket=bucket_name
cb.password=bucket's_password

## Import information
import.tables=specific_table_name
import.createViews=true
import.typefield=
import.fieldcase=none

保存此文件。

注意事项

cb.password=bucket's_password     
// you can set passwords for each bucket via Couchbase console. Select bucket and edit the feild 'Access Control' and give password in there and save.



import.tables=All  //For migrating entire table.

If import.properties file not found in 'couchbase-sql-importer-master' folder, then search and find sample import.properties file and rename it to so.

第六步。 运行终端中的这个命令,

java -cp "./CouchbaseSqlImporter.jar:./mysql-connector-java-5.1.25-bin.jar" com.couchbase.util.SqlImporter import.properties

输出


############################################
#         COUCHBASE SQL IMPORTER           #
############################################



Importing table(s)
    from :  jdbc:mysql://XXXX:3306/XXX
    to :    [http://localhost:8091/pools] - XXXX

  Exporting Table : XXXX


 Create Couchbase views for XXXX
    2801937 records moved to Couchbase.


 Create Couchbase views for 'types' ....


              FINISHED
############################################

Check Couchbase console for verifying  the content.

希望这crystal对你来说是清楚的:) 谢谢。