我是靠谱客的博主 勤劳诺言,最近开发中收集的这篇文章主要介绍redis环境部署,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

【centos6.5】

环境准备:

master-redis      192.168.16.6

slave-redis      192.1681.1.53

先构建yum【略过】

修改主机名、关闭防火墙、selinux机制

[root@localhost ~]# hostname master;bash

[root@master ~]#sed  -i '2 s/localhost.localdomain/master/' /etc/sysconfig/network

[root@master ~]# cat /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=master

[root@master ~]# setenforce 0

[root@master ~]# iptables -F

[root@master ~]# rpm -e httpd --nodeps

 

1开始安装redistribute

[root@master ~]# ls

redis-2.8.9.tar

[root@master ~]# tar xf redis-2.8.9.tar -C /usr/src/

[root@master ~]# cd /usr/src/redis-2.8.9/

[root@master redis-2.8.9]# make MALLOC=jemalloc

[root@master redis-2.8.9]# make PREFIX=/usr/local/redis install

[root@master redis-2.8.9]# LANG=en

[root@master redis-2.8.9]# yum -y install tree httpd

[root@master redis-2.8.9]# tree /usr/local/redis/bin/【命令执行完之后,会在/usr/local/redis/bin/目录下生成5个可执行文件,分别是redis-server  redis-cli   redis-check-dump  redis-check-aof redis-benchmark

/usr/local/redis/bin/

|-- redis-benchmark【redis性能测试工具,测试redis在你的系统及你的配置下读写性能】

|-- redis-check-aof【对更新日志appendonly.aof检查,是否可用,类似检查mysql  binlog的工具】

|-- redis-check-dump【用于本地数据库rdb文件的检查】

|-- redis-cli【redis命令操作工具】

`-- redis-server【redis服务器的daemon启动程序】

0 directories, 5 files

 

【slave服务器】

[root@slave yum.repos.d]# yum -y install lrzsz gcc gcc-c++  tree

[root@slave ~]# ls

redis-2.8.9.tar

[root@slave redis-2.8.9]# make MALLOC=jemalloc

[root@slave redis-2.8.9]# make PREFIX=/usr/local/redis install

cd src && make install

make[1]: Entering directory `/usr/src/redis-2.8.9/src'

 

Hint: To run 'make test' is a good idea ;)

    INSTALL install

    INSTALL install

    INSTALL install

    INSTALL install

    INSTALL install

make[1]: Leaving directory `/usr/src/redis-2.8.9/src'

[root@slave redis-2.8.9]# LANG=en

[root@slave redis-2.8.9]# tree /usr/local/redis/bin/

/usr/local/redis/bin/

|-- redis-benchmark

|-- redis-check-aof

|-- redis-check-dump

|-- redis-cli

`-- redis-server

0 directories, 5 files

 

【主服务器】

[root@master ~]# sed -i '276 s/^#//' /etc/httpd/conf/httpd.conf

[root@master ~]# sed -i '402 s/DirectoryIndex/DirectoryIndex index.php/' /etc/httpd/conf/httpd.conf

[root@master ~]# cat  /etc/httpd/conf/httpd.conf 【最后的结果】

276 ServerName www.example.com:80

402 DirectoryIndex index.php index.html index.html.var

[root@master ~]# /etc/init.d/httpd restart

 

2 配置并启动redis服务

[root@master redis-2.8.9]# ln -s /usr/local/redis/bin/* /usr/local/bin/【配置启动命令】

[root@master redis-2.8.9]# redis-server -h

【从源程序目录复制redis.conf到程序安装目录下】

[root@master redis-2.8.9]# pwd

/usr/src/redis-2.8.9

[root@master redis-2.8.9]# mkdir /usr/local/redis/conf

[root@master redis-2.8.9]# cp redis.conf /usr/local/redis/conf/

[root@master redis-2.8.9]# redis-server /usr/local/redis/conf/redis.conf  &【启动redis服务】

[1] 28021

[root@master redis-2.8.9]# [28021] 23 May 20:56:41.706 * Increased maximum number of open files to 10032 (it was originally set to 1024).

                _._                                                 

           _.-``__ ''-._                                            

      _.-``    `.  `_.  ''-._           Redis 2.8.9 (00000000/0) 64 bit

  .-`` .-```.  ```/    _.,_ ''-._                                  

 (    '      ,       .-`  | `,    )     Running in stand alone mode

 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379

 |    `-._   `._    /     _.-'    |     PID: 28021

  `-._    `-._  `-./  _.-'    _.-'                                  

 |`-._`-._    `-.__.-'    _.-'_.-'|                                 

 |    `-._`-._        _.-'_.-'    |           http://redis.io       

  `-._    `-._`-.__.-'_.-'    _.-'                                   

 |`-._`-._    `-.__.-'    _.-'_.-'|                                 

 |    `-._`-._        _.-'_.-'    |                                 

  `-._    `-._`-.__.-'_.-'    _.-'                                  

      `-._    `-.__.-'    _.-'                                       

          `-._        _.-'                                          

              `-.__.-'                                              

 

[28021] 23 May 20:56:41.770 # Server started, Redis version 2.8.9

[28021] 23 May 20:56:41.773 # 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.【报错】

[28021] 23 May 20:56:41.773 * The server is now ready to accept connections on port 6379

[root@master redis-2.8.9]# ps -ef|grep redis|grep -v grep【查看redis进程启动情况】

root      28021  27987  0 20:56 pts/2    00:00:00 redis-server *:6379

[root@master redis-2.8.9]# pkill redis【杀死进程】

[28021 | signal handler] (1558616370) Received SIGTERM, scheduling shutdown...

[root@master redis-2.8.9]# [28021] 23 May 20:59:30.854 # User requested shutdown...

[28021] 23 May 20:59:30.854 * Saving the final RDB snapshot before exiting.

[28021] 23 May 20:59:30.880 * DB saved on disk

[28021] 23 May 20:59:30.880 # Redis is now ready to exit, bye bye...

 

[1]+  Done                    redis-server /usr/local/redis/conf/redis.conf

[root@master redis-2.8.9]# sysctl vm.overcommit_memory=1【修改参数为1,默认为0

vm.overcommit_memory = 1

[root@master redis-2.8.9]# redis-server /usr/local/redis/conf/redis.conf &【启动成功】

[1] 28081

[root@master redis-2.8.9]# [28081] 23 May 21:05:58.492 * Increased maximum number of open files to 10032 (it was originally set to 1024).

                _._                                                  

           _.-``__ ''-._                                            

      _.-``    `.  `_.  ''-._           Redis 2.8.9 (00000000/0) 64 bit

  .-`` .-```.  ```/    _.,_ ''-._                                  

 (    '      ,       .-`  | `,    )     Running in stand alone mode

 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379

 |    `-._   `._    /     _.-'    |     PID: 28081

  `-._    `-._  `-./  _.-'    _.-'                                  

 |`-._`-._    `-.__.-'    _.-'_.-'|                                 

 |    `-._`-._        _.-'_.-'    |           http://redis.io       

  `-._    `-._`-.__.-'_.-'    _.-'                                  

 |`-._`-._    `-.__.-'    _.-'_.-'|                                  

 |    `-._`-._        _.-'_.-'    |                                 

  `-._    `-._`-.__.-'_.-'    _.-'                                  

      `-._    `-.__.-'    _.-'                                      

          `-._        _.-'                                           

              `-.__.-'                                              

 

[28081] 23 May 21:05:58.536 # Server started, Redis version 2.8.9

[28081] 23 May 21:05:58.538 * DB loaded from disk: 0.000 seconds

[28081] 23 May 21:05:58.538 * The server is now ready to accept connections on port 6379

 

3、测试关闭redis服务的命令

[root@master redis-2.8.9]# ps -ef|grep redis|grep -v grep

root      28081  27987  0 21:05 pts/2    00:00:00 redis-server *:6379

[root@master redis-2.8.9]# redis-cli shutdown

[28081] 23 May 21:08:02.465 # User requested shutdown...

[28081] 23 May 21:08:02.465 * Saving the final RDB snapshot before exiting.

[28081] 23 May 21:08:02.578 * DB saved on disk

[28081] 23 May 21:08:02.578 # Redis is now ready to exit, bye bye..

[root@master redis-2.8.9]# ps -ef|grep redis|grep -v grep

[1]+  Done                    redis-server /usr/local/redis/conf/redis.conf

[root@master redis-2.8.9]# redis-server /usr/local/redis/conf/redis.conf &

[1] 28130

[root@master redis-2.8.9]# [28130] 23 May 21:15:48.236 * Increased maximum number of open files to 10032 (it was originally set to 1024).

                _._                                                 

           _.-``__ ''-._                                            

      _.-``    `.  `_.  ''-._           Redis 2.8.9 (00000000/0) 64 bit

  .-`` .-```.  ```/    _.,_ ''-._                                  

 (    '      ,       .-`  | `,    )     Running in stand alone mode

 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379

 |    `-._   `._    /     _.-'    |     PID: 28130

  `-._    `-._  `-./  _.-'    _.-'                                  

 |`-._`-._    `-.__.-'    _.-'_.-'|                                 

 |    `-._`-._        _.-'_.-'    |           http://redis.io       

  `-._    `-._`-.__.-'_.-'    _.-'                                  

 |`-._`-._    `-.__.-'    _.-'_.-'|                                 

 |    `-._`-._        _.-'_.-'    |                                 

  `-._    `-._`-.__.-'_.-'    _.-'                                   

      `-._    `-.__.-'    _.-'                                      

          `-._        _.-'                                          

              `-.__.-'                                              

 

[28130] 23 May 21:15:48.242 # Server started, Redis version 2.8.9

[28130] 23 May 21:15:48.242 * DB loaded from disk: 0.000 seconds

[28130] 23 May 21:15:48.242 * The server is now ready to accept connections on port 6379

 

4、通过客户端操作redis数据库

【插入数据:设置一个key-value对】

[root@master redis-2.8.9]# redis-cli【通过客户端连接本地redis

127.0.0.1:6379> set id 001【写入一条数据key(id),value(001)

OK

127.0.0.1:6379> get id【取值key(id)

"001" 【显示key对应的值】

127.0.0.1:6379> del id【删除keyid)】

(integer) 1  【1表示成功】

127.0.0.1:6379> exists id【验证key是否存在】

(integer) 0  【0表示不存在】

127.0.0.1:6379> get id篇【取key的值】

(nil) 【报错信息】

127.0.0.1:6379> set user001 benet

OK

127.0.0.1:6379> set user002 yunjisuan

OK

127.0.0.1:6379> set user003 yum123

OK

127.0.0.1:6379> get user001

"benet"

127.0.0.1:6379> get user002

"yunjisuan"

127.0.0.1:6379> get user003

"yum123"

127.0.0.1:6379> keys *【查看redis里所有的key

1) "user002"

2) "user001"

3) "user003"

 

5、更多操作方式及命令帮助

5.1 redis数据库的表模式

127.0.0.1:6379> select 1【切换到表1模式】

OK

127.0.0.1:6379[1]> keys *【查询所有key

(empty list or set)

127.0.0.1:6379[1]> set name wangwu【写入一个key-value对】

OK

127.0.0.1:6379[1]> keys *【查看所有key

1) "name" 【key (name)已经有了】

127.0.0.1:6379[1]> get name【查看keyname)的值】

"wangwu"

127.0.0.1:6379[1]> select 0【切换回表0模式(初始模式)】

OK

127.0.0.1:6379> keys *【查看所有key

1) "user002"

2) "user001"

3) "user003"

 

5.2redis-cli客户端的远程连接及非交互式操作数据库

[root@master redis-2.8.9]# redis-cli -h 192.168.1.151 -p 6379

192.168.1.151:6379> quit

[root@master redis-2.8.9]# redis-cli -h 192.168.1.151 -p 6379 set aaa 111

OK

[root@master redis-2.8.9]# redis-cli -h 192.168.1.151 -p 6379 get aaa

"111"

 

5.3 通过telnet连接ewdis数据库【在从服务器上操作】

[root@slave redis-2.8.9]# yum -y install telnet

[root@slave redis-2.8.9]# telnet 192.168.16.6 6379

Trying 192.168.16.6...

Connected to 192.168.16.6.

Escape character is '^]'.

auth yunjisuan【输入密码yunjisuan

+OK

set name 002  【创建名字】      

+OK

keys *

*1

$4

name

quit

+OK

 

6  redis安全

6.1redis客户端设置外部链接密码

[root@master redis-2.8.9]# grep -n requirepass /usr/local/redis/conf/redis.conf 【修改redis配置文件,添加密码】

198:# If the master is password protected (using the "requirepass" configuration

339:# requirepass foobared

[root@master redis-2.8.9]# sed -i '339 s@# requirepass foobared@requirepass yunjisuan@g' /usr/local/redis/conf/redis.conf【密码是yunjisuan

[root@master redis-2.8.9]# grep -n requirepass /usr/local/redis/conf

/redis.conf

198:# If the master is password protected (using the "requirepass" configuration

339:requirepass yunjisuan

 

6.2重启redis后测试

[root@master redis-2.8.9]# ps -ef|grep redis|grep -v grep

root      28130      1  0 21:15 ?        00:00:04 redis-server *:6379 

[root@master redis-2.8.9]# redis-cli shutdown

[root@master redis-2.8.9]# ps -ef |grep redis|grep -v grep

[root@master redis-2.8.9]#redis-server /usr/local/redis/conf/redis.conf &

[1] 28391

[root@master redis-2.8.9]# [28391] 23 May 22:11:03.589 * Increased maximum number of open files to 10032 (it was originally set to 1024).

                _._                                                  

           _.-``__ ''-._                                            

      _.-``    `.  `_.  ''-._           Redis 2.8.9 (00000000/0) 64 bit

  .-`` .-```.  ```/    _.,_ ''-._                                  

 (    '      ,       .-`  | `,    )     Running in stand alone mode

 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379

 |    `-._   `._    /     _.-'    |     PID: 28391

  `-._    `-._  `-./  _.-'    _.-'                                  

 |`-._`-._    `-.__.-'    _.-'_.-'|                                 

 |    `-._`-._        _.-'_.-'    |           http://redis.io       

  `-._    `-._`-.__.-'_.-'    _.-'                                  

 |`-._`-._    `-.__.-'    _.-'_.-'|                                 

 |    `-._`-._        _.-'_.-'    |                                 

  `-._    `-._`-.__.-'_.-'    _.-'                                  

      `-._    `-.__.-'    _.-'                                      

          `-._        _.-'                                           

              `-.__.-'                                              

 

[28391] 23 May 22:11:03.621 # Server started, Redis version 2.8.9

[28391] 23 May 22:11:03.623 * The server is now ready to accept connections on port 6379

 

[root@master redis-2.8.9]# ps -ef |grep redis|grep -v grep

root      28391  28356  0 22:11 pts/4    00:00:00 redis-server *:6379

 

6.3测试验证效果

第一种登录验证方式

[root@master redis-2.8.9]# redis-cli【登录本地redis

127.0.0.1:6379> set name 3333【存数据】

(error) NOAUTH Authentication required.

127.0.0.1:6379> keys *【查看所有key

(error) NOAUTH Authentication required. 【没有验证权限】

127.0.0.1:6379> auth yunjisuan【提交验证密码】

OK【验证通过】

127.0.0.1:6379> keys *【查看所有keys

(empty list or set)

127.0.0.1:6379> quit

 

第二种登录验证方式

 [root@master redis-2.8.9]# redis-cli -a yunjisuan【进入成功】

127.0.0.1:6379> keys *【因为再次进入后就会没有数据,】

(empty list or set)【没有数据】

127.0.0.1:6379> quit

 

6.4将危险的命令改名

查看配置说明

[root@master redis-2.8.9]# cat -n /usr/local/redis/conf/redis.conf |sed -n '326,359p'

   326         ################################## SECURITY ###################################

   327        

   328         # Require clients to issue AUTH <PASSWORD> before processing any other

   329         # commands.  This might be useful in environments in which you do not trust

   330         # others with access to the host running redis-server.

   331         #

   332         # This should stay commented out for backward compatibility and because most

   333         # people do not need auth (e.g. they run their own servers).

   334         #

   335         # Warning: since Redis is pretty fast an outside user can try up to

   336         # 150k passwords per second against a good box. This means that you should

   337         # use a very strong password otherwise it will be very easy to break.

   338         #

   339         requirepass yunjisuan【添加的密码验证】

   340        

   341         # Command renaming.

   342         #

   343         # It is possible to change the name of dangerous commands in a shared

   344         # environment. For instance the CONFIG command may be renamed into something

   345         # hard to guess so that it will still be available for internal-use tools

   346         # but not available for general clients.

   347         #

   348         # Example:

   349         #

   350         # rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52

   351         #

   352         # It is also possible to completely kill a command by renaming it into

   353         # an empty string:

   354         #

   355         # rename-command CONFIG ""【命令修改示例】

   356         #

   357         # Please note that changing the name of commands that are logged into the

   358         # AOF file or transmitted to slaves may cause problems.

   359        

 

修改配置文件

[root@master redis-2.8.9]# sed -i '359i rename-command set "sset"' /usr/local/redis/conf/redis.conf

[root@master redis-2.8.9]# sed -n '359p' /usr/local/redis/conf/redis.conf

rename-command set "sset"

 

重启redis进程

[root@master redis-2.8.9]# redis-cli -a yunjisuan shutdown

[28391] 23 May 22:23:26.856 # User requested shutdown...

[28391] 23 May 22:23:26.856 * Saving the final RDB snapshot before exiting.

[28391] 23 May 22:23:27.242 * DB saved on disk

[28391] 23 May 22:23:27.242 # Redis is now ready to exit, bye bye...

[1]+  Done                    redis-server /usr/local/redis/conf/redis.conf  (wd: ~)

(wd now: /usr/src/redis-2.8.9)

[root@master redis-2.8.9]# redis-server /usr/local/redis/conf/redis.conf &

[1] 28452

[root@master redis-2.8.9]# [28452] 23 May 22:25:38.467 * Increased maximum number of open files to 10032 (it was originally set to 1024).

                _._                                                 

           _.-``__ ''-._                                            

      _.-``    `.  `_.  ''-._           Redis 2.8.9 (00000000/0) 64 bit

  .-`` .-```.  ```/    _.,_ ''-._                                  

 (    '      ,       .-`  | `,    )     Running in stand alone mode

 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379

 |    `-._   `._    /     _.-'    |     PID: 28452

  `-._    `-._  `-./  _.-'    _.-'                                  

 |`-._`-._    `-.__.-'    _.-'_.-'|                                 

 |    `-._`-._        _.-'_.-'    |           http://redis.io       

  `-._    `-._`-.__.-'_.-'    _.-'                                  

 |`-._`-._    `-.__.-'    _.-'_.-'|                                 

 |    `-._`-._        _.-'_.-'    |                                 

  `-._    `-._`-.__.-'_.-'    _.-'                                   

      `-._    `-.__.-'    _.-'                                      

          `-._        _.-'                                          

              `-.__.-'                                              

 

[28452] 23 May 22:25:38.470 # Server started, Redis version 2.8.9

[28452] 23 May 22:25:38.471 * DB loaded from disk: 0.000 seconds

[28452] 23 May 22:25:38.471 * The server is now ready to accept connections on port 6379

 

验证命令改名效果

[root@master redis-2.8.9]# redis-cli -a yunjisuan

127.0.0.1:6379> set xxx 555【命令输入错误。因为修改过了】

(error) ERR unknown command 'set'

127.0.0.1:6379> sset xxx 555【写入key-value正确】

OK

127.0.0.1:6379> get xxx

"555"

127.0.0.1:6379> quit

 

7、为php安装redis客户端扩展

[root@master ~]# ls

phpredis-master.tar.gz

[root@master ~]# ls -l phpredis-master.tar.gz

-rw-r--r--. 1 root root 164355 5月  23 22:28 phpredis-master.tar.gz

[root@master ~]# tar xf phpredis-master.tar.gz -C /usr/src/

[root@master ~]# cd /usr/src/phpredis-master/

【关机再挂载一张光盘】

【此处需要挂载俩张光盘,并按安装php-devel

[root@localhost yum.repos.d]# yum -y install php-develyum -y install php-devel

[root@master phpredis-master]# /usr/bin/phpize

Configuring for:

PHP Api Version:         20090626

Zend Module Api No:      20090626

Zend Extension Api No:   220090626

[root@master phpredis-master]# ./configure --with-php-config=/usr/bin/php-config && make && make install

----------------------------------------------------------------------

Build complete.

Don't forget to run 'make test'.

Installing shared extensions:     /usr/lib64/php/modules/

 

7.1修改php.ini设置 ,重启php

[root@master ~]# sed -i '808 s/;//' /etc/php.ini

[root@master ~]# sed -n '808p' /etc/php.ini

 extension_dir = "./"

[root@master ~]# sed -i '808 s%./%/usr/lib64/php/modules/%p' /etc/php.ini

[root@master ~]# sed -n '808p' /etc/php.ini

 extension_dir = "/usr/lib64/php/modules/"

[root@master ~]# echo "extension = redis.so" >>/etc/php.ini

[root@master ~]# /etc/init.d/php-fpm start

[root@master html]# vim /etc/httpd/conf/httpd.conf

276 ServerName www.example.com:80

402 DirectoryIndex index.php  index.html index.html.var

 

8 开发php程序操作redis

在操作之前,将之前redis配置文件里修改的redis命令注释掉

[root@master redis-2.10.1]# vim /usr/local/redis/conf/redis.conf

359 #rename-command set "sset"【注释掉】

[root@master redis-2.10.1]# redis-cli -a yunjisuan shutdown

[root@master redis-2.10.1]# redis-server /usr/local/redis/conf/redis.conf &

[root@master ~]# vim /var/www/html/redis.php

<?php

$redis = new Redis();

$redis -> connect("192.168.1.151",6379);

$redis -> auth("yunjisuan");

$redis -> set("name","yunjisuantesttest");

$var = $redis -> get("name");

echo "$varn";

?>

保存

[root@localhost ~]# vim /var/www/html/index.php

<?php

phpinfo();

?>

测试:输入192.168.1.151

 

 

9、安装python redis客户端操作resis

[root@master ~]# ls

redis-2.10.1.tar.gz

[root@master ~]# tar xf redis-2.10.1.tar.gz

[root@master ~]# cd redis-2.10.1/

[root@master redis-2.10.1]# python setup.py install

 

开发Python程序操作redis

[root@master redis-2.10.1]# python

Python 2.6.6 (r266:84292, Nov 22 2013, 12:16:22)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> import redis【引用redis支持库】

>>> r = redis.Redis(host='192.168.1.151',port='6379',password='yunjisuan')【建立redis数据库的连接对象(面向对象方式)】

>>> r.set('name','benet')【操作对象调用set方法写入数据】

True

>>> r.get('name')【操作对象调用get方式读取数据】

'benet'

>>> r.dbsize()【操作对象查看redis数据库的数据条数】

1L

>>> r.keys()【查看所有的key

['name']

>>> exit()

 

10 通过web界面连接Python程序展示redis

开发python脚本

[root@master ~]# vim python-redis.py

        r.set('name','haolilong')

        return r.get('name')

def hello_world_app(environ,start_response):

        status = '200 OK' #HTTP Status

        headers = [('Content-type','text/plain')]  #HTTP Headers

        start_response(status,headers)

        #The returned object is going to be printed

        return get_redis()

httpd = make_server('',8000,hello_world_app)

print "Serving on port 8000..."

# Server until process is killed

httpd.serve_forever()

保存退出

【启动python脚本】

[root@master ~]# python python-redis.py

Serving on port 8000...【坚听8000端口】

【通过客户端浏览器连接python程序】

 

[root@master ~]# python python-redis.py【网页登录一次出现俩行】

Serving on port 8000...

192.168.1.1 - - [24/May/2019 03:11:15] "GET / HTTP/1.1" 200 9

192.168.1.1 - - [24/May/2019 03:11:25] "GET /favicon.ico HTTP/1.1" 200 9

 

实验补充:

1、长时间不操作会出现以下    情况

[root@master ~]# [28452] 23 May 22:40:39.065 * 1 changes in 900 seconds. Saving...

[28452] 23 May 22:40:39.078 * Background saving started by pid 28523

[28523] 23 May 22:40:39.103 * DB saved on disk

[28523] 23 May 22:40:39.105 * RDB: 6 MB of memory used by copy-on-write

[28452] 23 May 22:40:39.190 * Background saving terminated with success

2、报错,用python操作redis出现以下情况,是原来的命令被修改了,找不到命令

注释掉redis.conf文件里的359 #rename-command set "sset"

>>> r.set('name','benet')

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "redis/client.py", line 999, in set

    return self.execute_command('SET', *pieces)

  File "redis/client.py", line 529, in execute_command

    return self.parse_response(connection, command_name, **options)

  File "redis/client.py", line 541, in parse_response

    response = connection.read_response()

  File "redis/connection.py", line 550, in read_response

    raise response

redis.exceptions.ResponseError: unknown command 'SET'

3、第一次出现这个情况

[root@master html]# netstat -anpt|grep httpd

tcp        0      0 :::80                       :::*                        LISTEN      6831/httpd          

tcp        0      0 ::ffff:192.168.1.151:80     ::ffff:192.168.1.1:2463     ESTABLISHED 6836/httpd         

tcp        0      0 ::ffff:192.168.1.151:80     ::ffff:192.168.1.1:2464     ESTABLISHED 6834/httpd

最后

以上就是勤劳诺言为你收集整理的redis环境部署的全部内容,希望文章能够帮你解决redis环境部署所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(44)

评论列表共有 0 条评论

立即
投稿
返回
顶部