標籤:no sql 之redis安裝
摘錄百科:
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.gzResolving download.redis.io... 109.74.203.151Connecting to download.redis.io|109.74.203.151|:80... connected.HTTP request sent, awaiting response... 200 OKLength: 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]# lltotal 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 allmake[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-aofHint: 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 installHint: 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.conf12912: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.412912: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 6379tcp 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群
本文出自 “12087328” 部落格,請務必保留此出處http://12097328.blog.51cto.com/12087328/1856277
No SQL 之Redis安裝