Redis 5.0.8 安装与基本配置

1.下载安装包(root)

官网:https://redis.io/ 下载即可。

放入 /soft 文件加并授权 chmod 777 -R /soft 备用

 

2.创建用户和组(root)

[root@test2 ~]# groupadd -g 601 redis
[root@test2 ~]# useradd -u 6001 -g 601 redis
[root@test2 ~]# id redis
uid=6001(redis) gid=601(redis) groups=601(redis)
[root@test2 ~]# passwd redis
Changing password for user redis.
New password: 
BAD PASSWORD: it is too short
BAD PASSWORD: is too simple
Retype new password: 
passwd: all authentication tokens updated successfully.

 

3.调整 redis 用户的 ulimit(root)

echo "redis hard nofile 10240" >> /etc/security/limits.conf
echo "redis soft nofile 10240" >> /etc/security/limits.conf
echo "redis hard nproc 8192" >> /etc/security/limits.conf
echo "redis soft nproc 8192" >> /etc/security/limits.conf

 

4.创建 redis 的安装路径(root)

mkdir -p /data/redis
chown -R redis:redis /data/redis

 

5.创建 redis 的数据路径(root)

mkdir -p /data/redis/log
mkdir -p /data/redis/conf
mkdir -p /data/redis/data
chown -R redis:redis /data/redis

 

6.编译、安装源程序(redis)

su - redis
cd /soft
tar zxvf redis-5.0.8.tar.gz
cd redis-5.0.8
make
cd src
make PREFIX=/data/redis install
cp ../redis.conf /data/redis/redis.conf

 

7.配置环境变量(redis)

vi ~/.bash_profile
PATH=/data/redis/bin:$PATH

 

8.修改系统参数 (root)

a.调整vm.overcommit_memory
    echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf
    可选值:0、1、2
        0:表示内核将检查是否有足够的可用内存供应用进程使用,如果有足够的可用内存,内存申请        
            允许,否则,内存申请失败,并把错误返回给应用进程。
        1:表示内核允许分配所有的物理内存,而不管当前的内存状态如何。
        2:表示内核允许分配超过所有物理内存和交换空间综合的内存。


b.调整Transparent Huge Pages(THP)
    解决:redis 做 rdb时会有部分请求超时的case
    echo "never > /sys/kernel/mm/transparent_hugepage/enabled" >> /etc/rc.local

c.TCP backlog设置
    echo "net.core.somaxconn = 2048 " >> /etc/sysctl.conf
    sysctl -p
    此参数确定了TCP 连接中已完成队列(完成3次握手之后)的长度,
    当然此值必须不大于Linux系统定义的/proc/sys/net/core/somaxconn值,默认是511,
    而Linux的默认参数值是128.当系统并发量大并且客户端速度缓慢的时候,可以将这2个参数一起参考    
    设定。

d.调整redis.conf
    vi /data/redis/redis.conf添加以下
    daemonize yes
    logfile "/data/redis/log/redis.log"
    requirepass redis

    并修改 bind参数的127.0.0.1 ,改为本机IP
    其中还有内存,最大连接数等参数,根据情况自己设置

 

 9.启动 redis 服务(redis)

[redis@test2 ~]$ redis-server /data/redis/redis.conf 
[redis@test2 ~]$ ps -ef|grep redis
root      32070  27704  0 01:58 pts/0    00:00:00 su - redis
redis     32071  32070  0 01:58 pts/0    00:00:00 -bash
redis     32091      1  0 01:58 ?        00:00:00 redis-server 192.168.65.2:6379     
redis     32099  32071  0 01:59 pts/0    00:00:00 ps -ef
redis     32100  32071  0 01:59 pts/0    00:00:00 grep redis
[redis@test2 ~]$ netstat -an|grep 6379
tcp        0      0 192.168.65.2:6379           0.0.0.0:*                   LISTEN  

 

10.客户端连接测试 (redis)

[redis@test2 ~]$ redis-cli -h 192.168.65.2
192.168.65.2:6379> ping
(error) NOAUTH Authentication required.
#这里要进行密码验证是因为我们在配置文件中修改requirepass参数,如果不设置,则默认为空,客户端连进来就直接可以操作,如果设置了就需要验证密码后才能操作
192.168.65.2:6379> auth redis      
OK
192.168.65.2:6379> ping
PONG
192.168.65.2:6379> 

11.停止 redis 服务(redis)

[redis@test2 ~]$ redis-cli -h 192.168.65.2 -a redis
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.168.65.2:6379> ping
PONG
192.168.65.2:6379> shutdown
not connected> 

PS:-a 后面跟的是密码,进去后就无需验证密码

也可以使用 pkill redis-server

 

12.设置开机自动启动(root)

vim /etc/rc.local
添加以下内容:
su - redis -c "/data/redis/bin/redis-server /data/redis/redis.conf"

 

13.修改 redis 密码 (redis)

a.关闭 redis 服务
    > vi /data/redis/redis.conf 
    > 修改 requirepass redis123
    > 重启 redis

b.不关闭 redis 服务
    > vi /data/redis/redis.conf 
    > 修改 requirepass redis123
    > redis-cli -h 192.168.65.2
    192.168.65.2:6379> ping
    (error) NOAUTH Authentication required.
    192.168.65.2:6379> auth redis13
    (error) ERR invalid password
    192.168.65.2:6379> auth redis123
    OK
    192.168.65.2:6379> config get requirepass
    1) "requirepass"
    2) "redis123"
    192.168.65.2:6379> config set requirepass redis
    OK
    192.168.65.2:6379> config get requirepass
    1) "requirepass"
    2) "redis"
    192.168.65.2:6379> exit
    [redis@test2 ~]$ redis-cli -h 192.168.65.2
    192.168.65.2:6379> auth redis
    OK
    192.168.65.2:6379> ping
    PONG

 

14. master 有密码,slave 如何设置

vi /data/redis/redis.conf
添加以下内容:
masterauth redis

 

15.第二种安装方法(不推荐,因为是用 root 安装的) 

cd /soft/redis-5.0.8/utils
[root@test2 utils]# ./install_server.sh 
Welcome to the redis service installer
This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379] 6479      # 写新的端口号
Please select the redis config file name [/etc/redis/6479.conf] /data/redis/6479/redis_6479.conf              #填配置文件存放路径
Please select the redis log file name [/var/log/redis_6479.log] /data/redis/6479/log/redis_6479.conf          #填日志文件存放路径
Please select the data directory for this instance [/var/lib/redis/6479] /data/redis/6479/data/                        #填数据文件存放的路径
Please select the redis executable path [] /data/redis/bin/redis-server
Selected config:
Port           : 6479
Config file    : /data/redis/6479/redis_6479.conf
Log file       : /data/redis/6479/log/redis_6479.conf
Data dir       : /data/redis/6479/data/
Executable     : /data/redis/bin/redis-server
Cli Executable : /data/redis/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.   #按回车
Copied /tmp/6479.conf => /etc/init.d/redis_6479
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!   #安装成功

查看状态
[root@test2 utils]# ps -ef|grep redis
redis      2127      1  0 03:22 ?        00:00:01 redis-server 192.168.65.2:6379     
root       2192      1  0 03:34 ?        00:00:00 /data/redis/bin/redis-server 127.0.0.1:6479                  
root       2197   2044  0 03:34 pts/0    00:00:00 grep redis
[root@test2 utils]# netstat -an|grep 6479
tcp        0      0 127.0.0.1:6479              0.0.0.0:*                   LISTEN      
[root@test2 utils]#

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
============================================ Redis 5.0.8发布于2020年3月12日16时05分41秒 ============================================ 升级紧迫性高:这个版本修复了安全问题。 这是这个版本的修复列表: Salvatore Sanfilippo在《commit 2bea502d》中写道: 来自dustinmm80/add-arm-latomi -link的合并拉请求#6975 达斯汀·柯林斯在b5931405: 修正Pi建设需要-拉丁,支持端口 文件更改1次,插入9次(+) srzhao在commit fd441300: 修正了子白名单SIGUSR1特性的impl。 1个文件更改,5个插入(+),4个删除(-) Ariel在承诺77ff332b: 修正了ThreadSafeContext锁定/解锁函数名的问题 1个文件更改,2个插入(+),2个删除(-) Guy Benoish《commit 4f0f799c》: XREADGROUP应该在MULTI/EXEC中传播XCALIM/SETID 1个文件更改,2个插入(+),2个删除(-) 奥兰·阿格拉在commit 0c1273c3: 修正客户端标志在module.c中的int64 1个文件改变,3个插入(+),3个删除(-) Guy Benoish在承诺708a4e8a: 修复与复制和监视模糊相关的小错误 2个文件更改,8个插入(+),6个删除(-) 吴云龙在提交eac4115d: 修复lua相关的内存泄漏。 1个文件更改,1个插入(+) 提交d075df17: 简化# 6379的变化。 2个文件更改,4个插入(+),9个删除(-) 武云龙在commit 80a49c37中: 在pfdebugCommand()中释放分配的sds,以避免内存泄漏。 1个文件更改,1个插入(+) 提交60870d3a中的antirez: 解析错误时跳转到右标签。 1个文件更改,6个插入(+),4个删除(-) 提交d90f599b: 在错误发生时释放错误信号。 1个文件改变,11个插入(+),3个删除(-) WuYunlong in commit 8ee3bddf: 修复rioWriteBulkStreamID()的潜在内存泄漏。 1个文件更改,4个插入(+),1个删除(-) 武云龙在commit 4780fe78中: 修复clusterLoadConfig()的潜在内存泄漏。 1个文件更改,20个插入(+),5个删除(-) Leo Murillo在f3b77510中: 修正了KEYS命令中模式以*开头,后跟\x00 (null char)的错误。 1个文件更改,1个插入(+),1个删除(-) Guy Benoish的《commit 7f3fcedb》: 阻塞XREAD[GROUP]应该总是使用有效数据进行应答(或超时) 更改3个文件,44次插入(+),10次删除(-) 提交f93b2fa5: XCLAIM:仅在成功的索赔上创建消费者。 1个文件更改,4个插入(+),2个删除(-) Guy Benoish在《commit 89682d96》中写道: 流:处理与流相关的边缘情况 4个文件改变,54个插入(+),4个删除(-) 提交920e108f: 修正了RM_GetClusterNodeInfo()中的ip和丢失模式。 1个文件改变,5个插入(+),2个删除(-) 提交7569b210: 内联协议:处理好空字符串。 1个文件更改,2个插入(+),6个删除(-) Khem Raj在承诺3c610b4e: 在sds.h中标记SDS_NOINIT的外部定义 1个文件更改,1个插入(+),1个删除(-) Seunghoon Woo在承诺16b2d07f: [修复]重访CVE-2015-8080漏洞 1个文件更改,6个插入(+),4个删除(-) yz1509在commit 19f33585中: 避免将标记更改promoted_slave作为它自己的副本。 1个文件更改,1个插入(+),1个删除(-)
Redis是一个开源的内存数据库,它提供了高性能的键值存储和数据结构服务。在Windows上下载、安装配置Redis可以按照以下步骤进行: 1. 下载Redis: 在Redis官方网站(https://redis.io/download)上下载最新的稳定版本的Redis。选择适合Windows的版本,通常是一个zip压缩包。 2. 解压Redis: 将下载的zip压缩包解压到你想要安装Redis的目录。 3. 配置Redis: 在Redis目录中,找到redis.windows.conf文件,并用文本编辑器打开它。在该文件中,你可以配置Redis的各种参数,如端口号、密码等。根据你的需求进行相应的配置。 4. 启动Redis: 在Redis目录中,找到redis-server.exe文件,并双击运行它。这将启动Redis服务器。 5. 测试Redis: 打开一个新的命令提示符窗口,导航到Redis目录,并运行redis-cli.exe命令。这将打开一个与Redis服务器进行交互的命令行界面。你可以使用各种Redis命令来测试和操作数据。 6. 配置Redis为Windows服务(可选): 如果你希望将Redis配置为Windows服务,以便在系统启动时自动启动Redis服务器,可以按照以下步骤进行配置: - 打开一个新的命令提示符窗口,导航到Redis目录。 - 运行redis-server.exe --service-install命令,将Redis配置为Windows服务。 - 运行redis-server.exe --service-start命令,启动Redis服务。 以上是在Windows上下载、安装配置Redis基本步骤。希望对你有帮助!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Ty_FFTQ

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值