Redis安装及部署

仅此记录Redis安装和部署的过程

登录redis官网,下载完成的是一个tar.gz包,上传到服务器

1、进入redis包的目录,执行解压

tar -zvxf redis-6.2.4.tar.gz

2、执行以下命令进行编译

cd redis-6.2.4
make -j 4
make install

3、启动前修改配置文件的内容,当前目录下的redis.conf,进行以下修改

bind 0.0.0.0 // 任意ip可以访问
daemonize yes // 允许后台执行
requirepass 123456 // 设置登陆密码为123456

4、启动redis服务和配置文件

redis-server ./redis.conf // 启动redis服务、指定配置文件
ps -ef | grep redis // 查看redis进程

5、访问redis,执行相关指令

redis-cli // 进入redis访问
auth 123456 // 输入密码进入
set name lufei // 设置name为lufei
set age 18 // 设置age为18
get name // 查看name的value
get age // 查看age的value

6、将redis服务做成系统的服务,在util目录下有install_server.sh

./install_server.sh // 需要root权限

// 如果出现以下错误,参考解决方案

This systems seems to use systemd.
Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!
Welcome to the redis service installer
This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379] 
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf] /home/Redis/redis-6.2.4/redis.conf // 选择redis的配置文件
Please select the redis log file name [/var/log/redis_6379.log] /home/Redis/redis-6.2.4/redis.log  // 指定redis的日志文件                                   
Please select the data directory for this instance [/var/lib/redis/6379] /home/Redis/redis-6.2.4/data  // 指定redis的data目录
Please select the redis executable path [/usr/local/bin/redis-server] 
Selected config:
Port           : 6379
Config file    : /home/suntingting/Redis/redis-6.2.4/redis.conf
Log file       : /home/suntingting/Redis/redis-6.2.4/redis.log
Data dir       : /home/suntingting/Redis/redis-6.2.4/data
Executable     : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort. // 回车
// 除了配置文件,其他可以放在任意位置

7、查看服务是否存在,如果chkconfig不存在,参考解决方案

chkconfig --list | grep redis

8、查看redis状态 // 需要sudo

sudo systemctl status redis_6379 // redis_6379 为 chkconfig --list | grep redis 显示的redis服务名称

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值