栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

在Linux环境下安装Redis

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在Linux环境下安装Redis

目录

  

1. 环境准备,java, gcc, redis安装包

 2. 解压redis安装包:程序一般放在opt目录下

 3. 进入解压文件,可以看到redis配置文件

 4. 基本环境安装

 5. 修改redis默认安装路径

 6. 将redis配置文件复制来

 7. redis默认部署后台启动,要修改配置文件

​ 8. 启动redis

 9. 查看进程是否开启

 10.关闭服务


  

1. 环境准备,java, gcc, redis安装包

系统:centos7
 

[root@cyj01 ~]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
Copyright © 2015 Free Software Foundation, Inc.
本程序是自由软件;请参看源代码的版权声明。本软件没有任何担保;
包括没有适销性和某一专用目的下的适用性担保。
[root@cyj01 ~]# java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)
[root@cyj01 ~]# 
[root@cyj01 ~]# cd /home
[root@cyj01 home]# ls
soni
[root@cyj01 home]# cd soni
[root@cyj01 soni]# ls
redis-5.0.7.tar.gz
[root@cyj01 soni]# 

安装gcc

centos7自带的gcc版本是4.8,通过gcc官网安装手册可知,依赖文件太多了,手动升级安装太繁琐。可以通过安装devtoolset的方式间接升级gcc至高版本

sudo yum install centos-release-scl
sudo yum install devtoolset-7-gcc*
scl enable devtoolset-7 bash
which gcc
gcc --version


 2. 解压redis安装包:程序一般放在opt目录下
[root@cyj01 soni]# mv redis-5.0.7.tar.gz /opt
[root@cyj01 soni]# cd /opt
[root@cyj01 opt]# ls
containerd  redis-5.0.7.tar.gz  rh
[root@cyj01 opt]# tar -zxvf redis-5.0.7.tar.gz
[root@cyj01 opt]# ls
containerd  redis-5.0.7  redis-5.0.7.tar.gz  rh
[root@cyj01 opt]# 


 3. 进入解压文件,可以看到redis配置文件
[root@cyj01 opt]# ls
containerd  redis-5.0.7  redis-5.0.7.tar.gz  rh
[root@cyj01 opt]# cd redis-5.0.7
[root@cyj01 redis-5.0.7]# ls
00-RELEASENOTES  COPYING  Makefile   redis.conf       runtest-moduleapi  src
BUGS             deps     MANIFESTO  runtest          runtest-sentinel   tests
CONTRIBUTING     INSTALL  README.md  runtest-cluster  sentinel.conf      utils
[root@cyj01 redis-5.0.7]# 


 4. 基本环境安装
make
再次make
make
make install


 5. 修改redis默认安装路径
[root@cyj01 redis-5.0.7]# ls
00-RELEASENOTES  COPYING  Makefile   redis.conf       runtest-moduleapi  src
BUGS             deps     MANIFESTO  runtest          runtest-sentinel   tests
CONTRIBUTING     INSTALL  README.md  runtest-cluster  sentinel.conf      utils
[root@cyj01 redis-5.0.7]# cd /usr
[root@cyj01 usr]# cd local
[root@cyj01 local]# ls
bin  etc  games  include  lib  lib64  libexec  sbin  share  src
[root@cyj01 local]# cd bin
[root@cyj01 bin]# 
[root@cyj01 bin]# ls
redis-benchmark  redis-check-aof  redis-check-rdb  redis-cli  redis-sentinel  redis-server
[root@cyj01 bin]# 


 6. 将redis配置文件复制来
[root@cyj01 redis-5.0.7]# cd /usr
[root@cyj01 usr]# cd local
[root@cyj01 local]# ls
bin  etc  games  include  lib  lib64  libexec  sbin  share  src
[root@cyj01 local]# cd bin
[root@cyj01 bin]# ls
redis-benchmark  redis-check-aof  redis-check-rdb  redis-cli  redis-sentinel  redis-server
[root@cyj01 bin]# mkdir cyjconfig
[root@cyj01 bin]# cd /cyjcongig
-bash: cd: /cyjcongig: 没有那个文件或目录
[root@cyj01 bin]# cd /cyjconfig
-bash: cd: /cyjconfig: 没有那个文件或目录
[root@cyj01 bin]# ls
cyjconfig        redis-check-aof  redis-cli       redis-server
redis-benchmark  redis-check-rdb  redis-sentinel
[root@cyj01 bin]# cp /opt/redis-5.0.7/redis.conf cyjconfig
[root@cyj01 bin]# cd cyjconfig/
[root@cyj01 cyjconfig]# ls
redis.conf
[root@cyj01 cyjconfig]# 


 7. redis默认部署后台启动,要修改配置文件
[root@cyj01 cyjconfig]# ls
redis.conf
[root@cyj01 cyjconfig]# vim redis.conf
[root@cyj01 cyjconfig]# 


 8. 启动redis
[root@cyj01 bin]# pwd
/usr/local/bin
[root@cyj01 bin]# redis-server cyjconfig/redis.conf
19360:C 08 May 2022 12:11:40.806 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
19360:C 08 May 2022 12:11:40.806 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=19360, just started
19360:C 08 May 2022 12:11:40.806 # Configuration loaded
[root@cyj01 bin]# 
[root@cyj01 bin]# redis-cli -p 6379
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set name cyj
OK
127.0.0.1:6379> get name
"cyj"
127.0.0.1:6379> key *
(error) ERR unknown command `key`, with args beginning with: `*`, 
127.0.0.1:6379> keys *
1) "name"
127.0.0.1:6379> 


 9. 查看进程是否开启
[root@cyj01 /]# ps -ef|grep redis
root      19361      1  0 12:11 ?        00:00:00 redis-server 127.0.0.1:6379
root      19373  14435  0 12:12 pts/2    00:00:00 redis-cli -p 6379
root      19384  14287  0 12:13 pts/1    00:00:00 grep --color=auto redis
[root@cyj01 /]# 


 10.关闭服务
127.0.0.1:6379> shutdown
not connected> exit
[root@cyj01 bin]# 


检查进程
[root@cyj01 /]# ps -ef|grep redis
root      19394  14287  0 12:14 pts/1    00:00:00 grep --color=auto redis
[root@cyj01 /]# 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/868297.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号