centos安装redis

2021-01-09  本文已影响0人  kbdwn

安装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

后台启动

./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
Please select the redis config file name [/etc/redis/6379.conf] /usr/local/redis/bin/redis.conf
Please select the redis log file name [/var/log/redis_6379.log] /usr/local/redis/log/redis.log 
Please select the data directory for this instance [/var/lib/redis/6379] /usr/local/redis/data
Please select the redis executable path [] /usr/local/redis/bin/redis-server
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.
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
1:注释 bind 127.0.0.1
2:修改 protected-mode yes 变成 protected-mode no
3:设置密码 requirepass 密码
上一篇 下一篇

猜你喜欢

热点阅读