liunx 下 安裝MongoDB時的啓動問題

liunx 下 安裝MongoDB時的啓動問題

一. 啓動MongoDB4.0.4時出現/lib64/libc.so.6: version `GLIBC_2.14’ not found解決辦法

1. 安裝環境

centOS 6. x

2. 查看系統glibc支持的版本

[root@jones bin]# strings /lib64/libc.so.6 | grep GLIBC
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_PRIVATE

我們可以看到最高版本是2.12的沒有glibc2.14 我們下載下

3. 下載glibc-2.14.tar.xz

下載之前 最好先建好glibc的文件夾,這樣方便管理

wget http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.xz

4. 解壓

4.1 解壓可能遇到的問題

如果沒有安裝xz的解壓環境則無法解壓

安裝yum -y install xz

4.2 解壓

tar xvJf glibc-2.14.tar.xz

5.在glibc-2.14源碼目錄建立build目錄,並進入build目錄

$ cd glibc-2.14  
$ mkdir build  
$ cd build/ 

6. 配置. 編譯並安裝

$ ../configure --prefix=/opt/glibc-2.14  
$ make -j4  
$ make install 

7. 繼續配置

cp  /etc/ld.so.c* /opt/glibc-2.14/etc/
ln -sf /opt/glibc-2.14/lib/libc-2.14.so /lib64/libc.so.6

8. 查看版本庫的支持

[root@jones bin]# strings /lib64/libc.so.6 | grep GLIBC
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_2.13
GLIBC_2.14

安裝成功

9. 啓動MongoDB

9.1 命令啓動

命令啓動不需要配置文件

# 進入bin目錄
cd /usr/local/mongodb/bin
# 啓動
./mongod --dbpath /usr/local/mongodb/data/db/ --logpath /usr/local/mongodb/logs/mongodb.log --logappend -fork --bind_ip 0.0.0.0

啓動界面

[root@jones bin]# ./mongod --dbpath /usr/local/mongodb/data/db/ --logpath /usr/local/mongodb/logs/mongodb.log --logappend -fork --bind_ip 0.0.0.0
2018-11-30T13:18:30.190+0000 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
about to fork child process, waiting until server is ready for connections.
forked process: 12750
child process started successfully, parent exiting

9.2 配置文件啓動

# 進入bin目錄
cd /usr/local/mongodb/bin
# 啓動
./mongod -f mongodb.conf

啓動界面

[root@jones bin]# ./mongod -f mongodb.conf
2018-11-30T13:23:22.021+0000 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
about to fork child process, waiting until server is ready for connections.
forked process: 12793
child process started successfully, parent exiting

10 連接 MongoDB數據庫

# 進入bin目錄
cd /usr/local/mongodb/bin
# 連接數據庫
./mongo

連接好的界面

[root@jones bin]# ./mongo
MongoDB shell version v4.0.4
connecting to: mongodb://127.0.0.1:27017
Implicit session: session { "id" : UUID("670f4d3e-528a-4fb1-8027-c812e72a920f") }
MongoDB server version: 4.0.4
Server has startup warnings: 
2018-11-30T13:23:22.039+0000 I STORAGE  [initandlisten] 
2018-11-30T13:23:22.039+0000 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2018-11-30T13:23:22.039+0000 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2018-11-30T13:23:23.537+0000 I CONTROL  [initandlisten] 
2018-11-30T13:23:23.537+0000 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-11-30T13:23:23.537+0000 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2018-11-30T13:23:23.537+0000 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-11-30T13:23:23.537+0000 I CONTROL  [initandlisten] 
2018-11-30T13:23:23.537+0000 I CONTROL  [initandlisten] 
2018-11-30T13:23:23.537+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2018-11-30T13:23:23.537+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2018-11-30T13:23:23.537+0000 I CONTROL  [initandlisten] 
2018-11-30T13:23:23.537+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2018-11-30T13:23:23.537+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2018-11-30T13:23:23.537+0000 I CONTROL  [initandlisten] 
---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).

The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.

To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---

>

10.2 查看所有庫

> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
> 

11. 設置權限

啓動服務時可能會報錯:

about to fork child process, waiting until server is ready for connections.

forked process: 11335

ERROR: child process failed, exited with error number 1

這個錯誤原因是dbpath文件的權限問題,data和logs目錄增加寫權限即可

[root@localhost ~]# chmod 754 /usr/local/mongodb/data/db

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章