摘录百科:
Redis是一个开源的使用ANSI C语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。从2010年3月15日起,Redis的开发工作由VMware主持。从2013年5月开始,Redis的开发由Pivotal赞助。
1、安装"Development tools"
[[email protected] src]# yum groupinstall "Development tools"
2、下载Redis
http://download.redis.io/releases/ 选择自己需要的版本
[[email protected] src]# wget http://download.redis.io/releases/redis-3.0.4.tar.gz --2016-09-25 10:40:04-- http://download.redis.io/releases/redis-3.0.4.tar.gz Resolving download.redis.io... 109.74.203.151 Connecting to download.redis.io|109.74.203.151|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1364993 (1.3M) [application/x-gzip] Saving to: `redis-3.0.4.tar.gz‘ 100%[=====================================================================================================================================================>] 1,364,993 31.0K/s in 39s 2016-09-25 10:40:46 (34.4 KB/s) - `redis-3.0.4.tar.gz‘ saved [1364993/1364993] [[email protected] src]# ll total 1336 -rw-r--r--. 1 root root 1364993 Sep 8 2015 redis-3.0.4.tar.gz [[email protected] src]#
3、编译安装
[[email protected] src]# tar xf redis-3.0.4.tar.gz [[email protected] src]# cd redis-3.0.4 [[email protected] redis-3.0.4]# make cd src && make all make[1]: Entering directory `/usr/local/src/redis-3.0.4/src‘ rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-dump redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html ... \\省略编译信息 CC redis-check-aof.o LINK redis-check-aof Hint: It‘s a good idea to run ‘make test‘ ;) make[1]: Leaving directory `/usr/local/src/redis-3.0.4/src‘ [[email protected] redis-3.0.4]# cd src/ [[email protected] src]# make install Hint: It‘s a good idea to run ‘make test‘ ;) INSTALL install INSTALL install INSTALL install INSTALL install INSTALL install [[email protected] src]#
4、简单配置并启动测试
[[email protected] src]# mkdir /usr/local/redis3.0.4/etc/ -p [[email protected] src]# mkdir /usr/local/redis3.0.4/bin/ -p [[email protected] src]# find . -perm 755 -o -perm 775| xargs -i cp {} /usr/local/redis3.0.4/bin/ [[email protected] src]# cd .. [[email protected] redis-3.0.4]# cp redis.conf /usr/local/redis3.0.4/etc/ [[email protected] redis-3.0.4]# ls /usr/local/redis3.0.4/{etc,bin} /usr/local/redis3.0.4/bin: mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-dump redis-cli redis-sentinel redis-server redis-trib.rb /usr/local/redis3.0.4/etc: redis.conf [[email protected] redis-3.0.4]# vim /usr/local/redis3.0.4/etc/redis.conf ... ################################ GENERAL ##################################### # By default Redis does not run as a daemon. Use ‘yes‘ if you need it. # Note that Redis will write a pid file in /var/run/redis.pid when daemonized. daemonize yes \\默认是no改为yes,这样启动就会在后台运行 #daemonize no ... :wq \\保存退出 [[email protected] redis-3.0.4]# ln -sv /usr/local/redis3.0.4/bin/* /usr/local/bin/ \\软连接到PATH去,这样就不用输入绝对路径,可以直接使用命令。 [[email protected] redis-3.0.4]# redis- \\瞧见没 redis-benchmark redis-check-aof redis-check-dump redis-cli redis-sentinel redis-server redis-trib.rb [[email protected] redis-3.0.4]# redis-server /usr/local/redis3.0.4/etc/redis.conf \\启动Redis,必须制定配置文件,不然出现如下情况 [[email protected] redis-3.0.4]# redis-server 12912:C 25 Sep 10:58:42.547 # Warning: 注意这里-->no config file specified, using the default config.<--注意这里 In order to specify a config file use redis-server /path/to/redis.conf 12912:M 25 Sep 10:58:42.548 * Increased maximum number of open files to 10032 (it was originally set to 1024). _._ _.-``__ ‘‘-._ _.-`` `. `_. ‘‘-._ Redis 3.0.4 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ‘‘-._ ( ‘ , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|‘` _.-‘| Port: 6379 | `-._ `._ / _.-‘ | PID: 12912 `-._ `-._ `-./ _.-‘ _.-‘ |`-._`-._ `-.__.-‘ _.-‘_.-‘| | `-._`-._ _.-‘_.-‘ | http://redis.io `-._ `-._`-.__.-‘_.-‘ _.-‘ |`-._`-._ `-.__.-‘ _.-‘_.-‘| | `-._`-._ _.-‘_.-‘ | `-._ `-._`-.__.-‘_.-‘ _.-‘ `-._ `-.__.-‘ _.-‘ `-._ _.-‘ `-.__.-‘ 12912:M 25 Sep 10:58:42.550 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 12912:M 25 Sep 10:58:42.550 # Server started, Redis version 3.0.4 12912:M 25 Sep 10:58:42.550 # 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. 12912:M 25 Sep 10:58:42.550 # 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. 12912:M 25 Sep 10:58:42.550 * The server is now ready to accept connections on port 6379<--这里会无休止提示,并且还会占用我们的session,session关闭则服务停止,这也是为什么配置文件我只强调“daemonize yes \\默认是no改为yes,这样启动就会在后台运行” \\下面是正常启动访问关闭 [[email protected] redis-3.0.4]# netstat -tunlp| grep 6379 tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 12827/redis-server tcp 0 0 :::6379 :::* LISTEN 12827/redis-server [[email protected] redis-3.0.4]# redis-cli 127.0.0.1:6379> exit [[email protected] redis-3.0.4]# redis-cli shutdown [[email protected] redis-3.0.4]# netstat -tunlp| grep 6379 [[email protected] redis-3.0.4]#
至此Redis的简单配置就OK拉,具体需求具体配置,配置文件参数度娘即可获得。
欢迎大家关注 459479177QQ群
时间: 2024-12-18 21:00:29