我在一个干净,新鲜的Ubuntu 12.04 LTS服务器上安装我的MongoDB需要一些帮助,没有安装废话。我认为这将是一块蛋糕,但我有一些错误,Ubuntu论坛没有得到我想要的答案。
在开始实际安装MongoDB之前,我希望服务器是最新的,所以我键入了:
$ sudo apt-get clean && sudo apt-get update && sudo apt-get upgrade
我从MongoDB(http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/)访问了网站并按照他们的教程进行了操作,因此我键入了:
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
$ echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
$ sudo apt-get update
$ sudo apt-get install -y mongodb-org
此时我安装了MongoDB。就像我们都知道的那样,为了使用MongoDB,您需要使用终端启动它,之后您就可以使用分离的终端/连接进行连接。
所以,我打字:
ubuntu-user@ubuntu-vm:~$ mongo
MongoDB shell version: 3.0.1
connecting to: test
Server has startup warnings:
2015-03-27T12:37:30.430+0100 I CONTROL [initandlisten]
2015-03-27T12:37:30.430+0100 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-03-27T12:37:30.430+0100 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2015-03-27T12:37:30.430+0100 I CONTROL [initandlisten]
> ^C
ubuntu-user@ubuntu-vm:~$ mongod
2015-03-27T12:38:54.773+0100 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2015-03-27T12:38:54.774+0100 I CONTROL [initandlisten] dbexit: rc: 100
当然,在我先做自己的调查之前,我不想马上使用stackoverflow。我上网寻找答案,我注意到很多人使用"导出LC_ALL = C"修复变量问题。我也尝试过使用dpkg。
ubuntu-user@ubuntu-vm:~$ export LC_ALL=C
ubuntu-user@ubuntu-vm:~$ dpkg-reconfigure locales
root@ubuntu-vm:~# dpkg-reconfigure locales
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:en",
LC_ALL = "c",
LC_PAPER = "nl_NL.UTF-8",
LC_ADDRESS = "nl_NL.UTF-8",
LC_MONETARY = "nl_NL.UTF-8",
LC_NUMERIC = "nl_NL.UTF-8",
LC_TELEPHONE = "nl_NL.UTF-8",
LC_IDENTIFICATION = "nl_NL.UTF-8",
LC_MEASUREMENT = "nl_NL.UTF-8",
LC_NAME = "nl_NL.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (c)
Generating locales...
en_AG.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
en_AU.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
en_BW.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
en_CA.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
en_DK.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
en_GB.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
en_HK.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
en_IE.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
en_IN.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
en_NG.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
en_NZ.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
en_PH.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
en_SG.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
en_US.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
en_ZA.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
en_ZM.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
en_ZW.UTF-8... /usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (c)
up-to-date
Generation complete.
显然,这不能正常工作,所以我需要继续搜索。我提出了另一个解决方案:使用 GRUB_CMDLINE_LINUX_DEFAULT =&#34; transparent_hugepage = never&#34; 编辑 / etc / default / grub文件然后我得到了这个:< / p>
ubuntu-user@ubuntu-vm:~$ mongo
Failed global initialization: BadValue Invalid or no user locale set.
Please ensure LANG and/or LC_* environment variables are set correctly.
ubuntu-user@ubuntu-vm:~$ mongod
2015-03-27T12:56:19.085+0100 F CONTROL Failed global initialization:
BadValue Invalid or no user locale set. Please ensure LANG and/or LC_*
environment variables are set correctly.
所以,实际上我不知道出了什么问题。我浏览了整个互联网,无法找到我想要的确切答案。我做了一个干净的安装就像网站说的那样。几个月前,我做了相同的教程,一切都运行良好,版本2.6.x,这是3.0.1。
你可以帮帮我吗?任何评论/提示/技巧将真诚地感谢:)编辑1 - 回复费尔南多
ubuntu-user@ubuntu-vm:~$ mongo
MongoDB shell version: 3.0.1
connecting to: test
Server has startup warnings:
2015-03-27T13:53:25.243+0100 I CONTROL [initandlisten]
2015-03-27T13:53:25.243+0100 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-03-27T13:53:25.243+0100 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2015-03-27T13:53:25.243+0100 I CONTROL [initandlisten]
> LC_ALL=C mongo
2015-03-27T18:54:16.838+0100 E QUERY SyntaxError: Unexpected identifier
> LC_ALL=C
2015-03-27T18:54:20.061+0100 E QUERY ReferenceError: C is not defined
at (shell):1:8
> ^C
bye
答案 0 :(得分:4)
使用apt-get安装后,您无需手动启动mongod。您可以使用
启动和停止服务器# service mongod start
和
# service mongod stop
您第一次输入mongo并获得:
MongoDB shell version: 3.0.1
connecting to: test
服务器已启动并正在运行。
如果您现在遇到此错误:
Failed global initialization: BadValue Invalid or no user locale set. Please ensure LANG and/or LC_* environment variables are set correctly.
您可以启动mongo shell声明变量LC_ALL,运行:
# LC_ALL=C mongo
答案 1 :(得分:0)
转到编辑文件/etc/default/locale
并设置
LANG=
LANGUAGE=
LC_ALL=
到您的首选设置。举个例子:
$ vim /etc/default/locale
LANG=en_US.UTF-8
LANGUAGE=en_US
LC_ALL=en_US.UTF-8