- 安装Redis服务器端
~ sudo apt-get install redis-server
安装完成后,Redis服务器会自动启动,我们检查Redis服务器程序
- 检查Redis服务器系统进程
~ ps -aux|grep redis
redis 4162 0.1 0.0 10676 1420 ? Ss 23:24 0:00 /usr/bin/redis-server /etc/redis/redis.conf
conan 4172 0.0 0.0 11064 924 pts/0 S+ 23:26 0:00 grep --color=auto redis
3.1 检查Redis服务器状态 法1:
~ netstat -nlt|grep 6379
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN
3.2 检查Redis服务器状态 法2:
~$ sudo /etc/init.d/redis-server status
● redis-server.service - Advanced key-value store
Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
Active: active (running) since 四 2017-11-09 12:22:09 CST; 59s ago
Docs: http://redis.io/documentation,
man:redis-server(1)
Main PID: 5394 (redis-server)
CGroup: /system.slice/redis-server.service
└─5394 /usr/bin/redis-server 127.0.0.1:6379
8月 07 12:22:09 zzf systemd[1]: Starting Advanced key-value store...
8月 07 12:22:09 zzf run-parts[5388]: run-parts: executing /etc/redis/redi...le
8月 07 12:22:09 zzf run-parts[5395]: run-parts: executing /etc/redis/redi...le
8月 07 12:22:09 zzf systemd[1]: Started Advanced key-value store.
Hint: Some lines were ellipsized, use -l to show in full.
- 通过命令行客户端访问Redis
安装Redis服务器,会自动地一起安装Redis命令行客户端程序。
在本机输入redis-cli命令就可以启动,客户端程序访问Redis服务器。
~ redis-cli
redis 127.0.0.1:6379>
# 命令行的帮助
redis 127.0.0.1:6379> help
redis-cli 2.2.12
Type: "help @" to get a list of commands in
"help " for help on
"help " to get a list of possible help topics
"quit" to exit
# 查看所有的key列表
redis 127.0.0.1:6379> keys *
(empty list or set)
- 修改Redis的配置
~ sudo vi /etc/redis/redis.conf
……修改完成
~ sudo /etc/init.d/redis-server start
# 5.1 取消注释requirepass,设置密码
requirepass password
# 5.2 注释bind,让Redis服务器被远程访问
#bind 127.0.0.1
# 修改后,重启Redis服务器。
~ sudo /etc/init.d/redis-server restart
网友评论