0%

redis源码安装

REmote DIctionary Server(Redis) 是一个由Salvatore Sanfilippo写的key-value存储系统。Redis是一个开源的使用ANSI C语言编写、遵守BSD协议、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。

  1. redis官网下载源码

  2. 解压 tar -zxvf redis-5.0.4.tar.gz -C /usr/local

  3. 切换目录 cd /usr/local/redis-5.0.4

  4. 安装 make

  5. 切换目录 cd src

  6. 复制相关文件以全局运行 cp {redis-cli,redis-server,redis-sentinel} /usr/local/bin/

  7. 修改redsi.conf,以后台进程方式运行 daemonize yes

  8. 启动服务 redis-server redis.conf

  9. 查看redis进程 ps -ef|grep redis

  10. 测试

    1
    2
    3
    4
    5
    6
    >redis-cli

    >set name "张三"

    >get name
    "\xe5\xbc\xa0\xe4\xb8\x89" //中文乱码
  11. redis-cli –raw // 解决中文乱码

  12. 进程kill不掉,一般是目录权限问题,对redis目录加一下权限

1
2
3
4
5
808:M 18 Dec 2019 14:29:48.639 # User requested shutdown...
808:M 18 Dec 2019 14:29:48.639 * Saving the final RDB snapshot before exiting.
808:M 18 Dec 2019 14:29:48.639 # Failed opening the RDB file dump.rdb (in server root dir /usr/local/redis-5.0.7) for saving: Permission denied
808:M 18 Dec 2019 14:29:48.639 # Error trying to save the DB, can't exit.
808:M 18 Dec 2019 14:29:48.639 # SIGTERM received but errors trying to shut down the server, check the logs for more information