linux安装redis完整步骤
linux安装redis完整步骤
2.解压
  tar xzvf redis-4.0.
3.安装
  cd redis-4.0.8
  make
  cd src
  make install PREFIX=/usr/local/redis
4.移动配置⽂件到安装⽬录下
  cd ../
  mkdir /usr/local/redis/etc
  f /usr/local/redis/etc
5.配置redis为后台启动
  vi /usr/local/redis/f //将daemonize no 改成daemonize yes
6.将redis加⼊到开机启动
  vi /etc/rc.local //在⾥⾯添加内容:/usr/local/redis/bin/redis-server /usr/local/redis/f (意思就是开机调⽤这段开启redis的命令)
7.开启redis
中国中国鲜红的太阳永不落  /usr/local/redis/bin/redis-server /usr/local/redis/f
常⽤命令 
  redis-server /usr/local/redis/f //启动redis
  pkill redis //停⽌redis
  卸载redis:
    rm -rf /usr/local/redis //删除安装⽬录
    rm -rf /usr/bin/redis-* //删除所有redis相关命令脚本
    rm -rf /root/download/redis-4.0.4 //删除redis解压⽂件夹
让外⽹能够访问redis
    a.配置防⽕墙: firewall-cmd --zone=public --add-port=6379/tcp --permanent(开放6379端⼝)
          systemctl restart firewalld(重启防⽕墙以使配置即时⽣效)
     查看系统所有开放的端⼝:firewall-cmd --zone=public --list-ports
    b.此时虽然防⽕墙开放了6379端⼝,但是外⽹还是⽆法访问的,因为redis监听的是127.0.0.1:6379,并不监听外⽹的请求。
      (⼀)把⽂件夹⽬录⾥的f配置⽂件⾥的bind 127.0.0.1前⾯加#注释掉
七夕是什么节日
      (⼆)命令:redis-cli连接到redis后,通过 config get daemonize和config get protected-mode 是不是都为no,如果不是,就⽤config set 配置名属性改为no。
坐飞机不能带什么东西
# bind 127.0.0.1
daemonize no
protected-mode no
在家可以做什么兼职# redis在最终⽬标上移动临时数据库⽂件时出错将dir ./ 修改为redis配置⽂件所在⽬录:/usr/local/redis/etc/ 
# redis的持久化机制RDB先将内存中的数据集写⼊临时⽂件(temp-pid.rdb),写成功后再替换之前的⽂件(dump.rdb),⽽现在写⼊临时⽂件出错,数据保存不了,导致程序崩溃
dir /usr/local/redis/etc/
# RDB和AOF持久化
#redis有两种持久化⽅式:⼀种是RDB持久化(原理是将Reids在内存中的数据库记录定时dump到磁盘上的RDB持久化)
#           ⼀种是AOF持久化(原理是将Reids的操作⽇志以追加的⽅式写⼊⽂件)
#RDB是默认开启的,AOF需要修改配置⽂件来开启
appendonly yes
appendfilename "appendonly.aof"
12493:M 27 Dec 19:42:23.095 * 10 changes in 300 seconds.
12493:M 27 Dec 19:42:23.095 * Background saving started by pid 7905
7905:C 27 Dec 19:42:23.106 # Error moving temp DB file temp-7905.rdb on the final destination crontab (in server root dir /etc): Operation not permitted
12493:M 27 Dec 19:42:23.196 # Background saving error
Redis持久化失败报错
错误:
WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add
'vm.overcommit_memory = 1'
to /f and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. [7679] 15 Jan 00:27:35.287 * DB loaded from disk: 19.629 seconds
解决⽅案:在Linux系统设置⼀个参数(vm.overcommit_memory)即可解决。
  编辑 f 配置⽂件:vim /f
    vm.overcommit_memory = 1
  使配置⽂件⽣效:sysctl -p
  最后重启redis
18679:M 27 Dec 19:52:06.900 # WARNING: The TCP backlog setting of 511 cannot be enforced bec
ause /proc/sys/net/core/somaxconn is set to the lower value of 128.
18679:M 27 Dec 19:52:06.900 # Server initialized
18679:M 27 Dec 19:52:06.900 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never >
/sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
18679:M 27 Dec 19:52:06.900 * Ready to accept connections
18679:M 27 Dec 19:57:07.096 * 10 changes in 300 seconds.
18679:M 27 Dec 19:57:07.096 * Background saving started by pid 6584
胡静老公个人资料6584:C 27 Dec 19:57:07.111 * DB saved on disk
6584:C 27 Dec 19:57:07.112 * RDB: 0 MB of memory used by copy-on-write
18679:M 27 Dec 19:57:07.196 * Background saving terminated with success
18679:M 27 Dec 20:01:20.187 * 10000 changes in 60 seconds.
18679:M 27 Dec 20:01:20.187 * Background saving started by pid 24886
24886:C 27 Dec 20:01:20.224 * DB saved on disk
24886:C 27 Dec 20:01:20.225 * RDB: 0 MB of memory used by copy-on-write
18679:M 27 Dec 20:01:20.287 * Background saving terminated with success
>江苏高考 数学