Redis在Linux上的安装,很简单

大家好,今天分享一下Redis在Linux上的安装

首先要获取软件包(linux)

  1. 可以在官网下载
  2. 使用镜像站的方式(因为官网下载很慢)

这是Redis 包的国内镜像站,点一下就可以了

点开始这样的

在这里插入图片描述

下载这个redis-5.0.8.tar.gz
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

解压包

[root@localhost opt]# tar zvxf  redis-5.0.8.tar.gz  -C  /opt/

在这里插入图片描述

[root@localhost ~]# ls -l /opt/redis-5.0.8/    //显示redis   文件目录

总用量 272
-rw-rw-r--.  1 root root 118338 312 2020 00-RELEASENOTES
-rw-rw-r--.  1 root root     53 312 2020 BUGS
-rw-rw-r--.  1 root root   2381 312 2020 CONTRIBUTING
-rw-rw-r--.  1 root root   1487 312 2020 COPYING
drwxrwxr-x.  6 root root    124 312 2020 deps
-rw-rw-r--.  1 root root     11 312 2020 INSTALL
-rw-rw-r--.  1 root root    151 312 2020 Makefile
-rw-rw-r--.  1 root root   6888 312 2020 MANIFESTO
-rw-rw-r--.  1 root root  20555 312 2020 README.md
-rw-rw-r--.  1 root root  61797 312 2020 redis.conf
-rwxrwxr-x.  1 root root    275 312 2020 runtest
-rwxrwxr-x.  1 root root    280 312 2020 runtest-cluster
-rwxrwxr-x.  1 root root    373 312 2020 runtest-moduleapi
-rwxrwxr-x.  1 root root    281 312 2020 runtest-sentinel
-rw-rw-r--.  1 root root   9710 312 2020 sentinel.conf
drwxrwxr-x.  3 root root   4096 312 2020 src
drwxrwxr-x. 11 root root    182 312 2020 tests
drwxrwxr-x.  8 root root   4096 312 2020 utils
[root@localhost ~]# 

安装一下基本环境

[root@localhost ~]# yum install  gcc c++ -y

查看高层次版本

[root@localhost ~]# gcc -v
使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
目标:x86_64-redhat-linux
配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enecking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc+,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/buiD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
线程模型:posix
gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 

在Redis软件的解压目录下编译

[root@localhost redis-5.0.8]# make

编译成功

[root@localhost redis-5.0.8]# make all

cd src && make all
make[1]: 进入目录“/opt/redis-5.0.8/src”
    CC Makefile.dep
make[1]: 离开目录“/opt/redis-5.0.8/src”
make[1]: 进入目录“/opt/redis-5.0.8/src”

Hint: It's a good idea to run 'make test' ;)

make[1]: 离开目录“/opt/redis-5.0.8/src”

安装

[root@localhost redis-5.0.8]# make install
cd src && make install
make[1]: 进入目录“/opt/redis-5.0.8/src”

Hint: It's a good idea to run 'make test' ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: 离开目录“/opt/redis-5.0.8/src”
[root@localhost redis-5.0.8]# 

Redis默认安装目录

[root@localhost ~]# ls  -l /usr/local/bin/
总用量 49404
lrwxrwxrwx. 1 root root       23 32 13:15 ab -> /usr/local/httpd/bin/ab
lrwxrwxrwx. 1 root root       30 32 13:15 apachectl -> /usr/local/httpd/bin/apachectl
lrwxrwxrwx. 1 root root       25 32 13:15 apxs -> /usr/local/httpd/bin/apxs
lrwxrwxrwx. 1 root root       29 32 13:15 checkgid -> /usr/local/httpd/bin/checkgid
lrwxrwxrwx. 1 root root       30 32 13:15 dbmmanage -> /usr/local/httpd/bin/dbmmanage
-rwxr-xr-x. 1 root root 17032648 312 18:40 docker-compose
lrwxrwxrwx. 1 root root       28 32 13:15 envvars -> /usr/local/httpd/bin/envvars
lrwxrwxrwx. 1 root root       32 32 13:15 envvars-std -> /usr/local/httpd/bin/envvars-std
lrwxrwxrwx. 1 root root       33 32 13:15 htcacheclean -> /usr/local/httpd/bin/htcacheclean
lrwxrwxrwx. 1 root root       26 32 13:15 htdbm -> /usr/local/httpd/bin/htdbm
lrwxrwxrwx. 1 root root       29 32 13:15 htdigest -> /usr/local/httpd/bin/htdigest
lrwxrwxrwx. 1 root root       29 32 13:15 htpasswd -> /usr/local/httpd/bin/htpasswd
lrwxrwxrwx. 1 root root       26 32 13:15 httpd -> /usr/local/httpd/bin/httpd
lrwxrwxrwx. 1 root root       30 32 13:15 httxt2dbm -> /usr/local/httpd/bin/httxt2dbm
lrwxrwxrwx. 1 root root       31 32 13:15 logresolve -> /usr/local/httpd/bin/logresolve
-rwxr-xr-x. 1 root root  4365776 316 13:37 redis-benchmark
-rwxr-xr-x. 1 root root  8123976 316 13:37 redis-check-aof
-rwxr-xr-x. 1 root root  8123976 316 13:37 redis-check-rdb
-rwxr-xr-x. 1 root root  4806744 316 13:37 redis-cli
lrwxrwxrwx. 1 root root       12 316 13:37 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root  8123976 316 13:37 redis-server
lrwxrwxrwx. 1 root root       31 32 13:15 rotatelogs -> /usr/local/http
[root@localhost ~]# cd /usr/local/bin/
[root@localhost bin]# mkdir redistest
[root@localhost bin]# cp ./redis-
redis-benchmark  redis-check-aof  redis-check-rdb  redis-cli        redis-sentinel   redis-server     
[root@localhost bin]# cp /opt/redis-
opt/
[root@localhost bin]# cp /opt/redis-5.0.8/redis.conf  redistest
[root@localhost bin]# 
[root@localhost bin]# cd redistest/
[root@localhost redistest]# ls
redis.conf
[root@localhost redistest]# 
# Redis configuration file example.
#
# Note that in order to read the configuration file, Redis must be
# started with the file path as first argument:
#
# ./redis-server /path/to/redis.conf

# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# 1gb => 1024*1024*1024 bytes
#
# units are case insensitive so 1GB 1Gb 1gB are all the same.

################################## INCLUDES ###################################

这样改下

在这里插入图片描述

启动redis

[root@localhost redistest]# cd ..
[root@localhost bin]# red
red              rediff           redis-benchmark  redis-check-aof  redis-check-rdb  redis-cli        redis-sentinel   redis-server     
[root@localhost bin]# redis-server redistest/redis.conf
10345:C 16 Mar 2022 13:53:25.613 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
10345:C 16 Mar 2022 13:53:25.613 # Redis version=5.0.8, bits=64, commit=00000000, modified=0, pid=10345, just started
10345:C 16 Mar 2022 13:53:25.613 # Configuration loaded
[root@localhost bin]# 

连接到数据库

[root@localhost bin]# redis-cli -p 6379

测试:

在这里插入图片描述

查看当前redis是否启动
在这里插入图片描述

退出(关闭)Redis

127.0.0.1:6379> keys *
1) "name"
127.0.0.1:6379> SHUTDOWN
not connected> exit
[root@localhost bin]# 

截图:

在这里插入图片描述

好了,有关于Redis在Linux上的安装就到这里了,谢谢大家

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
redis安装 1: 下载redis-5.0.4.tar.gz 2: 解压源码并进入目录 tar zxvf redis-5.0.4.tar.gz cd redis-5.0.4 3: 不用configure 4: 直接make (如果是32位机器 make 32bit) 查看linux机器是32位还是64位的方法:file /bin/ls 注:易碰到的问题,时间错误. 原因: 源码是官方configure过的,但官方configure时,生成的文件有时间戳信息, Make只能发生在configure之后, 如果你的虚拟机的时间不对,比如说是2012年 解决: date -s ' yyyy-mm-dd hh:mm:ss ' 重写时间 再 clock -w 写入cmos 5: 可选步骤: make test 测试编译情况 (可能出现: need tcl >8.4这种情况, yum -y install tcl ) 6: 安装到指定的目录,比如 /usr/local/redis make PREFIX=/usr/local/redis install 注: PREFIX要大写 7: 复制配置文件 cp redis.conf /usr/local/redis 注path为解压后的安装包路径 /root/gsj/redis-3.0.6 8: 让redis以后台进程的形式运行 vim /usr/local/redis/redis.conf 编辑redis.conf配置文件,修改如下内容; daemonize yes 9: make install之后,cd /usr/local/redis/bin得到如下几个文件 redis-benchmark 性能测试工具 redis-check-aof 日志文件检测工(比如断电造成日志损坏,可以检测并修复) redis-check-dump 快照文件检测工具,效果类上 redis-cli 客户端 redis-server 服务端 10: 启动与连接 启动redis并指定配置文件 cd /usr/local/redis ./bin/redis-server ./redis.conf #设置随机启动 vim /etc/rc.local 最后添加: /usr/local/redis/bin/redis-server /usr/local/redis/redis.conf 连接: 用redis-cli cd /usr/local/redis/bin/ ./redis-cli #进入 exit /quit #退出 关闭redis pkill redis-server #关闭 ./redis-cli shutdown #关闭 查看是否启动成功 ps -ef | grep redis #查看端口是否占用 netstat -tunpl | grep 6379 11: 测试 String(字符串)类型: set name lijie #设置键name的值为lijie get name #获取name的值。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

思诚代码块

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

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

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

打赏作者

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

抵扣说明:

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

余额充值