redis的安装

redis的安装


去官网下载redis的安装包http://www.redis.cn/download.html

tar -zxvf redis-5.0.5.tar.gz
mv redis-5.0.5 /usr/local
cd /usr/local/redis-5.0.5
make
cd src
make install PREFIX=/usr/local/redis

 

cd ..
mkdir /usr/local/redis/etc
mv redis.conf /usr/local/redis/etc/

useradd -d /home/redis redis

cp /usr/local/redis/etc/redis.conf /home/redis
cd /home/redis/
chmod 640 redis.conf   设置redis启动文件权限
--------------------------------------------------------------------------------------------

vim /home/redis/redis.conf
pidfile /var/run/redis.pid     修改为 pidfile /home/redis/run/redis.pid
dir ./                                  修改为 dir /home/redis/redis
logfile ""                             添加为 logfile "/home/redis/log/redis.log"
port 6379                           修改为 port 8972
bind 0.0.0.0                        登录阿里云控制台做安全组规则开放端口和授权指定IP

:/requirepass foobared        找到这一行 添加如下内容(设置密码登录)
requirepass zkjs_20191113

:/maxmemory          找到这一行 添加如下内容(过期策略)
maxmemory 1G
maxmemory-policy volatile-lru

:/rename-command CONFIG     找到这一行 添加如下内容(禁用如下的高危命令)

rename-command CONFIG ""
rename-command FLUSHALL ""
rename-command FLUSHDB ""
rename-command SHUTDOWN ""

daemonize no 修改为 daemonize yes 以后台方式启动,可以从redis.log查看启动结果

:wq

---------------------------------------------------------------------------------------------------------------------

cd /home/redis
mkdir redis
mkdir run
mkdir log
chown -R redis:redis /home/redis

su - redis   切换到redis用户启动
cd /usr/local/redis/bin
./redis-server /home/redis/redis.conf

ps -elf | grep redis  查看redis的启动用户

 

 


------------------------------------------------------------------------------------------------------------------

redis相关问题



1、 问题描述 服务器安装redis后,开始使用,发现无法正常使用,服务异常

报错信息
UnhandledPromiseRejectionWarning: ReplyError: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.

解决方法

方式一:
检查磁盘空间,检查磁盘是否真的被使用完毕了

df -h


方式二:
$ redis-cli -h 41.188.42.198 -a zkjs_20191113 -p 8972
config set stop-writes-on-bgsave-error no

你可能感兴趣的:(redis的安装)