linux mongo 64位安装
Linux  /  houtizong 发布于 3年前   114
本文章介绍mongodb64位的安装
[root@test ~]# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.4.12.tgz?_ga=1.193844461.1950324063.1413874126[root@test ~]# tar -zxvf mongodb-linux-x86_64-2.4.12.tgz -C /usr/local[root@test ~]# mv /usr/local/mongodb-linux-x86_64-2.4.12 /usr/local/mongodb
修改mongo.conf
port = 27017 #默认27017 端口号dbpath = /usr/local/mongodb/var/data/ #数据库路径logpath = /usr/local/mongodb/var/log/mongodb.log #日志输出文件路径pidfilepath = /usr/local/mongodb/var/run/mongo.pidfork = true #设置后台运行journal = truelogappend = true #日志输出方式auth = true #开启认证
添加/etc/init.d/mongo
#! /bin/sh##chkconfig: 2345 80 90#description: mongodbstart(){ echo "start mongodb..." /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongodb.conf}stop(){ /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongodb.conf --shutdown echo "stop mongodb"}case "$1" instart) start ;;stop) stop ;;restart) stop start ;;*) echo "usage: $0 start|stop|restart" exit 0;esac
开机启动
[root@test mongodb]# chkconfig --add mongo[root@test mongodb]# chkconfig --level 2345 mongo on[root@test mongodb]# chkconfig --list mongo
修改iptables
[root@jiaomai jiaoMai]# netstat -apnl | grep mongotcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN 6531/mongodtcp 0 0 0.0.0.0:28017 0.0.0.0:* LISTEN 6531/mongodunix 2 [ ACC ] STREAM LISTENING 19626 6531/mongod /tmp/mongodb-27017.sock[root@jiaomai jiaoMai]# vim /etc/sysconfig/iptables-A INPUT -m state --state NEW -m tcp -p tcp --dport 27017 -j ACCEPT #添加这一行
启动mongodb
[root@jiaomai /]# /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongo.confabout to fork child process, waiting until server is ready for connections.forked process: 6382all output going to: /var/log/mongodb/mongodb.logchild process started successfully, parent exiting
添加用户
[root@jiaomai /]# cd /usr/local/mongodb/[root@jiaomai mongodb]# bin/mongoMongoDB shell version: 2.4.12connecting to: testWelcome to the MongoDB shell.For interactive help, type "help".For more comprehensive documentation, see http://docs.mongodb.org/Questions? Try the support group http://groups.google.com/group/mongodb-user> use adminswitched to db admin> show dbsadmin (empty)local 0.078125GB> show collections> db.addUser('admin', 'admin'){ "user" : "admin", "readOnly" : false, "pwd" : "90429ba3167e4110d836c66086d037e3", "_id" : ObjectId("54461ebba5420047ba02e191")}> exit
PHP扩展
介绍地址 https://github.com/mongodb/mongo-php-driver
[root@test ~]# wget https://github.com/mongodb/mongo-php-driver/archive/master.zip[root@test ~]# mv master php-mongo.zip[root@test ~]# unzip php-mongo.zip[root@test ~]# cd mongo-php-driver-master[root@test mongo-php-driver-master]# /usr/local/php/bin/phpize[root@test mongo-php-driver-master]# ./configure --with-php-config=/usr/local/php/bin/php-config[root@test mongo-php-driver-master]# make[root@test mongo-php-driver-master]# make installInstalling shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/[root@test mongo-php-driver-master]# cd /usr/local/php[root@test php]# cp -p lib/php/extensions/no-debug-non-zts-20090626/mongo.so ext/[root@test php]# vim etc/php.ini添加一行 extension=mongo.so[root@test php]# kill -USR2 `cat var/run/php-fpm.pid` #PHP重启[root@test php]# /usr/local/nginx/sbin/nginx -s reload #nginx重启
请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!
技术博客集 - 网站简介:
前后端技术:
后端基于Hyperf2.1框架开发,前端使用Bootstrap可视化布局系统生成
网站主要作用:
1.编程技术分享及讨论交流,内置聊天系统;
2.测试交流框架问题,比如:Hyperf、Laravel、TP、beego;
3.本站数据是基于大数据采集等爬虫技术为基础助力分享知识,如有侵权请发邮件到站长邮箱,站长会尽快处理;
4.站长邮箱:[email protected];
文章归档
文章标签
友情链接