簡體   English   中英

MongoDB安裝Ubuntu 12.04 LTS錯誤

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM