Java老程序员霸榜前5名预测自由点赞群

Linux安装redis

2019-02-17  本文已影响4人  vincent201819

1.安装redis

apt-get update

apt-get install redis-server

2.启动redis

cd redis

sudo redis-server redis.conf

3.查看是否已经启动

redis-cli

4.打开/etc/redis.conf修改如下内容

bind 127.0.0.1----->  #bind 127.0.0.1

logfile ""    ----->  /var/lib/redis/redis_log.log

dir ./        ----->  /var/lib/redis

daemonize no  ----->  daemonize yes

timeout 0    ----->  timeout 0

#client-output-buffer-limit normal 0 0 0

#client-output-buffer-limit slave 256mb 64mb 60

#client-output-buffer-limit pubsub 32mb 8mb 60

--------->

client-output-buffer-limit normal 0 0 0

client-output-buffer-limit slave 0 0 0

client-output-buffer-limit pubsub 0 0 0

5.修改/etc/sysctl.conf

sudo vim /etc/sysctl.conf 添加 vm.overcommit_memory=1

生效:sudo /sbin/sysctl -p

6.创建redis日志文件

sudo touch /var/lib/redis/redis_log.log

sudo chmod 777 /var/lib/redis/redis_log.log

7.关闭redis

ps aux|grep redis

sudo kill -9 进程号

8. 虚拟机增加6379端口

9.设置redis密码

修改redis.conf

>sudo vim redis.conf

>requirepass yourpassword

redis-cli

>auth redispassword

10.常见异常

①redis.clients.jedis.exceptions.JedisDataException: MISCONF Redis is configured to save RDB snapshots

通过redis-cli连接到服务器后执行以下命令:

config set stop-writes-on-bgsave-error no

②ERR This instance has cluster support disabled

sudo vim redis.conf将#cluster-enabled yes注释去掉,重启redis

③JedisConnectionException: java.net.SocketException: Connection reset

关闭防火墙:sudo sysv-rc-conf iptables off

④(error) NOAUTH Authentication required

redis-cli

auth "yourpassword"

⑤MISCONF Redis is configured to save RDB snapshots

redis-cli

config set stop-writes-on-bgsave-error no

上一篇下一篇

猜你喜欢

热点阅读