缓存:Redis 5.0.8 (master-slave)
IP | 端口 | 密码 | 备注 |
---|---|---|---|
10.18.226.160(192.168.10.5)(主) | 6379 | redis0715jhl | |
10.18.226.167(192.168.10.9)(从) | 6379 | redis0715jhl |
参考:
tar -zxvf redis-5.0.8.tar.gz -C /usr/local/
cd /usr/local/redis-5.0.8
make
make install
操作指令默认在/usr/local/bin(可在任何位置访问到)
redis-server
修改运行方式为后台运行
#备份
cp /usr/local/redis-5.0.8/redis.conf /usr/local/redis-5.0.8/redis.conf.backup
#编辑
vim /usr/local/redis-5.0.8/redis.conf
#修改daemonize no 为 yes,这样运行方式就可以在后台运行
shell
cd /usr/local/redis-5.0.8
redis-server redis.conf
#服务端关闭方式1:启动redis-cli,执行 shutdown 或者 直接执行 redis-cli shutdown
#服务端关闭方式2:杀死进程
netstat -tunlp | grep redis
kill -9 进程号
#客户端关闭:exit
参考:
https://www.cnblogs.com/skyessay/p/6433349.html
https://segmentfault.com/a/1190000017370825
redis 自带一个启动脚本
1) 复制脚本
cp /usr/local/redis-5.0.8/utils/redis_init_script /etc/init.d/redis
2) 复制配置
mkdir /etc/redis
cp /usr/local/redis-5.0.8/redis.conf /etc/redis/redis.conf
3) 修改 /etc/init.d/redis
vim /etc/init.d/redis
该脚本并不复杂,关键一点一定要在 #!/bin/sh
下添加2行
其他的目录按照实际安装情况配置即可
#!/bin/sh
# chkconfig: 2345 10 90
# description: Start and Stop redis
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
### BEGIN INIT INFO
# Provides: redis_6379
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Redis data structure server
# Description: Redis data structure server. See https://redis.io
### END INIT INFO
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/etc/redis/redis.conf"
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
*)
echo "Please use start or stop as first argument"
;;
esac
4)新增服务
chkconfig --add redis
5)启动redis
service redis start
打开redis命令service redis stop
关闭redis命令chkconfig redis on
设为开机启动chkconfig redis off
设为开机关闭fail
参考: https://www.cnblogs.com/weibin1/p/10441832.html
配置文件没有移动,还是在 /usr/local/redis-5.0.8/ 目录下
官网地址 上没有windows版本的redis安装包
或 [github#microsoft-redis](https://github.com/microsoftarchive/redis/releases)
下载 mis 包
#进入redis安装目录
#启动
redis-server.exe redis.windows.conf
#在redis安装目录下
redis-cli
redis-server.exe 启动报错 Creating Server TCP listening socket 127.0.0.1:6379: bind: No error
解决方法:
在命令行中运行 redis-cli.exe
127.0.0.1:6379>shutdown
not connected>exit
然后重新运行redis-server.exe redis.windows.conf,启动成功!
登录远程redis,执行命令报错,如 Keys * (error) ERR unkown command 'keys'