redis安装-Linux 多实例

获取tar包下载路径

官网地址:redis官网 (打不开的建议科学上网)

右键复制链接 即 https://download.redis.io/releases/redis-6.2.5.tar.gz

进入服务器 安装wget

[root@linux /]# yum install wget

创建redis目录

[root@linux local]# cd /usr/local  //建议安装到该目录下
[root@linux local]# mkdir redis 
[root@linux local]# chmod 777 redis  //给个权限
[root@linux local]# wget https://download.redis.io/releases/redis-6.2.5.tar.gz
[root@linux local]# tar xf redis-6.2.5.tar.gz  //解压

编译redis

一般这种源码 第一件事就是进里面看看README 看看如何build
在这里插入图片描述
下面还有很多 这里不一一细讲
直接make即可

[root@linux local]# make

如果提示缺少cc(源码是c语言开发的 编译需要cc支持),就安装一下 命令为:

[root@linux local]# yum install gcc
[root@linux local]# make distclean //清理一下刚刚报错的编译 readme中告诉的
[root@linux local]# make  //再次编译

编译成功 进入src目录 使用./redis-server即可使用了
当然我们可以将可执行脚本提取出来,免于和源码混在一起 (都是README中告诉我们的)

[root@linux src]#  make install PREFIX=/usr/local/redis-bin  //提取到该目录
[root@linux src]# cd /usr/local/redis-bin/bin
[root@linux src]# ll
-rwxr-xr-x 1 root root 4829624 8月  19 14:13 redis-benchmark
lrwxrwxrwx 1 root root      12 8月  19 14:13 redis-check-aof -> redis-server
lrwxrwxrwx 1 root root      12 8月  19 14:13 redis-check-rdb -> redis-server
-rwxr-xr-x 1 root root 5003240 8月  19 14:13 redis-cli
lrwxrwxrwx 1 root root      12 8月  19 14:13 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 9491752 8月  19 14:13 redis-server

设置环境变量

之后我们去设置一下环境变量

[root@linux src]# vi /etc/profile  //新增如下两行
export REDIS_HOME=/usr/local/redis-bin  
export PATH=$PATH:$REDIS_HOME/bin
:wq保存
[root@linux src]# source /etc/profile //重新载入一下配置文件

设置服务启动方式

[root@linux src]# /usr/local/redis/redis-6.2.5/utils
[root@linux src]#  ./install_server.sh 
//默认6379  回车 (同样方法 可以启动多个实例 在这里改一下端口号就可以了)
//默认生成的配置文件 回车
//默认生成的log文件 回车
//默认生成的数据文件(持久化位置) 回车
//默认服务位置  回车
//确认刚刚的选择  回车
//这时候已经安装好并且启动了一个redis实例了 进入 /etc/init.d/中
[root@linux src]# cd /etc/init.d/    
//发现多出了一个redis_6379文件 这是一个脚本,也是服务名 有了它 就可以在任意位置对redis服务进行操作了
[root@linux ~]# service redis_6379 status  //服务名也是redis_6379
Redis is running (7469)(进程id)
//启动多个实例的效果
[root@linux utils]# ps -ef|grep redis
root      7469     1  0 23:48 ?        00:00:00 /usr/local/bin/redis-server 127.0.0.1:6379
root     26027     1  0 23:56 ?        00:00:00 /usr/local/bin/redis-server 127.0.0.1:6380
root     26799   537  0 23:56 pts/2    00:00:00 grep --color=auto redis

//访问效果如下
[root@linux bin]# ./redis-cli -h 127.0.0.1 -p 6380
127.0.0.1:6380> 
[root@linux bin]# ./redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> 

如果提示如下错误

Welcome to the redis service installer
This script will help you easily set up a running redis server

This systems seems to use systemd.
Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!

进入install_server.sh 中

[root@linux src]# vi install_server.sh 

将如下几行注释掉即可

#_pid_1_exe="$(readlink -f /proc/1/exe)"
#if [ "${_pid_1_exe##*/}" = systemd ]
#then
#       echo "This systems seems to use systemd."
#       echo "Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!"
#       exit 1
#fi
#unset _pid_1_exe

至此redis-Linux 多实例安装启动完毕

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值