前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Linux云计算运维架构师(连载)缓存服务 Redis 集群-03

Linux云计算运维架构师(连载)缓存服务 Redis 集群-03

原创
作者头像
用户1880875
修改2021-07-06 14:51:26
3370
修改2021-07-06 14:51:26
举报
文章被收录于专栏:用户1880875的专栏

二、Redis 基本部署

1、Yum 方式安装最新版本 Redis

1、安装 redis-rpm源

代码语言:javascript
复制
[root@xulei.com ~]# yum install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

2、安装 Redis

代码语言:javascript
复制
[root@xulei.com ~]# yum --enablerepo=remi install redis

3、开机自启 Redis

代码语言:javascript
复制
[root@xulei.com ~]# systemctl enable redis

4、设置redis.conf

允许远程登录: bind 127.0.0.1 改为 bind 0.0.0.0 (可选)

代码语言:javascript
复制
[root@xulei.com ~]# vim /etc/redis.conf

2、编译安装最新版本redis

1、编译安装 Redis

代码语言:javascript
复制
[root@xulei.com  ~]# wget http://download.redis.io/releases/redis-5.0.5.tar.gz 
[root@xulei.com  ~]# tar -zxvf redis-5.0.5.tar.gz -C /usr/local
[root@xulei.com  ~]# yum install gcc -y       # gcc -v查看,如果没有需要安装
[root@xulei.com  ~]# cd /usr/local/redis-5.0.5
[root@xulei.com  redis-5.0.5]# make MALLOC=lib 
[root@xulei.com  redis-5.0.5]# cd src && make all
[root@xulei.com  src]# make install

2、启动 Redis 实例

代码语言:javascript
复制
[root@xulei.com  src]# ./redis-server
21522:C 17 Jun 2019 15:36:52.038 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
21522:C 17 Jun 2019 15:36:52.038 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=21522, just started
21522:C 17 Jun 2019 15:36:52.038 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
                _._                                                 
           _.-``__ ''-._                                            
      _.-``    `.  `_.  ''-._           Redis 5.0.5 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                  
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 21522
  `-._    `-._  `-./  _.-'    _.-'                                  
 |`-._`-._    `-.__.-'    _.-'_.-'|                                 
 |    `-._`-._        _.-'_.-'    |           http://redis.io       
  `-._    `-._`-.__.-'_.-'    _.-'                                  
 |`-._`-._    `-.__.-'    _.-'_.-'|                                 
 |    `-._`-._        _.-'_.-'    |                                 
  `-._    `-._`-.__.-'_.-'    _.-'                                  
      `-._    `-.__.-'    _.-'                                      
          `-._        _.-'                                          
              `-.__.-'                                              
 
出现以上界面说明安装成功
 
[root@xulei.com  src]# ./redis-cli --version           # 查询是安装的最新版本的redis
redis-cli 5.0.5
[root@xulei.com  src]# ./redis-server --version
Redis server v=5.0.5 sha=00000000:0 malloc=libc bits=64 build=4db47e2324dd3c5

3、配置启动数据库

1、开启 Redis 服务守护进程

代码语言:javascript
复制
# 以./redis-server 启动方式,需要一直打开窗口,不能进行其他操作,不太方便,以后台进程方式启动 redis
[root@xulei.com  src]# vim /usr/local/redis-5.0.5/redis.conf   # 默认安装好的配置文件并不在这个目录下,需要找到复制到该目录下
daemonize no 改为 daemonize yes        # 以守护进程运行           
 
[root@xulei.com  src]# ./redis-server /usr/local/redis-5.0.5/redis.conf
21845:C 17 Jun 2019 15:44:14.129 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
21845:C 17 Jun 2019 15:44:14.129 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=21845, just started
21845:C 17 Jun 2019 15:44:14.129 # Configuration loaded

2、关闭redis进程

代码语言:javascript
复制
[root@xulei.com  src]# ps -ef|grep redis
root     21846     1  0 15:44 ?        00:00:00 ./redis-server 127.0.0.1:6379
root     22042  6950  0 15:46 pts/1    00:00:00 grep --color=auto redis
[root@xulei.com  src]# kill -9 21846
 # 此方法启动关闭较为麻烦,且不能设置开机自启动

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 二、Redis 基本部署
    • 1、Yum 方式安装最新版本 Redis
      • 1、安装 redis-rpm源
        • 2、安装 Redis
          • 3、开机自启 Redis
            • 4、设置redis.conf
              • 2、编译安装最新版本redis
                • 1、编译安装 Redis
                  • 2、启动 Redis 实例
                    • 3、配置启动数据库
                      • 1、开启 Redis 服务守护进程
                        • 2、关闭redis进程
                        相关产品与服务
                        云数据库 Redis
                        腾讯云数据库 Redis(TencentDB for Redis)是腾讯云打造的兼容 Redis 协议的缓存和存储服务。丰富的数据结构能帮助您完成不同类型的业务场景开发。支持主从热备,提供自动容灾切换、数据备份、故障迁移、实例监控、在线扩容、数据回档等全套的数据库服务。
                        领券
                        问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档