2. Linux下安装redis以及简单管理
来源:互联网 发布:mac阻止打开文件 编辑:程序博客网 时间:2024/06/05 23:48
安装Redis
- 下载redis安装包
http://download.redis.io/releases/redis-3.2.8.tar.gz
- 将压缩包拷贝到/opt目录下并且解压缩
[root@hm707 redis-3.2.8]# tar -zxvf redis-3.2.8.tar.gz
- 进入到解压缩后的目录中,执行
make
命令
注意:执行make
时需要有gcc环境,如果没有需要提前安装
[root@hm707 redis-3.2.8]# yum install gcc-c++ -y
再次执行make
时还是会报错,错误如下
[root@hm707 redis-3.2.8]# makecd src && make allmake[1]: Entering directory `/opt/redis-3.2.8/src' CC adlist.oIn file included from adlist.c:34:zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directoryzmalloc.h:55:2: error: #error "Newer version of jemalloc required"make[1]: *** [adlist.o] Error 1make[1]: Leaving directory `/opt/redis-3.2.8/src'make: *** [all] Error 2
该错误是因为之前在没有gcc环境时执行make命令后生成了一些文件目录导致的,只需要执行make distclean
之后在执行make
- 最后执行
make install
[root@hm707 redis-3.2.8]# make installcd src && make installmake[1]: Entering directory `/opt/redis-3.2.8/src'Hint: It's a good idea to run 'make test' ;) INSTALL install INSTALL install INSTALL install INSTALL install INSTALL install
简单管理
- 目录的简单说明
安装完成后的可执行文件在/usr/local/bin
目录下
[root@hm707 redis-3.2.8]# cd /usr/local/bin[root@hm707 bin]# lltotal 26348-rwxr-xr-x. 1 root root 5580327 Apr 27 23:09 redis-benchmark-rwxr-xr-x. 1 root root 22217 Apr 27 23:09 redis-check-aof-rwxr-xr-x. 1 root root 7829986 Apr 27 23:09 redis-check-rdb-rwxr-xr-x. 1 root root 5709187 Apr 27 23:09 redis-clilrwxrwxrwx. 1 root root 12 Apr 27 23:09 redis-sentinel -> redis-server-rwxr-xr-x. 1 root root 7829986 Apr 27 23:09 redis-server
修改配置文件,让redis可以后台启动
[root@hm707 bin]# pwd/opt/redis-3.2.8[root@hm707 bin]# mkdir /myredis[root@hm707 bin]# cp redis.conf /myredis/[root@hm707 bin]# vim /myredis/redis.conf
daemonize改为yes
################################# GENERAL ###################################### By default Redis does not run as a daemon. Use 'yes' if you need it.# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.daemonize yes
启动redis服务
[root@hm707 bin]# pwd/usr/local/bin[root@hm707 bin]# redis-server /myredis/redis.conf[root@hm707 bin]# ps -ef | grep redisroot 6048 1 0 23:26 ? 00:00:00 redis-server 127.0.0.1:6379 root 6054 2438 0 23:27 pts/1 00:00:00 grep redis
使用redis-cli -p 6379
连接redis服务. SHUTDOWN
关闭服务
[root@hm707 bin]# pwd/usr/local/bin[root@hm707 bin]# redis-cli -p 6379127.0.0.1:6379> pingPONG127.0.0.1:6379> set k1 helloOK127.0.0.1:6379> get k1"hello"127.0.0.1:6379> SHUTDOWNnot connected> exit[root@hm707 bin]# ps -ef|grep redisroot 6075 2438 0 23:31 pts/1 00:00:00 grep redis
使用Redis-benchmark
测试redis性能
下面是简单的例子,具体参考 http://www.redis.cn/topics/benchmarks.html
Usage: redis-benchmark [-h <host>] [-p <port>] [-c <clients>] [-n <requests]> [-k <boolean>] -h <hostname> Server hostname (default 127.0.0.1) -p <port> Server port (default 6379) -s <socket> Server socket (overrides host and port) -c <clients> Number of parallel connections (default 50) -n <requests> Total number of requests (default 10000) -d <size> Data size of SET/GET value in bytes (default 2) -k <boolean> 1=keep alive 0=reconnect (default 1) -r <keyspacelen> Use random keys for SET/GET/INCR, random values for SADD Using this option the benchmark will get/set keys in the form mykey_rand:000000012456 instead of constant keys, the <keyspacelen> argument determines the max number of values for the random number. For instance if set to 10 only rand:000000000000 - rand:000000000009 range will be allowed. -P <numreq> Pipeline <numreq> requests. Default 1 (no pipeline). -q Quiet. Just show query/sec values 只显示每秒钟能处理多少请求数结果 --csv Output in CSV format -l Loop. Run the tests forever 永久测试 -t <tests> Only run the comma separated list of tests. The test names are the same as the ones produced as output. -I Idle mode. Just open N idle connections and wait.
//SET/GET 100 bytes 检测host为127.0.0.1 端口为6379的redis服务器性能redis-benchmark -h 127.0.0.1 -p 6379 -q -d 100 //5000个并发连接,100000个请求,检测host为127.0.0.1 端口为6379的redis服务器性能 redis-benchmark -h 127.0.0.1 -p 6379 -c 5000 -n 100000
0 0
- 2. Linux下安装redis以及简单管理
- windows/linux下安装redis以及用java简单操作redis
- Linux下redis的安装以及使用
- Linux下Redis 安装与简单配置
- linux 下安装redis以及php Redis扩展
- Linux下redis 的安装以及C++操作redis
- php使用redis扩展以及安装redis(linux下)
- Linux下进行Redis安装以及一些redis配置
- linux 下安装redis以及php Redis扩展
- Linux 简单安装redis
- Redis简介以及Linux环境下的安装与部署
- linux下redis安装以及处理一些常见问题
- linux下redis部署以及phpredis的安装
- Linux下安装Redis以及配置远端访问
- linux下的redis扩展安装以及使用
- Redis--Linux下安装Redis
- linux下redis安装
- linux下安装redis
- 输入URL到显示页面发生了什么
- js jq失焦事件和聚焦事件,简单的正则表达式
- 给vs2012添加glut库
- 严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderLis
- ios 静态库冲突的解决办法
- 2. Linux下安装redis以及简单管理
- 【WLAN从入门到精通-基础篇】第3期——WLAN标准协议
- poj 1644 概率dp
- EffectiveJava第二章
- 微信小程序支付功能 C# .NET开发
- eclipse快捷
- php获取各种时间戳
- Android获取图片的宽度和高度
- YII2.0框架(二) 模型类参考yii\base\Model