redis(单机安装)

一,下载地址
wget https://download.redis.io/releases/redis-6.2.6.tar.gz
二,安装
上传/data
解压
tar -xf redis-6.2.6.tar.gz
依赖环境的安装
yum install -y gcc ctl
解压好了,进入redis目录

[root@VM-8-14-centos ~]# cd /data/redis-6.2.6/
[root@VM-8-14-centos redis-6.2.6]# pwd 
/data/redis-6.2.6

目录文件

[root@VM-8-14-centos redis-6.2.6]# ll
total 348
-rw-rw-r--  1 root root 33624 Oct  4  2021 00-RELEASENOTES
-rw-rw-r--  1 root root    51 Oct  4  2021 BUGS
-rw-rw-r--  1 root root  5026 Oct  4  2021 CONDUCT
-rw-rw-r--  1 root root  3384 Oct  4  2021 CONTRIBUTING
-rw-rw-r--  1 root root  1487 Oct  4  2021 COPYING
drwxrwxr-x  7 root root  4096 Dec  8 17:26 deps
-rw-r--r--  1 root root    92 Dec  8 17:37 dump.rdb
-rw-rw-r--  1 root root    11 Oct  4  2021 INSTALL
-rw-rw-r--  1 root root   151 Oct  4  2021 Makefile
-rw-rw-r--  1 root root  6888 Oct  4  2021 MANIFESTO
-rw-rw-r--  1 root root 21567 Oct  4  2021 README.md
-rw-rw-r--  1 root root 93719 Dec  9 15:05 redis.conf
-rw-rw-r--  1 root root 93724 Oct  4  2021 redis.conf.bak
-rw-r--r--  1 root root  1176 Dec  9 15:06 redis.log
-rwxrwxr-x  1 root root   275 Oct  4  2021 runtest
-rwxrwxr-x  1 root root   279 Oct  4  2021 runtest-cluster
-rwxrwxr-x  1 root root  1079 Oct  4  2021 runtest-moduleapi
-rwxrwxr-x  1 root root   281 Oct  4  2021 runtest-sentinel
-rw-rw-r--  1 root root 13768 Oct  4  2021 sentinel.conf
drwxrwxr-x  3 root root 12288 Dec  8 17:27 src
drwxrwxr-x 11 root root  4096 Oct  4  2021 tests
-rw-rw-r--  1 root root  3055 Oct  4  2021 TLS.md
drwxrwxr-x  9 root root  4096 Oct  4  2021 utils

编译安装

make && make install 

没有报错就是安装成功

默认的安装到位置

[root@VM-8-14-centos redis-6.2.6]# cd /usr/local/bin/
[root@VM-8-14-centos bin]# ll
total 19892
-rwxr-xr-x 1 root root 1001112 Aug  5  2020 busybox-x86_64
-rwxr-xr-x 1 root root 4829472 Dec  8 17:27 redis-benchmark
lrwxrwxrwx 1 root root      12 Dec  8 17:27 redis-check-aof -> redis-server
lrwxrwxrwx 1 root root      12 Dec  8 17:27 redis-check-rdb -> redis-server
-rwxr-xr-x 1 root root 5003760 Dec  8 17:27 redis-cli
lrwxrwxrwx 1 root root      12 Dec  8 17:27 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 9524032 Dec  8 17:27 redis-server
[root@VM-8-14-centos bin]# pwd
/usr/local/bin

默认的的环境,可以在这里面执行命令

redis-cli ;提供 命令行客户端
redis-server ;服务端启动脚本
redis-sentinel ;哨兵启动脚本

三,配置文件的修改
1.先备份配置文件(在redis目录下)

cp -a redis.conf redis.confbak 

在这里插入图片描述

2.修改配置文件

#默认地址是127.0.0.1,只能本地访问,0.0.0.0可以任意IP访问,建议是自己安装实验可以,生产环境不要实验,这是一个安全隐患
bind 0.0.0.0 
#守护进程,修改yes为后台启动
 daemonize yes
 #设置密码
 requirepass foobared  给foobared修改 (喜欢什么设定什么,支持特殊符号)
 requirepass 123321
 

常见的配置

#监听端口号
port 6379 
#工作目录,默认当前目录,就是运行redis-server时的,命令,日志,持久化等文件会保留在这个目录
dir ./ 
#数据库默认是16个库,现在是单机安装改成1个库就好
databases 1 
#设置使用最大内存
maxmemory <bytes>   根据自己的需求更改
修改成  maxmemory 512mb 
日志默认为空,可以指定日志文件名称
logfile "redis.log"

四,验证

到安装目录
[root@VM-8-14-centos ~]# cd /data/redis-6.2.6/
[root@VM-8-14-centos redis-6.2.6]# pwd
/data/redis-6.2.6
启动
redis-server redis.conf 

[root@VM-8-14-centos src]# pwd
/data/redis-6.2.6/src
[root@VM-8-14-centos src]# ./redis-cli
127.0.0.1:6379>
成功

root@VM-8-14-centos src]# netstat -antp | grep 6379
tcp        0      0 0.0.0.0:6379            0.0.0.0:*               LISTEN      195915/redis-server 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值