gpt4 book ai didi

linux - MongoDB安装Ubuntu 12.04 LTS报错

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:57:40 25 4
gpt4 key购买 nike

我需要一些帮助来帮助我在干净、全新的 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 - 响应 Fernando

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

关于linux - MongoDB安装Ubuntu 12.04 LTS报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29305907/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com