您的位置:首页 > 数据库 > Mongodb

在Ubuntu中安装mongodb

2015-10-28 10:50 633 查看
#下载密钥文件

sudoapt-keyadv--keyserverhkp://keyserver.ubuntu.com:80--recv7F0CEB10

gpg:下载密钥‘7F0CEB10’,从hkp服务器keyserver.ubuntu.com
gpg:密钥7F0CEB10:公钥“RichardKreuter”已导入
gpg:没有找到任何绝对信任的密钥
gpg:合计被处理的数量:1
gpg:已导入:1(RSA:1)

#在source.list中增加MongoDB源的配置
sudovim/etc/apt/source.list/...............
debhttp://downloads-distro.mongodb.org/repo/ubuntu-upstartdist10gen

#更新软件源
sudoapt-getupdate

#安装MongoDB服务器端
sudoapt-getinstallmongodb-10gen

Ubuntu下安装pip的方法安装pip的方法:
InstallpipandvirtualenvforUbuntu10.10Maverickandnewer$sudoapt-getinstallpython-pippython-devbuild-essential
$sudopipinstall--upgradepip
$sudopipinstall--upgradevirtualenv
ForolderversionsofUbuntuInstallEasyInstall
$sudoapt-getinstallpython-setuptoolspython-devbuild-essential
Installpip
$sudoeasy_installpip
Installvirtualenv
$sudopipinstall--upgradevirtualenv解压后,首先进入解压后目录安装easyinstall:sudopythonez_setup.py然后安装mongo-connector:sudopythonsetup.pyinstall

下一步,我们将启动MongoConnector。为了下载和安装MongoConnector,你可以使用pip:
pipinstallmongo-connector

为了示例的正常进行,我们假设你已经安装好了Elasticsearch,且运行于端口为9200的本地机器。你可以使用下面的命令从MongoDB复制到Elasticsearch。
mongo-connector-mlocalhost:27017-tlocalhost:9200-dmongo_connector/doc_managers/elastic_doc_manager.py

当然,如果只想在post标题和内容中进行文本搜索,我们可以使用Elasticsearch的字段选项来限制字段。通过这个方法,我们能最小化所复制的数据量:
mongo-connector-mlocalhost:27017-tlocalhost:9200--fieldstitle,text-dmongo_connector/doc_managers/elastic_doc_manager.py

就像你看到reddit2mongo将Redditpost以STDOUT输出,你同样可以看到从MongoConnector输出的日志——所有文档都在同时发送给了ES。

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: