linux(ubuntu20.10) :编译安装redis6.0.9

一,下载redis

1,redis的官方站:
https://redis.io/
下载页面:
https://redis.io/download

 

2,下载到源码保存目录:
root@ku:/usr/local/source/redis# wget https://download.redis.io/releases/redis-6.0.9.tar.gz

 

说明:刘宏缔的架构森林是一个专注架构的博客,

网站:https://blog.imgtouch.com
本文: https://blog.imgtouch.com/index.php/2023/05/26/linux-ubuntu20-10-bian-yi-an-zhuang-redis6-9/

         对应的源码可以访问这里获取: https://github.com/liuhongdi/

说明:作者:刘宏缔 邮箱: 371125307@qq.com

 

二,安装redis6.0.9

1,准备gcc:
root@ku:/usr/local/source/redis# gcc --version
Command 'gcc' not found, but can be installed with:
apt install gcc
安装gcc
root@ku:/usr/local/source/redis# apt install gcc
查看效果:
root@ku:/usr/local/source/redis# gcc --version
gcc (Ubuntu 10.2.0-13ubuntu1) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 

2,准备make
安装make
root@ku:/usr/local/source/redis# apt install make
查看安装的效果:
root@ku:/usr/local/source/redis# make --version
GNU Make 4.3
为 x86_64-pc-linux-gnu 编译
Copyright (C) 1988-2020 Free Software Foundation, Inc.
许可证:GPLv3+:GNU 通用公共许可证第 3 版或更新版本<http://gnu.org/licenses/gpl.html>。
本软件是自由软件:您可以自由修改和重新发布它。
在法律允许的范围内没有其他保证。

 

3,解压redis的源码包:
root@ku:/usr/local/source/redis# tar -zxvf redis-6.0.9.tar.gz

 

4,编译并安装:
#PREFIX=/usr/local/soft/redis6:用来指定安装目录
root@ku:/usr/local/source/redis# cd redis-6.0.9/
root@ku:/usr/local/source/redis/redis-6.0.9# make PREFIX=/usr/local/soft/redis6 install
查看已安装的目录:
root@ku:/usr/local/source/redis/redis-6.0.9# ls /usr/local/soft/redis6/
bin

 

5,生成配置文件:
root@ku:/usr/local/source/redis/redis-6.0.9# mkdir /usr/local/soft/redis6/conf
root@ku:/usr/local/source/redis/redis-6.0.9# cp redis.conf /usr/local/soft/redis6/conf/

 

6,生成启动文件:
root@ku:/usr/local/source/redis/redis-6.0.9/utils# cp -axv redis_init_script /etc/init.d/redis
'redis_init_script' -> '/etc/init.d/redis’

注意这个启动文件位于源码的utils目录下

 

三,配置redis

1,生成日志和数据目录:
root@ku:/usr/local/source/redis/redis-6.0.9# mkdir -p /data/redis6
root@ku:/usr/local/source/redis/redis-6.0.9# mkdir -p /data/redis6/logs
root@ku:/usr/local/source/redis/redis-6.0.9# mkdir -p /data/redis6/data
2,编辑配置文件
root@ku:/usr/local/source/redis/redis-6.0.9# cd /usr/local/soft/redis6/conf/
root@ku:/usr/local/soft/redis6/conf# vi redis.conf
配置项:
1,绑定ip:这里使用默认值即可
bind 127.0.0.1

2,以daemon方式运行
daemonize yes

3,日志保存目录
logfile "/data/redis6/logs/redis.log"

4,数据保存目录:
dir /data/redis6/data/

5,使用的最大内存容量
maxmemory 128MB

 

四,修改启动文件

root@ku:/usr/local/source/redis/redis-6.0.9/utils# vi /etc/init.d/redis

 

修改启动脚本开始处的变量为:
REDISPORT=6379
EXEC=/usr/local/soft/redis6/bin/redis-server
CLIEXEC=/usr/local/soft/redis6/bin/redis-cli
 
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/usr/local/soft/redis6/conf/redis.conf"

 

五,测试运行redis

1,测试启动server
增加可执行属性
root@ku:/usr/local/source/redis/redis-6.0.9/utils# chmod +x /etc/init.d/redis
root@ku:/usr/local/source/redis/redis-6.0.9/utils# update-rc.d redis defaults
启动
root@ku:/usr/local/source/redis/redis-6.0.9/utils# service redis start

 

检查端口:
root@ku:/usr/local/source/redis/redis-6.0.9/utils# ss -lntp | grep redis
LISTEN 0      511             127.0.0.1:6379       0.0.0.0:*    users:(("redis-server",pid=16537,fd=6))

 

查看已安装的redis版本:
root@ku:/usr/local/source/redis/redis-6.0.9/utils# /usr/local/soft/redis6/bin/redis-server -v
Redis server v=6.0.9 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=861e278c5c605f67

 

2,测试用cli访问:
root@ku:/usr/local/source/redis/redis-6.0.9/utils# /usr/local/soft/redis6/bin/redis-cli
127.0.0.1:6379> set a avalue
OK
127.0.0.1:6379> get a
"avalue"

 

六,查看linux的版本:

root@ku:~# more /etc/os-release
NAME="Ubuntu Kylin"
VERSION="20.10 (Groovy Gorilla)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.10"
VERSION_ID="20.10"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=groovy
UBUNTU_CODENAME=groovy 

 

posted @ 2020-12-17 17:42  刘宏缔的架构森林  阅读(1442)  评论(0编辑  收藏  举报