文章目录
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