linux 下安装redis

下载redis redis-3.0.5.tar.gz 执行一下操作 tar zxvf redis-3.0.5.tar.gz cd redis-3.0.5 make 执行完成以后,进入src目录,执行 mkdir /usr/local/redis cp redis-server redis-cli /usr/local/redis cd .. cp redis.conf /usr/local/redis cd /usr/local/redis cp redis-server redis-cli /usr/local/bin 执行 redis-server /usr/local/redis/redis.conf 就可以启动redis 关闭 redis-cli shutdown redis-cli 就可以连接redis 优化 vim /usr/local/redis/redis.conf 将参数daemonize从no改为yes 代表启动redis之后进程在后台运行,不影响当前会话。 如果要给redis设置连接密码就可以添加下面参数,其中redis代表你设置的密码,你也可以将redis修改为自己的密码 requirepass redis 然后保存退出。 注意:如果你给redis设置了连接密码,需要这样连接 先执行 redis-cli 然后执行, auth redis 其中redis代表你的密码,然后就登录成功了。 如果启动报下面的错误 1.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 /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. 2.WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 3.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. 解决方法 第一个警告两个方式解决(overcommit_memory) 1. echo "vm.overcommit_memory=1" > /etc/sysctl.conf 或 vi /etcsysctl.conf , 然后reboot重启机器 2. echo 1 > /proc/sys/vm/overcommit_memory 不需要启机器就生效 第二个警告解决 1. echo 511 > /proc/sys/net/core/somaxconn 第三个警告解决方法 echo never > /sys/kernel/mm/transparent_hugepage/enabled

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