Centos7 linux下通过源码安装redis以及使用

下载redis安装包

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

解压压缩包

tar -zxvf redis-5.0..tar.gz

yum安装gcc依赖

[root@iZwz991stxdwj560bfmadtZ local]# yum -y install gcc

跳转到redis解压目录下

cd redis-5.0.

编译

[root@iZwz991stxdwj560bfmadtZ redis-5.0.]# make MALLOC=libc

安装

[root@iZwz991stxdwj560bfmadtZ redis-4.0.]# cd src && make install
CC Makefile.dep Hint: It's a good idea to run 'make test' ;) INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install

测试是否能够启动redis

[root@iZwz991stxdwj560bfmadtZ src]# redis-server
:C Dec ::12.507 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
:C Dec ::12.507 # Redis version=4.0., bits=, commit=, modified=, pid=, just started
:C Dec ::12.507 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 4.0. (/) bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port:
| `-._ `._ / _.-' | PID: 18685
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-' :M Dec ::12.508 # WARNING: The TCP backlog setting of cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of .
:M Dec ::12.508 # Server initialized
:M Dec ::12.508 # WARNING overcommit_memory is set to ! 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.
:M Dec ::12.508 # 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.
:M Dec ::12.508 * Ready to accept connections

移动目录

sudo mv redis-5.0. /usr/local/redis

修改配置文件(后台运行)

sudo vi /usr/local/redis/redis.conf 

daemonize no

修改为

daemonize yes

使用配置文件启动

redis-server /usr/local/redis/redis.conf

关闭redis

首先使用ps -aux | grep redis查看redis进程

[root@iZwz991stxdwj560bfmadtZ src]# ps -aux | grep redis
root 0.0 0.1 ? Ssl : : ./redis-server 127.0.0.1:
root 0.0 0.0 pts/ R+ : : grep --color=auto redis

使用kill命令杀死进程

[root@iZwz991stxdwj560bfmadtZ src]# kill -9 18714

客户端连接

[root@localhost bin]# redis-cli
127.0.0.1:>

参考:

https://www.cnblogs.com/zuidongfeng/p/8032505.html

上一篇:【随机】概率分析——cf1364E


下一篇:一维指针和一维数组