最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
memcache和mongodb在windows+php环境下安装总结教程
时间:2022-06-24 16:20:15 编辑:袖梨 来源:一聚教程网
mangodb安装
1. 下载mongodb的安装文件,我安装的windows 64位的,下载地址如下:
https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-2.6.6-signed.msi
2. 新建一个mongodb文件夹在E盘(随便放,如E:mongodb)
3. 将下载的安装文件解压,把解压的文件移动到E盘mongodb下
4. 建立mongodb数据存放目录E:mongodbdata
5. 启动mongodb(简单启动不配置服务)
E:mongodbbinmongod.exe --dbpath E:mongodbdata
可以看到如下信息:
说明安装启动成功了。
6. 在浏览器中输入http://localhost:27017/,会出现下面信息,表明mongdb已经启动好了
It looks like you are trying to access MongoDB over HTTP on the native driver port.
7、下载对应的mongodb php插件(不太好找,如果php是5.4-5.5版可用这个地址:http://pan.baidu.com/s/1sjJjsYh)并配置好。
8、在php中使用:
代码如下 | 复制代码 |
try { $mongo = new Mongo('localhost'); } catch(MongoConnectionException $e) { var_dump($e); } $mongo_db = $mongo->selectDB('logdatastorage'); |
注:上面的代码是demo,不可在生产环境中使用。
memcache安装
1、64位下载
From: http://www.urielkatz.com/archive/detail/memcached-64-bit-windows/
下载:http://www.urielkatz.com/projects/memcached-win64/memcached-win64.zip
源码:http://www.urielkatz.com/projects/memcached-win64/memcached-src.rar
2、解压刚刚下载的压缩包,得到两个文件:memcached.exe(服务端主程序)、pthreadGC2.dll
3、以管理员权限运行命令提示符,定位到解压路径,安装Memcached服务,命令:
memcached.exe -d install
4、执行 开始→管理工具→服务 打开Windows服务查看工具,找到memcached服务(没找到证明没有安装成功)
5、启动Memcached:
memcached.exe -m 1024 -d start
-d为守护进程启动,不能指定端口 默认端口11211
-m为指定内存大小
6、配置Windows防火墙,为Memcached默认端口11211 添加入站规则(如果服务端和客户端都在本机,不需要这一步)
7、测试是否可以正常通讯,这里借助Telnet:
telnet 127.0.0.1 11211
如果进入一个空白的doc屏,估计OK了。第一行命令输入是看不见的,所以我一般先敲一次回车,回返回一个Error,没关系,这是说明你输入的是一个无法识别的命令;
接着看下状态,键入stats然后回车:
8、下载对应的memcache php插件(如果php是5.5版可用这个地址:http://pan.baidu.com/s/1mgspf9e)并配置好。
9、在php中连接使用:
$memcache = new Memcache;
$memcache->connect('127.0.0.1', 11211);
Mongodb 安装配置,启动关闭
1. 下载mongodb的安装文件,我安装的windows 32位的,下载地址如下:
http://www.mongodb.org/dr//fastdl.mongodb.org/win32/mongodb-win32-i386-2.6.4.zip/download
2. 新建一个mongodb文件夹在E盘(随便放)
E:mongodb
3. 将下载的文件安装文件解压,把解压的文件移动到E盘mongodb下
4. 建立mongodb数据存放目录E:mongodbdata
5. 启动mongodb(简单启动不配置服务)
E:mongodbbinmongod.exe --dbpath E:mongodbdata
E:mongodbbin>mongod.exe --dbpath E:mongodbdata
2014-09-13T22:18:50.640+0800
2014-09-13T22:18:50.640+0800 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
2014-09-13T22:18:50.640+0800
2014-09-13T22:18:50.765+0800 [initandlisten] MongoDB starting : pid=9204 port=27
017 dbpath=E:mongodbdata 32-bit host=20120621-1418
2014-09-13T22:18:50.765+0800 [initandlisten]
2014-09-13T22:18:50.765+0800 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
2014-09-13T22:18:50.765+0800 [initandlisten] ** 32 bit builds are limitedto less than 2GB of data (or less with --journal).
2014-09-13T22:18:50.765+0800 [initandlisten] ** Note that journaling defaults to off for 32 bit and is currently off.
2014-09-13T22:18:50.765+0800 [initandlisten] ** See http://dochub.mongodb.org/core/32bit
2014-09-13T22:18:50.765+0800 [initandlisten]
2014-09-13T22:18:50.765+0800 [initandlisten] ** NOTE: your operating system version does not support the method that MongoDB
2014-09-13T22:18:50.765+0800 [initandlisten] ** uses to detect impending page faults.
2014-09-13T22:18:50.765+0800 [initandlisten] ** This may result in slowerperformance for certain use cases
2014-09-13T22:18:50.765+0800 [initandlisten]
2014-09-13T22:18:50.765+0800 [initandlisten] targetMinOS: Windows XP SP3
2014-09-13T22:18:50.765+0800 [initandlisten] db version v2.6.4
2014-09-13T22:18:50.765+0800 [initandlisten] git version: 3a830be0eb92d772aa855ebb711ac91d658ee910
2014-09-13T22:18:50.765+0800 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1'BOOST_LIB_VERSION=1_49
2014-09-13T22:18:50.765+0800 [initandlisten] allocator: system
2014-09-13T22:18:50.765+0800 [initandlisten] options: { storage: { dbPath: "E:mongodbdata" } }
在浏览器中输入http://localhost:27017/,会出现表面mongdb已经启动好了
It looks like you are trying to access MongoDB over HTTP on the native driver port.
6. 启动好后连接到mongodb
E:mongodbbinmongo.ext
E:mongodbbin>mongo
MongoDB shell version: 2.6.4
connecting to: test
Welcome 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
Server has startup warnings:
2014-09-13T22:18:50.765+0800 [initandlisten]
2014-09-13T22:18:50.765+0800 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
2014-09-13T22:18:50.765+0800 [initandlisten] ** 32 bit builds are limitedto less than 2GB of data (or less with --journal).
2014-09-13T22:18:50.765+0800 [initandlisten] ** Note that journaling defaults to off for 32 bit and is currently off.
2014-09-13T22:18:50.765+0800 [initandlisten] ** See http://dochub.mongodb.org/core/32bit
2014-09-13T22:18:50.765+0800 [initandlisten]
2014-09-13T22:18:50.765+0800 [initandlisten] ** NOTE: your operating system version does not support the method that MongoDB
2014-09-13T22:18:50.765+0800 [initandlisten] ** uses to detect impending page faults.
2014-09-13T22:18:50.765+0800 [initandlisten] ** This may result in slowerperformance for certain use cases
2014-09-13T22:18:50.765+0800 [initandlisten]
>
Mongodb的关闭:
前台运行:
如果没有使用--fork,直接可以前台退出终端关闭。通过这种方式,Mongodb将会自己做清理退出,把没有写好的数据写完成,并最终关闭数据文件。要注意的是这个过程会持续到所有操作都完成。
后台运行:
如果使用--fork在后台运行mongdb服务,那么就要通过向服务器发送shutdownServer()消息来关闭。
1、普通命令:
$ ./mongod
> use admin
> db.shutdownServer()
> db.shutdownServer()
2014-09-13T22:25:07.843+0800 DBClientCursor::init call() failed
server should be down...
2014-09-13T22:25:07.890+0800 trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed
2014-09-13T22:25:08.890+0800 warning: Failed to connect to 127.0.0.1:27017, reas
on: errno:10061由于目标机器积极拒绝,无法连接。
2014-09-13T22:25:08.890+0800 reconnect 127.0.0.1:27017 (127.0.0.1) failed failed
couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
>
控制台显示如下:
2014-09-13T22:25:07.625+0800 [conn1] terminating, shutdown command received
2014-09-13T22:25:07.625+0800 [conn1] dbexit: shutdown called
2014-09-13T22:25:07.625+0800 [conn1] shutdown: going to close listening sockets.
..
2014-09-13T22:25:07.625+0800 [conn1] closing listening socket: 1632
2014-09-13T22:25:07.625+0800 [conn1] shutdown: going to flush diaglog...
2014-09-13T22:25:07.625+0800 [conn1] shutdown: going to close sockets...
2014-09-13T22:25:07.625+0800 [conn1] shutdown: waiting for fs preallocator...
2014-09-13T22:25:07.625+0800 [conn1] shutdown: closing all files...
2014-09-13T22:25:07.625+0800 [conn1] closeAllFiles() finished
2014-09-13T22:25:07.625+0800 [conn1] shutdown: removing fs lock...
2014-09-13T22:25:07.625+0800 [conn1] dbexit: really exiting now
E:mongodbbin>
关闭成功
Mongodb启动帮助
E:mongodbbin>mongod --help
Options:
General options:
-h [ --help ] show this usage information
--version show version information
-f [ --config ] arg configuration file specifying additional options
-v [ --verbose ] [=arg(=v)] be more verbose (include multiple times for more
verbosity e.g. -vvvvv)
--quiet quieter output
--port arg specify port number - 27017 by default
--bind_ip arg comma separated list of ip addresses to listen on
- all local ips by default
--maxConns arg max number of simultaneous connections - 1000000
by default
--logpath arg log file to send write to instead of stdout - has
to be a file, not directory
--logappend append to logpath instead of over-writing
--timeStampFormat arg Desired format for timestamps in log messages.
One of ctime, iso8601-utc or iso8601-local
--pidfilepath arg full path to pidfile (if not set, no pidfile is
created)
--keyFile arg private key for cluster authentication
--setParameter arg Set a configurable parameter
--httpinterface enable http interface
--clusterAuthMode arg Authentication mode used for cluster
authentication. Alternatives are
(keyFile|sendKeyFile|sendX509|x509)
--auth run with security
--noauth run without security
--ipv6 enable IPv6 support (disabled by default)
--jsonp allow JSONP access via http (has security
implications)
--rest turn on simple rest api
--slowms arg (=100) value of slow for profile and console log
--profile arg 0=off 1=slow, 2=all
--cpu periodically show cpu and iowait utilization
--sysinfo print some diagnostic system information
--dbpath arg directory for datafiles - defaults to datadb
--directoryperdb each database will be stored in a separate
directory
--noIndexBuildRetry don't retry any index builds that were
interrupted by shutdown
--noprealloc disable data file preallocation - will often hurt
performance
--nssize arg (=16) .ns file size (in MB) for new databases
--quota limits each database to a certain number of files
(8 default)
--quotaFiles arg number of files allowed per db, implies --quota
--smallfiles use a smaller default file size
--syncdelay arg (=60) seconds between disk syncs (0=never, but not
recommended)
--upgrade upgrade db if needed
--repair run repair on all dbs
--repairpath arg root directory for repair files - defaults to
dbpath
--noscripting disable scripting engine
--notablescan do not allow table scans
--journal enable journaling
--nojournal disable journaling (journaling is on by default
for 64 bit)
--journalOptions arg journal diagnostic options
--journalCommitInterval arg how often to group/batch commit (ms)
Windows Service Control Manager options:
--install install Windows service
--remove remove Windows service
--reinstall reinstall Windows service (equivalent to --remove
followed by --install)
--serviceName arg Windows service name
--serviceDisplayName arg Windows service display name
--serviceDescription arg Windows service description
--serviceUser arg account for service execution
--servicePassword arg password used to authenticate serviceUser
Replication options:
--oplogSize arg size to use (in MB) for replication op log. default is
5% of disk space (i.e. large is good)
Master/slave options (old; use replica sets instead):
--master master mode
--slave slave mode
--source arg when slave: specify master as
--only arg when slave: specify a single database to replicate
--slavedelay arg specify delay (in seconds) to be used when applying
master ops to slave
--autoresync automatically resync if slave data is stale
Replica set options:
--replSet arg arg is
--replIndexPrefetch arg specify index prefetching behavior (if secondary)
[none|_id_only|all]
Sharding options:
--configsvr declare this is a config db of a cluster; default port 27019; default dir /data/configdb
--shardsvr declare this is a shard db of a cluster; default port 27018
下面通过构造一个conf文件进行启动
文件内容如下mongodb.conf
dbpath=E:mongodbdata
logpath=E:mongodblog
logappend=true
bind_ip=127.0.0.1
port=27019
fork=true
master=true
启动:
E:mongodbbin>mongod --config E:mongodbmongodb.conf
2014-09-13T22:39:31.296+0800
2014-09-13T22:39:31.296+0800 warning: 32-bit servers don't have journaling enabl
ed by default. Please use --journal if you want durability.
2014-09-13T22:39:31.296+0800
连接mongodb报错,原因我启动时指定端口号了,不是默认的27017了,所以报错
E:mongodbbin>mongo
MongoDB shell version: 2.6.4
connecting to: test
2014-09-13T22:50:24.296+0800 warning: Failed to connect to 127.0.0.1:27017, rea
on: errno:10061由于目标机器积极拒绝,无法连接。
2014-09-13T22:50:24.312+0800 Error: couldn't connect to server 127.0.0.1:27017
127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed
指定端口号连接:
E:mongodbbin>mongo 127.0.0.1:27019
MongoDB shell version: 2.6.4
connecting to: 127.0.0.1:27019/test
Server has startup warnings:
2014-09-13T22:50:13.593+0800 [initandlisten]
2014-09-13T22:50:13.593+0800 [initandlisten] ** NOTE: This is a 32 bit MongoDB b
inary.
2014-09-13T22:50:13.593+0800 [initandlisten] ** 32 bit builds are limited
to less than 2GB of data (or less with --journal).
2014-09-13T22:50:13.593+0800 [initandlisten] ** Note that journaling defaults to off for 32 bit and is currently off.
2014-09-13T22:50:13.593+0800 [initandlisten] ** See http://dochub.mongodb.org/core/32bit
2014-09-13T22:50:13.593+0800 [initandlisten]
2014-09-13T22:50:13.593+0800 [initandlisten] ** NOTE: your operating system version does not support the method that MongoDB
2014-09-13T22:50:13.593+0800 [initandlisten] ** uses to detect impending page faults.
2014-09-13T22:50:13.593+0800 [initandlisten] ** This may result in slowerperformance for certain use cases
2014-09-13T22:50:13.593+0800 [initandlisten]
>
相关文章
- 王者荣耀S38赛季有什么更新 12-25
- 王者荣耀S38赛季有什么更新 王者荣耀S38赛季更新内容介绍 12-25
- 世界之外12.25有什么更新 世界之外12月25日更新内容介绍 12-25
- 光遇12.25红石碎片在哪里 光遇12月25日红石碎片位置攻略 12-25
- 奇迹暖暖绚光引途第二天怎么玩 绚光引途day2庆祝之舞搭配攻略 12-25
- 无限暖暖拍照打卡位置在哪里 无限暖暖世界巡游位置全攻略 12-25