日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

十一.安装Redis

發布時間:2025/6/17 数据库 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 十一.安装Redis 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

redis是一個NOSql數據庫,在java web中,經常用來存儲session等,官網是https://redis.io/

當前官網指出的穩定版本為3.2.6,下載地址為http://download.redis.io/releases/redis-3.2.6.tar.gz

1.下載redis

[root@iZ25ufmpy4sZ local]# wget http://download.redis.io/releases/redis-3.2.6.tar.gz --2017-01-18 16:44:49-- http://download.redis.io/releases/redis-3.2.6.tar.gz Resolving download.redis.io (download.redis.io)... 109.74.203.151 Connecting to download.redis.io (download.redis.io)|109.74.203.151|:80... failed: Connection timed out. Retrying.--2017-01-18 16:46:57-- (try: 2) http://download.redis.io/releases/redis-3.2.6.tar.gz Connecting to download.redis.io (download.redis.io)|109.74.203.151|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1544806 (1.5M) [application/x-gzip] Saving to: ‘redis-3.2.6.tar.gz’100%[======================================================================================================================================================================================>] 1,544,806 1.40MB/s in 1.1s 2017-01-18 16:46:59 (1.40 MB/s) - ‘redis-3.2.6.tar.gz’ saved [1544806/1544806]

2.解壓

[root@iZ25ufmpy4sZ local]# tar -xvf redis-3.2.6.tar.gz

3.進入redis目錄并make

[root@iZ25ufmpy4sZ local]# cd redis-3.2.6 [root@iZ25ufmpy4sZ redis-3.2.6]# ls 00-RELEASENOTES BUGS CONTRIBUTING COPYING deps INSTALL Makefile MANIFESTO README.md redis.conf runtest runtest-cluster runtest-sentinel sentinel.conf src tests utils [root@iZ25ufmpy4sZ redis-3.2.6]# make cd src && make all make[1]: Entering directory `/usr/local/redis-3.2.6/src' rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html (cd ../deps && make distclean) make[2]: Entering directory `/usr/local/redis-3.2.6/deps' make[1]: Leaving directory `/usr/local/redis-3.2.6/src'

4.進入src目錄make install

[root@iZ25ufmpy4sZ redis-3.2.6]# cd src/ [root@iZ25ufmpy4sZ src]# ls adlist.c anet.o cluster.h debug.c geo.o lzf_d.c networking.o quicklist.o redis-check-aof.c release.h sds.o slowlog.h t_hash.o valgrind.sup adlist.h aof.c cluster.o debugmacro.h help.h lzf_d.o notify.c rand.c redis-check-aof.o release.o sentinel.c slowlog.o t_list.c version.h adlist.o aof.o config.c debug.o hyperloglog.c lzf.h notify.o rand.h redis-check-rdb replication.c sentinel.o solarisfixes.h t_list.o ziplist.c ae.c asciilogo.h config.h dict.c hyperloglog.o lzfP.h object.c rand.o redis-check-rdb.c replication.o server.c sort.c t_set.c ziplist.h ae_epoll.c bio.c config.o dict.h intset.c Makefile object.o rdb.c redis-check-rdb.o rio.c server.h sort.o t_set.o ziplist.o ae_evport.c bio.h crc16.c dict.o intset.h Makefile.dep pqsort.c rdb.h redis-cli rio.h server.o sparkline.c t_string.c zipmap.c ae.h bio.o crc16.o endianconv.c intset.o memtest.c pqsort.h rdb.o redis-cli.c rio.o setproctitle.c sparkline.h t_string.o zipmap.h ae_kqueue.c bitops.c crc64.c endianconv.h latency.c memtest.o pqsort.o redisassert.h redis-cli.o scripting.c setproctitle.o sparkline.o t_zset.c zipmap.o ae.o bitops.o crc64.h endianconv.o latency.h mkreleasehdr.sh pubsub.c redis-benchmark redis-sentinel scripting.o sha1.c syncio.c t_zset.o zmalloc.c ae_select.c blocked.c crc64.o fmacros.h latency.o multi.c pubsub.o redis-benchmark.c redis-server sdsalloc.h sha1.h syncio.o util.c zmalloc.h anet.c blocked.o db.c geo.c lzf_c.c multi.o quicklist.c redis-benchmark.o redis-trib.rb sds.c sha1.o testhelp.h util.h zmalloc.o anet.h cluster.c db.o geo.h lzf_c.o networking.c quicklist.h redis-check-aof release.c sds.h slowlog.c t_hash.c util.o [root@iZ25ufmpy4sZ src]# make installHint: It's a good idea to run 'make test' ;) INSTALL installINSTALL installINSTALL installINSTALL installINSTALL install

5.此時啟動,只要運行scr目錄下的redis-server,但是不符合Linux管理,建議在Nginx根目錄下創建一個bin和etc來分別存放系統文件和配置文件,如下

[root@iZ25ufmpy4sZ redis-3.2.6]# pwd /usr/local/redis-3.2.6 [root@iZ25ufmpy4sZ redis-3.2.6]# mkdir bin [root@iZ25ufmpy4sZ redis-3.2.6]# mkdir etc [root@iZ25ufmpy4sZ redis-3.2.6]# ls 00-RELEASENOTES bin BUGS CONTRIBUTING COPYING deps etc INSTALL Makefile MANIFESTO README.md redis.conf runtest runtest-cluster runtest-sentinel sentinel.conf src tests utils View Code

6.copy對應文件到bin和etc目錄下

[root@iZ25ufmpy4sZ redis-3.2.6]# cd src [root@iZ25ufmpy4sZ src]# ls adlist.c anet.o cluster.h debug.c geo.o lzf_d.c networking.o quicklist.o redis-check-aof.c release.h sds.o slowlog.h t_hash.o valgrind.sup adlist.h aof.c cluster.o debugmacro.h help.h lzf_d.o notify.c rand.c redis-check-aof.o release.o sentinel.c slowlog.o t_list.c version.h adlist.o aof.o config.c debug.o hyperloglog.c lzf.h notify.o rand.h redis-check-rdb replication.c sentinel.o solarisfixes.h t_list.o ziplist.c ae.c asciilogo.h config.h dict.c hyperloglog.o lzfP.h object.c rand.o redis-check-rdb.c replication.o server.c sort.c t_set.c ziplist.h ae_epoll.c bio.c config.o dict.h intset.c Makefile object.o rdb.c redis-check-rdb.o rio.c server.h sort.o t_set.o ziplist.o ae_evport.c bio.h crc16.c dict.o intset.h Makefile.dep pqsort.c rdb.h redis-cli rio.h server.o sparkline.c t_string.c zipmap.c ae.h bio.o crc16.o endianconv.c intset.o memtest.c pqsort.h rdb.o redis-cli.c rio.o setproctitle.c sparkline.h t_string.o zipmap.h ae_kqueue.c bitops.c crc64.c endianconv.h latency.c memtest.o pqsort.o redisassert.h redis-cli.o scripting.c setproctitle.o sparkline.o t_zset.c zipmap.o ae.o bitops.o crc64.h endianconv.o latency.h mkreleasehdr.sh pubsub.c redis-benchmark redis-sentinel scripting.o sha1.c syncio.c t_zset.o zmalloc.c ae_select.c blocked.c crc64.o fmacros.h latency.o multi.c pubsub.o redis-benchmark.c redis-server sdsalloc.h sha1.h syncio.o util.c zmalloc.h anet.c blocked.o db.c geo.c lzf_c.c multi.o quicklist.c redis-benchmark.o redis-trib.rb sds.c sha1.o testhelp.h util.h zmalloc.o anet.h cluster.c db.o geo.h lzf_c.o networking.c quicklist.h redis-check-aof release.c sds.h slowlog.c t_hash.c util.o [root@iZ25ufmpy4sZ src]# cp redis-benchmark redis-check-aof redis-cli redis-server ../bin [root@iZ25ufmpy4sZ src]# cd ../bin [root@iZ25ufmpy4sZ bin]# ls redis-benchmark redis-check-aof redis-cli redis-server

7.修改配置文件redis.cnf,把屬性daemonize改為yes

# Close the connection after a client is idle for N seconds (0 to disable) timeout 0# TCP keepalive. # # If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence # of communication. This is useful for two reasons: # # 1) Detect dead peers. # 2) Take the connection alive from the point of view of network # equipment in the middle. # # On Linux, the specified value (in seconds) is the period used to send ACKs. # Note that to close the connection the double of the time is needed. # On other kernels the period depends on the kernel configuration. # # A reasonable value for this option is 300 seconds, which is the new # Redis default starting with Redis 3.2.1. tcp-keepalive 300################################# 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# If you run Redis from upstart or systemd, Redis can interact with your # supervision tree. Options: # supervised no - no supervision interaction # supervised upstart - signal upstart by putting Redis into SIGSTOP mode # supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET # supervised auto - detect upstart or systemd method based on # UPSTART_JOB or NOTIFY_SOCKET environment variables # Note: these supervision methods only signal "process is ready." # They do not enable continuous liveness pings back to your supervisor. supervised no# If a pid file is specified, Redis writes it where specified at startup # and removes it at exit. # # When the server runs non daemonized, no pid file is created if none is # specified in the configuration. When the server is daemonized, the pid file # is used even if not specified, defaulting to "/var/run/redis.pid". # # Creating a pid file is best effort: if Redis is not able to create it # nothing bad happens, the server will start and run normally. pidfile /var/run/redis_6379.pid

?

8.啟動redis

[root@iZ25ufmpy4sZ bin]# ./redis-server ../etc/redis.conf _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 3.2.6 (00000000/0) 64 bit.-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379| `-._ `._ / _.-' | PID: 4496`-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 4496:M 18 Jan 17:10:46.374 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 4496:M 18 Jan 17:10:46.374 # Server started, Redis version 3.2.6 4496:M 18 Jan 17:10:46.374 # 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. 4496:M 18 Jan 17:10:46.374 # 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. 4496:M 18 Jan 17:10:46.374 * The server is now ready to accept connections on port 6379

9.如果還是覺得麻煩,可以在redis根目錄創建兩個腳本,start.sh和stop.sh,內容分別如下

[root@iZ25ufmpy4sZ redis]# ls 00-RELEASENOTES bin BUGS CONTRIBUTING COPYING deps dump.rdb etc INSTALL Makefile MANIFESTO README.md redis.conf runtest runtest-cluster runtest-sentinel sentinel.conf src start.sh stop.sh tests utils [root@iZ25ufmpy4sZ redis]# cat start.sh /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf [root@iZ25ufmpy4sZ redis]# cat stop.sh /usr/local/redis/bin/redis-cli shutdown

?

轉載于:https://www.cnblogs.com/qizhelongdeyang/p/6297582.html

總結

以上是生活随笔為你收集整理的十一.安装Redis的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。