[英]MongoDB installation Ubuntu 12.04 LTS errors
在干净,新鲜的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。 我上网寻找答案,发现很多人使用“ export 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 =“ transparent_hugepage = never”编辑/ etc / default / grub文件 ,然后得到以下信息:
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
使用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
转到编辑文件/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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.