下载安装redisx.x.x的源码,以2.8.19为例
$ wget http://download.redis.io/releases/redis-2.8.19.tar.gz $ tar xzf redis-2.8.19.tar.gz $ cd redis-2.8.19 $ make && make install
使用命令src/redis-server 如果显示如下就说明初步安装成功,接下来就自定一下配置
_._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 2.8.19 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in stand alone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 15629 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-'
进入
$ cd utils
执行
$ sudo ./install_server.sh
#以下配置是个人配置,不一定要一样,个人喜欢,全用系统默认的配置也行
Welcome to the redis service installer
This script will help you easily set up a running redis server
Please select the redis port for this instance: [6379] #/redis使用的默认端口
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf] /etc/redis/redis.conf #配置文件
Please select the redis log file name [/var/log/redis_6379.log] /var/log/redis/redis.log #日志文件
Please select the data directory for this instance [/var/lib/redis/6379]
Selected default - /var/lib/redis/6379
Please select the redis executable path [/usr/local/bin/redis-server] #可执行文件
Selected config:
Port : 6379
Config file : /etc/redis/redis.conf
Log file : /var/log/redis/redis.log
Data dir : /var/lib/redis/6379
Executable : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Adding system startup for /etc/init.d/redis_6379 ...
/etc/rc0.d/K20redis_6379 -> ../init.d/redis_6379
/etc/rc1.d/K20redis_6379 -> ../init.d/redis_6379
/etc/rc6.d/K20redis_6379 -> ../init.d/redis_6379
/etc/rc2.d/S20redis_6379 -> ../init.d/redis_6379
/etc/rc3.d/S20redis_6379 -> ../init.d/redis_6379
/etc/rc4.d/S20redis_6379 -> ../init.d/redis_6379
/etc/rc5.d/S20redis_6379 -> ../init.d/redis_6379
Success!
Starting Redis server...
Installation successful!
至此,安装完后,redis就可以如同apt-get install那样方便地使用
启动 $ service redis_6379 start 停止 $ service redis_6379 stop 重启 $ service redis_6379 restart 与redis交互 $ redis-cli找不到hiredis.h的问题:
到/redis-x.x.x/deps/hiredis/ 里面执行make,make install 即可
mongoc.h: No such file or directory 安装mongo:
1、首先安装mongoc
https://github.com/mongodb/mongo-c-driver
$ tar xzf mongo-c-driver-$ver.tar.gz $ cd mongo-c-driver-$ver $ ./configure $ make $ sudo make install
编译mosquitto-auth插件时候报错:
bson.h: No such file or directory
更改Makefile
redis的配置
ifneq ($(BACKEND_REDIS),no)
BACKENDS += -DBE_REDIS
BACKENDSTR += Redis
BE_CFLAGS += -I/usr/local/include/hiredis
BE_LDFLAGS += -L/usr/local/lib
BE_LDADD += -lhiredis
OBJS += be-redis.o
endif
mongodb的配置
ifneq ($(BACKEND_MONGO), no)
BACKENDS+= -DBE_MONGO
BACKENDSTR += MongoDB
BE_CFLAGS += -I/usr/local/include/libmongoc-1.0/
BE_CFLAGS += -I/usr/local/include/libbson-1.0/
BE_LDFLAGS += -L/usr/local/lib
BE_LDADD += -lmongoc-1.0 -lbson-1.0
OBJS += be-mongo.o
MongoDB
1、下面安装MongoDB,先下载:
- cd /usr/src
- wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.4.tgz
2、解压,进入目录:
- tar -zxvf mongodb-linux-x86_64-2.6.4.tgz -C /usr/src
- cd mongodb-linux-x86_64-2.6.4
3、创建数据库和日志的目录:
- mkdir log
- mkdir db
4、以后台运行方式启动:
- ./bin/mongod --dbpath=./db --logpath=./log/mongodb.log --fork --auth
会显示如下内容:
- about to fork child process, waiting until server is ready for connections.
- forked process: 4623
- child process started successfully, parent exiting
5、设置开机启动:
- echo "/usr/src/mongodb-linux-x86_64-2.6.4/bin/mongod --dbpath=/usr/src/mongodb-linux-x86_64-2.6.4/db --logpath=/usr/src/mongodb-linux-x86_64-2.6.4/log/mongodb.log --fork --auth" >> /etc/rc.local
ok,搞定,然后可以参看下端口netstat -nalupt | grep mongo
:
- tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN 4623/./bin/mongod
写在最后:mongodb绝对别用最新的。我用的3.2结果死活不行。换成2.8之后立马就可以了。。。整了好几天。