ubuntu16.04 安装 操作 redis
2018-08-07 10:18
741 查看
安装redis
安装php-redis
检查redis进程
通过命令行访问redis 基本操作
设置redis 密码 123456
密码登录redis
开启redis远程连接
重启Redis服务器
检查Redis服务器占用端口
远程连接redis
命令号不带密码连接redis
apt-get installl redis-server
安装php-redis
apt-get installl php-redis
检查redis进程
ps -aux|grep redis
通过命令行访问redis 基本操作
root@ubuntu16:~# redis-cli # 查看所有的key列表 127.0.0.1:6319>keys * (empty list or set) # 增加一条记录key1 127.0.0.1:6379> set key1 "hello world" OK # 打印记录 redis 127.0.0.1:6379> get key1 "hello world" # 增加一条数字记录 127.0.0.1:6379> set key2 1 OK # 让数字自增 127.0.0.1:6379> INCR key2 (integer) 2 #增加一个列表记录key3 127.0.0.1:6379> LPUSH key3 a (integer) 1 # 从左边插入列表 127.0.0.1:6379> LPUSH key3 b (integer) 2 # 从右边插入列表 127.0.0.1:6379> RPUSH key3 c (integer) 3 # 打印列表记录,按从左到右的顺序 127.0.0.1:6379> LRANGE key3 0 3 1) "b" 2) "a" 3) "c" # 删除key1,key2 127.0.0.1:6379> del key1 (integer) 1 127.0.0.1:6379> del key2 (integer) 1
设置redis 密码 123456
vi /etc/redis/redis.conf #取消注释requirepass foobared requirepass 123456 #保存退出
密码登录redis
redis-cli -h 127.0.0.1 -a 123456 -p 6379 # 切记 -h -a -p 后面的空格必须有
开启redis远程连接
vi /etc/redis/redis.conf #注释bind 127.0.0.1 #bind 127.0.0.1
重启Redis服务器
service redis restart # 或者 /etc/init.d/redis-server restart
检查Redis服务器占用端口
root@ubuntu16:~# netstat -nlt|grep 6379 tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN
远程连接redis
root@ubuntu:~# redis-cli -h 192.168.159.129 -a 123456 -h 6379 192.168.129.129:6379>
命令号不带密码连接redis
root@ubuntu:~# redis-cli -h 192.168.159.129 -h 6379 192.168.129.129:6379>auth 123456 OK 192.168.129.129:6379>keys * 1) "key2" 1) "key1"
在Redis集群中使用认证密码
如果Redis服务器,使用了集群。除了在master中配置密码外,也需要在
slave中进行相应配置。在
slave的配置文件中找到如下行,去掉注释并修改与
master相同的密码即可:
# masterauth master-password
相关文章推荐
- ubuntu 16.04安装php7.0 redis扩展及使用php操作redis
- ubuntu 16.04安装redis(源码安装)zz
- 如何在Ubuntu 16.04上安装配置Redis
- Ubuntu 16.04安装Redis
- Ubuntu16.04 Redis的安装及设置redis开机启动
- Linux(Ubuntu16.04)下redis的安装,helloworld及读懂配置文件
- Ubuntu16.04安装Redis
- Linux上安装Redis(Ubuntu16.04+Redis3.2.8)最烦网上流传的那些根本走不通的教程
- Ubuntu16.04下安装redis并实现helloworld
- Linux上安装Redis(Ubuntu16.04+Redis3.2.8)
- Ubuntu16.04安装Redis
- ubuntu redis 集群安装,超简单多图细腻操作
- Ubuntu 16.04 主题美化及常用软件安装操作步骤图文解说
- [转]Ubuntu16.04下安装redis并实现helloworld
- Ubuntu16.04 Redis 安装
- Ubuntu下redis安装及其操作
- Ubuntu 16.04安装SQLite Browser操作SQLite数据库
- Redis在Linux Ubuntu中安装和操作
- Ubuntu16.04 上 Redis 4.0 及php-redis扩展的安装和使用
- ubuntu 16.04 安装完成之后的操作和设置 (一)