linux 安装redis
redis下载
redis官网
安装包拷贝到linux
安装redis编译的c环境
yum install gcc-c++
解压到 /usr/local
tar -xvf redis-5.0.4.tar.gz -C /usr/local
删除安装包
rm -rf redis-5.0.4.tar.gz
安装
- cd redis-5.0.4
- make (源码文件被移动到当前目录的src文件夹下面)
- cd src
- make PREFIX=/usr/local/redis install
移动配置文件到安装目录下 - cd …/
- mkdir /usr/local/redis/etc
- mv redis.conf /usr/local/redis/etc 或 cp redis.conf /usr/local/redis/etc
配置redis为后台启动
vi /usr/local/redis/etc/redis.conf //将daemonize no 改成daemonize yes
配置密码
vi /usr/local/redis/etc/redis.conf // requirepass test
启动redis
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
查看进程
ps -ef|grep redis
root 16124 1 0 09:55 ? 00:00:00 /usr/local/redis/bin/redis-
server 127.0.0.1:6379
root 16135 7486 0 09:57 pts/0 00:00:00 grep --color=auto redis
客户端登录
- cd /usr/local/redis/bin
- ./redis-cli
- exit退出
ping
成功: PONG
开启外网访问
bind注释掉,即:#bind 127.0.0.1重启redis
开放端口
firewall-cmd --zone=public --add-port=6379/tcp --permanent
重载防火墙
firewall-cmd --reload
停止redis
pkill redis-server
或在Redis的bin目录下/redis-cli shutdown