Redis安装与部署

Redis安装与部署

一、安装

$ wget https://download.redis.io/releases/redis-6.2.6.tar.gz
$ tar xzf redis-6.2.6.tar.gz
$ cd redis-6.2.6
$ make
$ make install

二、前台启动

  • 编译好的二进制文件在 src 目录里。启动 Redis:
$ src/redis-server

三、后台启动

  • 复制配置文件到/etc目录下
[root@localhost redis]# cp redis.conf /etc/redis.conf
  • etc目录下
[root@localhost etc]# vim redis.conf 
  • 修改配置 daemonize no为yes
 252 ################################# GENERAL #################################     ####
 253 
 254 # By default Redis does not run as a daemon. Use 'yes' if you need it.
 255 # Note that Redis will write a pid file in /var/run/redis.pid when daemoniz     ed.
 256 # When Redis is supervised by upstart or systemd, this parameter has no imp     act.
 257 daemonize yes
  • 启动
[root@localhost redis-6.2.6]# cd /usr/local/bin/
[root@localhost bin]# ./redis-server  /etc/redis.conf 
  • 报错解决
[root@localhost bin]# ls
# 若没有以下文件,执行make install
redis-benchmark  redis-check-rdb  redis-sentinel
redis-check-aof  redis-cli        redis-server

四、连接Redis与关闭

  • 使用内置的客户端与Redis通讯:
[root@localhost bin]# ./redis-cli 
127.0.0.1:6379> shutdown
not connected> exit
[root@localhost bin]# 

五、切换数据库

  • 一共16个数据库,默认0号
127.0.0.1:6379> select 1
OK
127.0.0.1:6379[1]> 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值