安装redis
安装前准备
检查redis用户组和用户是否存在,如果没有,则创建
cat /etc/group | grep redis
cat /etc/passwd |grep redis
groupadd redis
useradd -r -g redis redis
获取安装包 赋予权限
获取redis资源
wget http://download.redis.io/releases/redis-4.0.8.tar.gz
解压、mv、将文件赋予redis组redis用户权限
tar xzvf redis-4.0.8.tar.gz
mv redis-4.0.8 redis
chown -R redis:redis /export/server/redis
修改配置 安装
安装redis
cd redis
make
cd src
make install PREFIX=/usr/local/redis make install PREFIX=/export/server/redis
配置redis为后台启动
vim /usr/local/redis/etc/redis.conf 或者 vim /export/server/redis/redis.conf
daemonize no no---->yes //将daemonize no 改成daemonize yes
protected-mode yes yes---->no
启动 停止 重启
启动redis
/export/server/redis/bin/redis-server /export/server/redis/redis.conf
将redis-cli,redis-server拷贝到bin下,让redis-cli指令可以在任意目录下直接使用
cp /usr/local/redis/bin/redis-server /usr/local/bin/ 或者 cp /export/server/redis/bin/redis-server /usr/local/bin/
cp /usr/local/redis/bin/redis-cli /usr/local/bin/ 或者 cp /export/server/redis/redis-cli /usr/local/bin/
重启redis kill -9 PID 参考文章:linux 安装redis 完整步骤
windows启动redis
cd D:\software\redis\pkg
d:
redis-server redis.windows.conf
redis-cli.exe
shutdown
exit
redis-server redis.windows.conf
报错:Creating Server TCP listening socket 127.0.0.1:6379: bind: No error 参考文章:Creating Server TCP listening socket 127.0.0.1:6379: bind: No error。。。启动遇到问题的解决办法
redis集群
参考文章:Redis cluster集群:原理及搭建 1.创建集群节点文件目录 可以启其他端口设置9001-9006
cd /usr/local/redis-cluster cd /export/server/redis/conf
mkdir 7001 7002 7003 7004 7005 7006
把redis的全局配置文件redis.conf移动至到conf目录下 2.编辑配置文件/conf/7001.conf
cat /export/server/redis/conf/7001/7001.conf //同理7002,7003...
include /export/server/redis/conf/redis.conf //[根据实际情况]
daemonize yes
cluster-enabled yes
cluster-config-file "nodes.conf"
cluster-node-timeout 15000
pidfile "/export/server/redis/logs/redis_7001.pid" //同理7002,7003...
logfile "/export/server/redis/logs/redis_7001.log" //同理7002,7003...
appendonly no
dir "/export/server/redis/conf/7001" //同理7002,7003...
port 7001 //同理7002,7003...
timeout 600
tcp-keepalive 3600
save 900 1
save 300 10
save 60 10000
client-output-buffer-limit normal 0 0 0
repl-timeout 180
repl-backlog-size 50mb
client-output-buffer-limit slave 0 0 0
save 900 1
save 300 10
save 60 10000
masterauth "jxh7nXoc87uLAytExEEmrfFAmGROA1qpPoGzPc3M4maeP8Qc"
requirepass "jxh7nXoc87uLAytExEEmrfFAmGROA1qpPoGzPc3M4maeP8Qc"
maxclients 4064
protected-mode no
备注:nodes.conf redis_7001.pid redis_7001.log不用自己创建 3.节点配置完成,开始启动服务
/export/server/redis/bin/redis-server /export/server/redis/conf/7001/7001.conf
同理 报错:cluster模式连接失败:10.241.242.13测试环境的redis无法通过远程客户端通过cluster模式连接,创建集群的时候不能用127.0.0.1,而是需要使用机器的实际ip
redis IP设置
修改/export/server/redis/conf/redis.conf bind xxxx(比如127.0.0.1) —> 删除 参考文章:Linux上安装Redis并搭建集群 redis集群搭建及遇到的问题
redis 使用
Redis可视化工具
Redis可视化工具Another Redis DeskTop Manager 下载及安装:Redis可视化工具Another Redis DeskTop Manager redis连接 密码:jxh7nXoc87uLAytExEEmrfFAmGROA1qpPoGzPc3M4maeP8Qc
Redis密码设置
redis如何设置密码:redis如何设置密码
|