首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过numactl作为守护进程启动mongodb

通过numactl作为守护进程启动mongodb
EN

Stack Overflow用户
提问于 2012-06-23 01:32:32
回答 5查看 9.3K关注 0票数 5

我正在尝试让mongodb在NUMA机器上作为守护进程启动。当我跑的时候

代码语言:javascript
复制
numactl --interleave=all mongod &

Mongo启动并正常运行,但所有输出仍然显示。(例如,Fri Jun 22 12:10:29初始化并从127.0.1.1:51837接受侦听连接)

然而,当我自己启动mongo时(如下所示),它失败了(日志如下):

代码语言:javascript
复制
service mongodb start

我在日志中得到了以下内容

代码语言:javascript
复制
Fri Jun 22 12:08:41 [initandlisten] MongoDB starting : pid=3348 port=27017 dbpath=/var/lib/mongodb 64-bit host=beckett
Fri Jun 22 12:08:41 [initandlisten]
Fri Jun 22 12:08:41 [initandlisten] ** WARNING: You are running on a NUMA machine.
Fri Jun 22 12:08:41 [initandlisten] **          We suggest launching mongod like this to avoid performance problems:
Fri Jun 22 12:08:41 [initandlisten] **              numactl --interleave=all mongod [other options]
Fri Jun 22 12:08:41 [initandlisten]
Fri Jun 22 12:08:41 [initandlisten] db version v2.0.6, pdfile version 4.5
Fri Jun 22 12:08:41 [initandlisten] git version: e1c0cbc25863f6356aa4e31375add7bb49fb05bc
Fri Jun 22 12:08:41 [initandlisten] build info: Linux ip-10-110-9-236 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_41
Fri Jun 22 12:08:41 [initandlisten] options: { auth: "true", command: [ "run" ], config: "/etc/mongodb.conf", dbpath: "/var/lib/mongodb", logappend: "true", logpath: "/var/log/mongodb/mongodb.log" }
Fri Jun 22 12:08:41 [initandlisten] journal dir=/var/lib/mongodb/journal
Fri Jun 22 12:08:41 [initandlisten] recover : no journal files present, no recovery needed
Fri Jun 22 12:08:42 [initandlisten] couldn't open /var/lib/mongodb/admin.ns errno:13 Permission denied
Fri Jun 22 12:08:42 [initandlisten] error couldn't open file /var/lib/mongodb/admin.ns terminating
Fri Jun 22 12:08:42 dbexit:
Fri Jun 22 12:08:42 [initandlisten] shutdown: going to close listening sockets...
Fri Jun 22 12:08:42 [initandlisten] shutdown: going to flush diaglog...
Fri Jun 22 12:08:42 [initandlisten] shutdown: going to close sockets...
Fri Jun 22 12:08:42 [initandlisten] shutdown: waiting for fs preallocator...
Fri Jun 22 12:08:42 [initandlisten] shutdown: lock for final commit...
Fri Jun 22 12:08:42 [initandlisten] shutdown: final commit...
Fri Jun 22 12:08:42 [initandlisten] shutdown: closing all files...
Fri Jun 22 12:08:42 [initandlisten] closeAllFiles() finished
Fri Jun 22 12:08:42 [initandlisten] journalCleanup...
Fri Jun 22 12:08:42 [initandlisten] removeJournalFiles
Fri Jun 22 12:08:42 [initandlisten] shutdown: removing fs lock...
Fri Jun 22 12:08:42 dbexit: really exiting now

我不知道当我以超级用户身份运行时,admin.ns怎么会有权限问题,也不知道为什么当包装在numactl中时,它可以正常启动。理想情况下,我希望在start_server()函数中使用numactl,如下所示:

代码语言:javascript
复制
start_server(){
    /usr/bin/numactl --interleave=all -- \
    start-stop-daemon --background --start --quiet --pidfile $PIDFILE \
        --make-pidfile --chuid $DAEMONUSER \
        --exec $DAEMON -- $DAEMON_OPTS
    errcode=$?
    return $errcode
}

归根结底,如何让mongo在NUMA机器上作为守护进程启动?

EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2012-06-27 03:06:18

事实证明,我的问题是numa和权限问题的组合。谢谢你,@Mark帮我的忙。要在NUMA设置上作为守护进程启动mongodb,请将/etc/init.d/mongodb中的start_server()函数替换为以下内容:

代码语言:javascript
复制
start_server() {
# check for numactl
NUMACTL=$(which numactl)
if [ -n "$NUMACTL" ]; then
    DAEMON_OPTS="--interleave=all ${DAEMON} ${DAEMON_OPTS}"
    DAEMON="$NUMACTL"
fi

# Start the process using the wrapper
            /usr/bin/numactl --interleave=all -- \
            start-stop-daemon --background --start --quiet --pidfile $PIDFILE \
                        --make-pidfile --chuid $DAEMONUSER \
                        --exec $DAEMON -- $DAEMON_OPTS
            errcode=$?
        return $errcode
}
票数 5
EN

Stack Overflow用户

发布于 2012-06-25 20:54:12

我假设你知道'mongo & numa‘的常见警告(http://www.mongodb.org/display/DOCS/NUMA),所以我就不再赘述了。

下面是一个使用numa - https://gist.github.com/1364716的mongodb的示例upstart配置文件。

基于此Google Group thread,将以下行添加到初始化脚本中的start_server函数中,并且成功了:

代码语言:javascript
复制
start_server() { 
# check for numactl 
NUMACTL=$(which numactl) 
if [ -n "$NUMACTL" ]; then 
    DAEMON_OPTS="--interleave=all ${DAEMON} ${DAEMON_OPTS}" 
    DAEMON="$NUMACTL" 
fi 

# Start the process using the wrapper 
票数 3
EN

Stack Overflow用户

发布于 2016-10-28 20:07:28

对于ubuntu 16.04

代码语言:javascript
复制
[Unit]
Description=High-performance, schema-free document-oriented database
After=time-sync.target network.target

[Service]
Type=forking
User=mongod
Group=mongod
LimitNOFILE=65000
PermissionsStartOnly=true
EnvironmentFile=/etc/default/mongod
ExecStartPre=/usr/bin/percona-server-mongodb-helper.sh
ExecStart=/usr/bin/env bash -c "numactl --interleave=all /usr/bin/mongod $OPTIONS > ${STDOUT} 2> ${STDERR}"
#ExecStart=/usr/bin/env bash -c "/usr/bin/mongod $OPTIONS > ${STDOUT} 2> ${STDERR}"
PIDFile=/var/run/mongod.pid

[Install]
WantedBy=multi-user.target
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11161308

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档