作者:手机用户2502894761 | 来源:互联网 | 2023-10-14 15:33
直接从网上下载redis当然你也可以直接从别的地方拿过来直接放在redis中[root@iZ2zedckzf8nczp6xshv4mZ]#wgethttp:download
// 直接从网上下载 redis 当然你也可以直接从别的地方拿过来直接放在redis中
[root@iZ2zedckzf8nczp6xshv4mZ /]# wget http://download.redis.io/releases/redis-2.6.14.tar.gz
-------------------------------------------------------------------------------------------------------------------------------------
// 第一步中的压缩包进行解压
[root@iZ2zedckzf8nczp6xshv4mZ /]# tar zxvf redis-2.6.14.tar.gz
-----------------------------------------------------------------------------------------------------------------------------------
// 解压之后会产生一个文件夹名字是redis-2.6.14,直接进入这个文件夹中
root@iZ2zedckzf8nczp6xshv4mZ /]# cd redis-2.6.14
[root@iZ2zedckzf8nczp6xshv4mZ redis-2.6.14]# ls
00-RELEASENOTES COPYING Makefile redis.conf src
BUGS deps MANIFESTO runtest tests
CONTRIBUTING INSTALL README sentinel.conf utils
----------------------------------------------------------------------------------------------------------------------------------
// 直接进行make 编译操作,编译完成之后并不需要make install
[root@iZ2zedckzf8nczp6xshv4mZ redis-2.6.14]# make
编译完成之后出现:
Hint: To run 'make test' is a good idea ;)
make[1]: Leaving directory `/redis-2.6.14/src'
表明编译完成直接进行下一步
---------------------------------------------------------------------------------------------
// 直接进入此时目录下的src目录中
[root@iZ2zedckzf8nczp6xshv4mZ redis-2.6.14]# cd src
[root@iZ2zedckzf8nczp6xshv4mZ src]# ls
adlist.c debug.c networking.c redis.h syncio.c
adlist.h debug.o networking.o redis.o syncio.o
adlist.o dict.c object.c redis-sentinel testhelp.h
ae.c dict.h object.o redis-server t_hash.c
ae_epoll.c dict.o pqsort.c release.c t_hash.o
ae_evport.c endianconv.c pqsort.h release.h t_list.c
ae.h endianconv.h pqsort.o release.o t_list.o
ae_kqueue.c endianconv.o pubsub.c replication.c t_set.c
ae.o fmacros.h pubsub.o replication.o t_set.o
ae_select.c help.h rand.c rio.c t_string.c
anet.c intset.c rand.h rio.h t_string.o
anet.h intset.h rand.o rio.o t_zset.c
anet.o intset.o rdb.c scripting.c t_zset.o
aof.c lzf_c.c rdb.h scripting.o util.c
aof.o lzf_c.o rdb.o sds.c util.h
asciilogo.h lzf_d.c redis-benchmark sds.h util.o
bio.c lzf_d.o redis-benchmark.c sds.o valgrind.sup
bio.h lzf.h redis-benchmark.o sentinel.c version.h
bio.o lzfP.h redis.c sentinel.o ziplist.c
bitops.c Makefile redis-check-aof sha1.c ziplist.h
bitops.o Makefile.dep redis-check-aof.c sha1.h ziplist.o
config.c memtest.c redis-check-aof.o sha1.o zipmap.c
config.h memtest.o redis-check-dump slowlog.c zipmap.h
config.o migrate.c redis-check-dump.c slowlog.h zipmap.o
crc64.c migrate.o redis-check-dump.o slowlog.o zmalloc.c
crc64.o mkreleasehdr.sh redis-cli solarisfixes.h zmalloc.h
db.c multi.c redis-cli.c sort.c zmalloc.o
里面中的有一个 redis-server redis-cli 使用来启动redis和服务器端和客户端
需要把这两个文件复制到另一个文件中例如 此时创建创建一个文件夹
[root@iZ2zedckzf8nczp6xshv4mZ src]# mkdir /usr/local/redis
//把两个文件放在这个新创建的文件中
cp redis-cli redis-server /usr/local/redis
----------------------------------------------------------------------------------------------
// 我们直接在这个文件中运行 redis-server
[root@iZ2zedckzf8nczp6xshv4mZ redis-2.6.14]# cd /usr/local/redis
[root@iZ2zedckzf8nczp6xshv4mZ redis]# ./redis-server
出现这个:
[6342] 04 Jul 18:47:10.937 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.6.14 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 6342
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[6342] 04 Jul 18:47:10.939 # Server started, Redis version 2.6.14
[6342] 04 Jul 18:47:10.939 # 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.
[6342] 04 Jul 18:47:10.939 * The server is now ready to accept connections on port 6379
---------------------------------------------------------------------------------------------------------------------------------------------
//这种启动的方法是前端的启动方法,实际上我们可不希望还要每次在终端去运行这个命令,所以我们需要另外的处理,把.src 同级目录下的redis.conf也要复制到新建的那个文件夹中
[root@iZ2zedckzf8nczp6xshv4mZ redis-2.6.14]# cp redis.conf /usr/local/redis
------------------------------------------------------------------------------------------------------------------------------------------------
//然后对这个redis.conf 进行中的内容进行更改:
[root@iZ2zedckzf8nczp6xshv4mZ redis]# vim redis.conf
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# 1gb => 1024*1024*1024 bytes
#
# units are case insensitive so 1GB 1Gb 1gB are all the same.
# 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
# When running daemonized, Redis writes a pid file in /var/run/redis.pid by
# default. You can specify a custom pid file location here.
pidfile /var/run/redis.pid
把你的内容中的这个改成我的这个样子daemonize yes
然后进行保存即可:
----------------------------------------------------------------------
接下来按照下面的命令进行启动
[root@iZ2zedckzf8nczp6xshv4mZ redis]# ./redis-server redis.conf
运行下面 的语句之后发现存在进程说明服务器已经正常启动
[root@iZ2zedckzf8nczp6xshv4mZ redis]# ps -A | grep redis
6354 ? 00:00:00 redis-server
-------------------------------------------------------------
[root@iZ2zedckzf8nczp6xshv4mZ redis]# ./redis-cli
redis 127.0.0.1:6379> set name tom
OK
// 启动客户端操作发现已经可以正常使用了