您好,欢迎访问一九零五行业门户网

CentOS 6.5下Redis安装测试

nosql之redis - centos 6.5安装测试 1.下载redis 可以在线安装或者下载 redis ①在线安装前需要检测是否存在rpm包不存在的话查看
nosql之redis - centos 6.5安装测试
1.下载redis
可以在线安装或者下载 redis
①在线安装前需要检测是否存在rpm包不存在的话查看yum在线是否存在rpm包不存在的话就只能手动下载或者用别的方式下载
[root@localhost ~]# rpm -qa|grep redis
[root@localhost ~]# yum list|grep redis
说明不存在。
②去官网下载或者在线下载
wget
官网下载好的 redis 已经存在博客中了点击下载 redis。
2.安装
由于是tar.gz格式的所以需要解压安装
下载好之后查找下载文件所在路径
[root@localhost ~]# whereis redis
redis: /etc/redis
[root@localhost ~]#
解压编译redis的软件包需要有gcc环境
总之缺少什么安装什么。
tar -zxvf reids-2.8.13.tar.gz
cd redis-2.8.13
make
sudo make install
#配置开始---
编译完成后在src目录下有四个可执行文件redis-server、redis-benchmark、redis-cli和redis.conf。然后拷贝到一个目录下。
mkdir /usr/redis
cp redis-server  /usr/redis
cp redis-benchmark /usr/redis
cp redis-cli  /usr/redis
cp redis.conf  /usr/redis
cd /usr/redis
#配置结束--
或者可以这样配置
mkdir /etc/redis
cp redis.conf /etc/redis/redis.conf
mkdir  /var/lib/redis
可从此处下载修改好的 redis.conf
启动redis
redis-server /etc/redis/redis.conf
#即可在后台启动redis服务确认运行了之后可以用redis-benchmark命令测试看看还可以通过redis-cli命令实际操作一下比如
#install的时候redis的命令会被拷贝到/usr/local/bin下面
3.测试
客户端测试一下是否启动成功
[root@localhost src]# ps -aux|grep redis
warning: bad syntax, perhaps a bogus '-'? see /usr/share/doc/procps-3.2.8/faq
root    23266  0.0  0.7 137356  7768 ?        sl  00:23  0:04 redis-server *:6379
root    23982  0.0  0.5  19404  5100 pts/0    s+  01:09  0:00 redis-cli
root    24398  0.0  0.0 103244  876 pts/2    s+  01:44  0:00 grep redis
[root@localhost src]# redis-cli
127.0.0.1:6379> set w wang
ok
127.0.0.1:6379> get w
wang
127.0.0.1:6379>
4.关闭服务
redis-cli shutdown
如果端口变化可以指定端口:
redis-cli -p 6379 shutdown
127.0.0.1:6379> i+j
could not connect to redis at 127.0.0.1:6379: connection refused
not connected> set w 3
could not connect to redis at 127.0.0.1:6379: connection refused
not connected>
5.启动服务
[root@localhost src]# redis-server
[24502] 28 oct 01:54:35.784 # warning: no config file specified, using the default config. in order to specify a config file use redis-server /path/to/redis.conf
[24502] 28 oct 01:54:35.784 * increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                 
          _.-``__ ''-._                                           
      _.-``    `.  `_.  ''-._          redis 2.8.13 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                 
 (    '      ,      .-`  | `,    )    running in stand alone mode
 |`-._`-...-` __...-.``-._|'` _.-'|    port: 6379
 |    `-._  `._    /    _.-'    |    pid: 24502
  `-._    `-._  `-./  _.-'    _.-'                                 
 |`-._`-._    `-.__.-'    _.-'_.-'|                                 
 |    `-._`-._        _.-'_.-'    |                 
  `-._    `-._`-.__.-'_.-'    _.-'                                 
 |`-._`-._    `-.__.-'    _.-'_.-'|                                 
 |    `-._`-._        _.-'_.-'    |                                 
  `-._    `-._`-.__.-'_.-'    _.-'                                 
      `-._    `-.__.-'    _.-'                                     
          `-._        _.-'                                         
              `-.__.-'                                             
[24502] 28 oct 01:54:35.786 # server started, redis version 2.8.13
[24502] 28 oct 01:54:35.786 # warning overcommit_memory is set to 0! background save may fail under low memory condition. to fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
[24502] 28 oct 01:54:35.786 * db loaded from disk: 0.000 seconds
[24502] 28 oct 01:54:35.786 * the server is now ready to accept connections on port 6379
启动之后最好重新打开个窗口运行redsi-cli进入控制台
其它类似信息

推荐信息