腾讯云Centos7.2搭建redis5.0
程序员文章站
2022-04-17 13:26:26
...
安装
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.查看版本
[aaa@qq.com_0_16_centos bin]# redis-server -v
Redis server v=5.0.5 sha=00000000:0 malloc=libc bits=64 build=57ca631c3a0a9413
6.启动服务
[aaa@qq.com_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.重新打开终端,插入数据进行测试
[aaa@qq.com_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.设置后台运行
[aaa@qq.com_0_16_centos redis]# mkdir /etc/redis
[aaa@qq.com_0_16_centos redis]# cp redis.conf /etc/redis
[aaa@qq.com_0_16_centos redis]# vim /etc/redis/redis.conf
找到"daemonize no" no改为yes你可以在命令行模式下输入/进行查找
指定配置文件后台启动redis
[aaa@qq.com_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文件
[aaa@qq.com_0_16_centos init.d]# vim redis
CONF="/etc/redis/redis.conf"(这路径是第八步的复制后的路径)
[aaa@qq.com_0_16_centos init.d]# chkconfig --add redis(这一步好像不用也可以)
[aaa@qq.com_0_16_centos init.d]# chkconfig redis on
[aaa@qq.com_0_16_centos init.d]# service redis stop
Stopping ...
Redis stopped
[aaa@qq.com_0_16_centos init.d]# service redis start
Starting Redis server...
10.连接RedisDesktopManager
[aaa@qq.com_0_16_centos ~]# vim /etc/redis/redis.conf
编辑Redis的配置文件,我这里是第八步自己创建的文件
记得重启redis
上一篇: 62. 不同路径
下一篇: 406. 根据身高重建队列
推荐阅读
-
腾讯云centos7 从零搭建laravel项目
-
Django+vue在腾讯云上搭建前后端分离项目
-
腾讯云服务器linux Ubuntu操作系统搭建ftp服务器vsftpd
-
腾讯云+阿里云 搭建hadoop + hbase
-
Django从零搭建个人博客 | 通过IIS部署腾讯云Winsows服务器
-
腾讯云centos7.2安装mysql
-
云服务器(阿里云,百度云,华为云,腾讯云)搭建Hadoop(Nameode,SecondaryNamenode,datanode)
-
利用Qt/C++在腾讯云/阿里云服务器搭建TCP/IP协议实现网络通信以及Qt在linux下的安装和程序打包踩坑(详解)
-
腾讯云服务器搭建Jenkins详细介绍
-
Django+vue在腾讯云上搭建前后端分离项目