千家信息网

mongodb-2.0.5的安装与启动

发表于:2025-01-20 作者:千家信息网编辑
千家信息网最后更新 2025年01月20日,Mongodb2.0.5版本安装一:安装PythonVersion:Python2.6http://www.python.org/ftp/python/tar zxvf Python-2.6.6.tg
千家信息网最后更新 2025年01月20日mongodb-2.0.5的安装与启动

Mongodb2.0.5版本安装

  1. 一:安装Python
  2. Version:Python2.6
  3. http://www.python.org/ftp/python/
  4. tar zxvf Python-2.6.6.tgz
  5. ./configure --enable-shared
  6. make
  7. sudo make instal
  8. cat /etc/ld.so.conf
  9. 在/etc/ld.so.conf 中添加 /usr/local/lib一行
  10. sudo ldconfig
  1. 二:Scons安装
  2. $ tar zxvf scons-2.0.1.tar.gz
  3. $ sudo python setup.py install
  4. sudo vim /usr/bin/scons 或者 vim /usr/local/bin/scons
  5. 修改内容如下
  6. #!/usr/bin/env python2.6
  1. sudo yum -y install boost-devel pcre-devel js-devel readline-devel ncurses-devel
  1. 三:Spider Monkey安装
  2. Version:js-1.7.0
  3. $ wget http://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz
  4. $ cd /home/webuser/software/mongodb/js/src
  5. $ export CFLAGS="-DJS_C_STRINGS_ARE_UTF8"
  6. $ make -f Makefile.ref
  7. $ sudo JS_DIST=/usr make -f Makefile.ref export
  1. sudo yum remove boost*i386 //卸载32位程序包 rpm -qa查看状态
  2. sudo yum remove pcre*i386 boost*i386 ncurses*i386 readline*i386
  3. sudo yum remove ncurses*i386
  4. sudo yum remove readline*i386
  5. ---------------------------------------------
  6. sudo yum remove pcre-devel //卸载64位开发包
  7. sudo yum remove boost-devel
  8. sudo yum remove ncurses-devel pcre-devel boost-devel readline-devel
  9. sudo yum remove readline-devel
  10. --------------------------------------------
  11. sudo yum install pcre-devel*x86* //安装64位开发包
  12. sudo yum install boost-devel*x86*
  13. sudo yum install ncurses-devel*x86* pcre-devel*x86* boost-devel*x86* readline-devel*x86*
  14. sudo yum install readline-devel*x86*
  15. ---------------------------------------------
  16. sudo ldconfig
  17. ---------------------------------------------
  1. 四:Boost安装
  2. 下载 boost_1_48_0.tar.gz源码包
  3. tar zxvf boost_1_48_0.tar.gz
  4. cd boost_1_48_0/
  5. ./bootstrap.sh
  6. 在当前目录下会生成b2的编译文件,然后执行
  7. ./b2
  8. 编译成功会出现如下:
  9. the boost C++ Libraries were successfull built
  10. the following directory should be added to compiler include paths:
  11. ...................
  12. the following directory should be added to linker library paths:
  13. sudo cp -R boost/ /usr/include ----注意一定要拷贝完 -安装的时候复制粘贴吧,避免出错!
  14. sudo cp stage/lib/* /usr/lib/
  15. sudo ldconfig
  1. 五:Mongodb的安装
  2. tar zxvf mongodb-src-r2.0.5.tar.gz
  3. scons --64 --extrapath=/usr --libpath=/usr/lib64 --full --release --static all
  4. scons --prefix=/opt/mongodb --64 --extrapath=/usr --libpath=/usr/lib64 --full --release --static install
  1. mkdir /opt/mongodb/{etc,log,repair,data}
  2. cd /opt/mongodb/etc/
  1. 六:Mongodb配置文件
  2. dbpath = /opt/mongodb/data
  3. #repairpath = /opt/mongodb/repair 仅当Mongodb数据库有问题需要修复时使用
  4. logpath = /opt/mongodb/log/mongodb.log
  5. pidfilepath = /opt/mongodb/log/mongodb.pid
  6. unixSocketPrefix = /opt/mongodb/log
  7. directoryperdb = true
  8. auth = true
  9. #sysinfo = true
  10. #verbose = true
  11. logappend = true
  12. #cpu = true
  13. #Network and security set
  14. noauth = true
  15. port = 33111
  16. maxConns = 1024
  17. fork = true
  18. #Management
  19. #nohttpinterface = true
  20. rest = true
  21. quota = true
  22. quotaFiles = 1024
  23. nssize = 16
  24. #syncdelay = 5
  

最后:service mongod start 启动mongod 服务

    netstat 查看
  1. 七:配置Mongodb启动
  2. vim /etc/init.d/mongod
  3. chmod u+x /etc/init.d/mongod
  4. chkconfig --add mongod
  1. 附上mongodb启动脚本:
  2. #!/bin/bash
  3. #&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  4. #Author:gaohaicang &
  5. #Company: dzh &
  6. #Date:2013-1-15 &
  7. #Version:1 &
  8. #&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  9. # description: mongodb server SysV script
  10. . /etc/rc.d/init.d/functions
  11. # Source networking configuration.
  12. . /etc/sysconfig/network
  13. #Set PATH ENV
  14. PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
  15. #Set mongod
  16. mongod=/opt/mongodb/bin/mongod
  17. prog=mongod
  18. lockfile=/opt/mongodb/data/db/mongod.lock
  19. pidfile=/opt/mongodb/log/mongodb.pid
  20. # config: /opt/mongod/etc/mongod
  21. RETVAL=0
  22. OPTIONS="--fork --logpath=/opt/mongodb/log/mongod.log --config /opt/mongodb/etc/mongodb"
  23. start()
  24. {
  25. echo -n $"Starting $prog: "
  26. daemon $mongod $OPTIONS
  27. daemon $mongd
  28. RETVAL=$?
  29. echo
  30. [ $RETVAL = 0 ]
  31. return $RETVAL
  32. }
  33. stop()
  34. {
  35. MONGOPID=`cat "$pidfile" 2>/dev/null `
  36. if [ -n "$MONGOPID" ]; then
  37. /bin/kill "$MONGOPID" >/dev/null 2>&1
  38. ret=$?
  39. if [ $ret -eq 0 ]; then
  40. STOPTIMEOUT=60
  41. while [ $STOPTIMEOUT -gt 0 ]; do
  42. /bin/kill -0 "$MONGOPID" >/dev/null 2>&1 || break
  43. sleep 1
  44. let STOPTIMEOUT=${STOPTIMEOUT}-1
  45. done
  46. if [ $STOPTIMEOUT -eq 0 ]; then
  47. echo "Timeout error occurred trying to stop Mongod Daemon."
  48. ret=1
  49. action $"Stopping $prog: " /bin/false
  50. else
  51. rm -f /opt/mongod/data/mongod.lock
  52. action $"Stopping $prog: " /bin/true
  53. fi
  54. else
  55. action $"Stopping $prog: " /bin/false
  56. fi
  57. else
  58. ret=1
  59. action $"Stopping $prog: " /bin/false
  60. fi
  61. return $ret
  62. }
  63. status()
  64. {
  65. echo -n $"$prog status is "
  66. netstat -tnlp|grep "$prog" >/dev/null
  67. RETVAL=$?
  68. if [ $RETVAL -eq 0 ];then
  69. echo -e "\033[32m running \033[0m"
  70. else
  71. echo -e "\033[31m stop \033[0m"
  72. fi
  73. }
  74. case "$1" in
  75. start)
  76. start ;;
  77. stop)
  78. stop ;;
  79. restart)
  80. stop
  81. start ;;
  82. status)
  83. status -p ${lockfile} $mongod
  84. RETVAL=$? ;;
  85. *)
  86. echo $"Usage: $prog {start|stop|restart|status|}"
  87. exit 1
  88. esac
0