1、Installation
Download, extract and compile Redis with:
$ wget http://download.redis.io/releases/redis-4.0.11.tar.gz
$ tar xzf redis-4.0.11.tar.gz
$ cd redis-4.0.11
$ make
The binaries that are now compiled are available in the src directory. Run Redis with:
$ src/redis-server
You can interact with Redis using the built-in client:
$ src/redis-cli
redis> set foo bar
OK
redis> get foo
"bar"
2、常用配置修改
requirepass 123456
protected-mode no
#bind 127.0.0.1
注意防火墙
3、Redis的启动方式
1.直接启动
进入redis根目录,执行命令:
#加上‘&’号使redis以后台程序方式运行
./redis-server &
2.通过指定配置文件启动
可以为redis服务启动指定配置文件,例如配置为/etc/redis/6379.conf
进入redis根目录,输入命令:
./redis-server /etc/redis/6379.conf
#如果更改了端口,使用`redis-cli`客户端连接时,也需要指定端口,例如:
redis-cli -p 6380
以后台程序方式运行redis
cd /usr/local/redis-4.0.11/src
./redis-server /usr/local/redis-4.0.11/redis.conf &
--------------------------------------------------------------------
cd /root/redis-4.0.11/src
./redis-server /root/redis-4.0.11/redis.conf &
--------------------------------------------------------------------
客户端启动
cd /usr/local/redis-4.0.11/src
./redis-cli -h 127.0.0.1 -p 6379 -a 123456
----------------------------------------------------------------------------------------------------------------------