腾讯云Centos7.2搭建redis5.0

安装

redis下载官网
1.下载解压包

wget http://download.redis.io/releases/redis-5.0.5.tar.gz

2.解压包

tar xzf redis-5.0.5.tar.gz

3.进入解压文件目录

cd redis-5.0.5

4.编译

make

出现问题
在这里插入图片描述
说明未安装gcc,使用命令安装gcc

yum install gcc

gcc安装完后make又出现了下面问题
在这里插入图片描述
原因是jemalloc重载了Linux下的ANSI C的malloc和free函数。解决办法:make时添加参数。

make MALLOC=libc

完成后进行,执行这个的目的就是将可执行文件拷贝到/usr/local/bin/目录下,这样就可以直接执行redis-server 、redis-cli 等命令了。

make install

在这里插入图片描述
5.查看版本

[root@VM_0_16_centos bin]# redis-server -v
Redis server v=5.0.5 sha=00000000:0 malloc=libc bits=64 build=57ca631c3a0a9413

6.启动服务

[root@VM_0_16_centos bin]# redis-server 
21136:C 23 Jul 2019 09:47:39.312 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
21136:C 23 Jul 2019 09:47:39.312 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=21136, just started
21136:C 23 Jul 2019 09:47:39.312 # 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: 21136
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

21136:M 23 Jul 2019 09:47:39.314 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
21136:M 23 Jul 2019 09:47:39.314 # Server initialized
21136:M 23 Jul 2019 09:47:39.314 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
21136:M 23 Jul 2019 09:47:39.314 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
21136:M 23 Jul 2019 09:47:39.314 * Ready to accept connections

7.重新打开终端,插入数据进行测试

[root@VM_0_16_centos ~]# redis-cli
127.0.0.1:6379> set name zhangsan
OK
127.0.0.1:6379> get name
"zhangsan"
127.0.0.1:6379> keys *
1) "name"
127.0.0.1:6379> 

8.设置后台运行

[root@VM_0_16_centos redis]# mkdir /etc/redis
[root@VM_0_16_centos redis]# cp redis.conf /etc/redis
[root@VM_0_16_centos redis]# vim /etc/redis/redis.conf 

找到"daemonize no" no改为yes你可以在命令行模式下输入/进行查找
在这里插入图片描述
在这里插入图片描述
指定配置文件后台启动redis

[root@VM_0_16_centos redis]# redis-server /etc/redis/redis.conf 
22528:C 23 Jul 2019 10:00:13.732 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
22528:C 23 Jul 2019 10:00:13.732 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=22528, just started
22528:C 23 Jul 2019 10:00:13.732 # Configuration loaded

9.redis开机启动
拷贝 redis 安装目前下的 /root/redis-5.0.5/utils/redis_init_script 到 /etc/init.d/redis文件中;

cp /root/redis-5.0.5/utils/redis_init_script /etc/init.d/redis

编辑/etc/init.d/redis文件

[root@VM_0_16_centos init.d]# vim redis 
	CONF="/etc/redis/redis.conf"(这路径是第八步的复制后的路径)
[root@VM_0_16_centos init.d]# chkconfig --add redis(这一步好像不用也可以)
[root@VM_0_16_centos init.d]# chkconfig redis on 
[root@VM_0_16_centos init.d]# service redis stop
Stopping ...
Redis stopped
[root@VM_0_16_centos init.d]# service redis start
Starting Redis server...

停止,开启

/etc/init.d/redis stop
/etc/init.d/redis start

10.连接RedisDesktopManager

[root@VM_0_16_centos ~]# vim /etc/redis/redis.conf

编辑Redis的配置文件,我这里是第八步自己创建的文件
在这里插入图片描述
记得重启redis

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值