linux 部署 Redis

234 阅读1分钟

1.下载

官网redis.io/

xxxxxxxxxx.png

2.安装

上传源码包至服务器
//1.解压
tar xzvf  redis-6.2.5.tar.gz
//2.进入目录安装
make
//3.可执行文件安装编译到指定目录
make install PREFIX=/usr/local/redis

3.配置

开启redis服务可远程访问,不开启则只指定母体机访问使用

# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES # JUST COMMENT OUT THE FOLLOWING LINE.

配置  注释掉 #bind 127.0.0.1 -::1  (该句指定访问ip,也可在此配置能访问此redis服务的ip)

关闭redis保护模式,如不关闭同样不支持远程访问

# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured, nor a specific set of interfaces
# are explicitly listed using the "bind" directive.    与bind命令搭配,开启远程访问
配置      
protected-mode no

设置redis后台守护进程启动,默认非守护进程

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
# When Redis is supervised by upstart or systemd, this parameter has no impact.
大致意思为Redis 不作为守护进程运行,如使用守护进程则配置yes
配置      
daemonize yes

自定义redis 端口,密码

开启远程后一定要配置密码.否则极有可能会被恶意扫码登录后 裸漏服务器

端口:
    port 3003
密码 
    requirepass Xnnf@123

启动

//指定配置文件启动
    redis-server ./redis.conf 
//指定配置文件参数启动,如端口是3303启动
    redis-server ./redis.conf  --port 3303
//redis暴力关闭
    ps -ef | group redis
    kill -9 端口 
//redis命令关闭
    redis-cli -h 127.0.0.1 -p 6379 shutdown