美文网首页
centos安装redis

centos安装redis

作者: kbdwn | 来源:发表于2021-01-09 20:22 被阅读0次

安装gcc依赖

yum install -y gcc 

下载并解压安装包

wget http://download.redis.io/releases/redis-5.0.3.tar.gz
tar -zxvf redis-5.0.3.tar.gz

cd切换到redis解压目录下,执行编译

cd redis-5.0.3
make

安装并指定安装目录

make install PREFIX=/usr/local/redis

前台启动,关闭窗口退出

cd /usr/local/redis/bin/
./redis-server

后台启动

  • 进入redis安装包解压缩后的utils目录
  • 执行install_server.sh
./install_server.sh
#输出
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
  • 确认redis的conf配置文件,输入/usr/local/redis/bin/redis.conf,然后回车
Please select the redis config file name [/etc/redis/6379.conf] /usr/local/redis/bin/redis.conf
  • 确认Redis的log文件目录位置,输入/usr/local/redis/log/redis.log 回车, 都在统一目录下方便查找
Please select the redis log file name [/var/log/redis_6379.log] /usr/local/redis/log/redis.log 
  • 确认Redis的数据存储路径,输入/usr/local/redis/data 然后回车
Please select the data directory for this instance [/var/lib/redis/6379] /usr/local/redis/data
  • 确认Reids的运行命令,输入/usr/local/redis/bin/redis-server然后回车
Please select the redis executable path [] /usr/local/redis/bin/redis-server
  • 确认Redis的启动项,这块默认就是刚刚安装路径,直接回车
Selected config:
Port           : 6379
Config file    : /usr/local/redis/bin/redis.conf
Log file       : /usr/local/redis/log/redis.log
Data dir       : /usr/local/redis/data
Executable     : /usr/local/redis/bin/redis-server
Cli Executable : /usr/local/redis/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
  • 出现successful,成功
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!
  • 查看服务名,确认是否成功
chkconfig --list | grep redis
# 输出
redis_6379      0:关闭    1:关闭    2:启用    3:启用    4:启用    5:启用    6:关闭
  • 启动、停止、查看状态命令
# centos7
systemctl status redis_6379   //查看状态
systemctl stop redis_6379   //停止
systemctl start redis_6379   //启动
# centos6
service redis_6379 status
service redis_6379 stop
service redis_6379 start
  • 配置远程链接,修改 /usr/local/redis/bin/redis.conf
1:注释 bind 127.0.0.1
2:修改 protected-mode yes 变成 protected-mode no
3:设置密码 requirepass 密码

相关文章

网友评论

      本文标题:centos安装redis

      本文链接:https://www.haomeiwen.com/subject/yuxhaktx.html