1.apt-get install redis-server

2. 检查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.通过启动命令检查Redis服务器状态 ~ netstat -nlt|grep 6379

tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN

4.通过启动命令检查Redis服务器状态 ~ sudo /etc/init.d/redis-server status

redis-server is running

安装redis-server的时候客户端命令也一起安装了,所以使用redis-cli 就可以进入客户端

~ redis-cli
redis 127.0.0.1:> # 命令行的帮助
redis 127.0.0.1:> help
redis-cli 2.2.
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:> keys *
(empty list or set)

测试:

127.0.0.1:> keys *
(empty list or set)
127.0.0.1:> set key "my name is yuwensong";
Invalid argument(s)
127.0.0.1:> set key "my name is yuwensong"
OK
127.0.0.1:> key *
(error) ERR unknown command 'key'
127.0.0.1:> keys *
) "key"
127.0.0.1:> get key
"my name is yuwensong"
127.0.0.1:>
# 增加一条数字记录key2
set key2
OK # 让数字自增
redis 127.0.0.1:> INCR key2
(integer)
redis 127.0.0.1:> INCR key2
(integer) # 打印记录
redis 127.0.0.1:> get key2
""
# 增加一个列表记录key3
redis 127.0.0.1:> LPUSH key3 a
(integer) # 从左边插入列表
redis 127.0.0.1:> LPUSH key3 b
(integer) # 从右边插入列表
redis 127.0.0.1:> RPUSH key3 c
(integer) # 打印列表记录,按从左到右的顺序
redis 127.0.0.1:> LRANGE key3
) "b"
) "a"
) "c"
# 增加一个哈希记表录key4
redis 127.0.0.1:> HSET key4 name "John Smith"
(integer) # 在哈希表中插入,email的Key和Value的值
redis 127.0.0.1:> HSET key4 email "abc@gmail.com"
(integer) # 打印哈希表中,name为key的值
redis 127.0.0.1:> HGET key4 name
"John Smith" # 打印整个哈希表
redis 127.0.0.1:> HGETALL key4
) "name"
) "John Smith"
) "email"
) "abc@gmail.com"
增加一条哈希表记录key5

# 增加一条哈希表记录key5,一次插入多个Key和value的值
redis 127.0.0.1:> HMSET key5 username antirez password P1pp0 age
OK # 打印哈希表中,username和age为key的值
redis 127.0.0.1:> HMGET key5 username age
) "antirez"
) "" # 打印完整的哈希表记录
redis 127.0.0.1:> HGETALL key5
) "username"
) "antirez"
) "password"
) "P1pp0"
) "age"
) ""
删除记录

# 查看所有的key列表
redis 127.0.0.1:> keys *
) "key2"
) "key3"
) "key4"
) "key5"
) "key1" # 删除key1,key5
redis 127.0.0.1:> del key1
(integer)
redis 127.0.0.1:> del key5
(integer) # 查看所有的key列表
redis 127.0.0.1:> keys *
) "key2"
) "key3"
) "key4"
. 修改Redis的配置

4.1 使用Redis的访问账号

默认情况下,访问Redis服务器是不需要密码的,为了增加安全性我们需要设置Redis服务器的访问密码。设置访问密码为redisredis。

用vi打开Redis服务器的配置文件redis.conf

~ sudo vi /etc/redis/redis.conf

#取消注释requirepass
requirepass redisredis 4.2 让Redis服务器被远程访问 默认情况下,Redis服务器不允许远程访问,只允许本机访问,所以我们需要设置打开远程访问的功能。 用vi打开Redis服务器的配置文件redis.conf ~ sudo vi /etc/redis/redis.conf #注释bind
#bind 127.0.0.1 修改后,重启Redis服务器。 ~ sudo /etc/init.d/redis-server restart
Stopping redis-server: redis-server.
Starting redis-server: redis-server. 未使用密码登陆Redis服务器 ~ redis-cli redis 127.0.0.1:> keys *
(error) ERR operation not permitted 发现可以登陆,但无法执行命令了。 登陆Redis服务器,输入密码 ~ redis-cli -a redisredis redis 127.0.0.1:> keys *
) "key2"
) "key3"
) "key4" 登陆后,一切正常。
我们检查Redis的网络监听端口

检查Redis服务器占用端口
~ netstat -nlt|grep
tcp 0.0.0.0: 0.0.0.0:* LISTEN 我们看到从之间的网络监听从 127.0.0.1: 变成 0.0.0.0:,表示Redis已经允许远程登陆访问。 我们在远程的另一台Linux访问Redis服务器 ~ redis-cli -a redisredis -h 192.168.1.199 redis 192.168.1.199:> keys *
) "key2"
) "key3"
) "key4" 远程访问正常。通过上面的操作,我们就把Redis数据库服务器,在Linux Ubuntu中的系统安装完成

ubuntu 中安装redis的更多相关文章

  1. 在Ubuntu中安装Redis

    原文地址:http://blog.fens.me/linux-redis-install/ 在Ubuntu中安装Redis R利剑NoSQL系列文章,主要介绍通过R语言连接使用nosql数据库.涉及的 ...

  2. 转】在Ubuntu中安装Redis

    不多说,直接上干货! 原博文出自于: http://blog.fens.me/category/%E6%95%B0%E6%8D%AE%E5%BA%93/ 感谢! 在Ubuntu中安装Redis R利剑 ...

  3. Ubuntu中安装redis

    第一种方式在线安装首要前提安装c语言编译环境,命令如下:$sudo apt-get install gcc 安装完成后可以输入$gcc --version查看版本 1.获取源码:$wget https ...

  4. ubuntu 中安装 Redis

    1.下载安装root@21ebdf03a086:/# apt-cache search redisroot@21ebdf03a086:/# apt-get install redis-server a ...

  5. 转】在Ubuntu中安装Cassandra

    原博文出自于: http://blog.fens.me/category/%E6%95%B0%E6%8D%AE%E5%BA%93/ 感谢! Posted: Mar 22, 2014 Tags: cas ...

  6. 【转】在Ubuntu中安装HBase

    原博客出自于: http://blog.fens.me/category/%E6%95%B0%E6%8D%AE%E5%BA%93/ 感谢! Posted: Apr 3, 2014 Tags: Hado ...

  7. 如何在win7系统中安装redis

    转载于:http://www.itxuexiwang.com/a/shujukujishu/redis/2016/0216/92.html?1455871954 如何在win7系统中安装redis​ ...

  8. 在ubuntu中安装maven

    安装环境 操作系统:ubuntu 14.04.1 server amd64 安装jdk 在安装maven之前,必须确保已经安装过jdk. 安装jdk的方法请参考文章<在ubuntu中安装jdk& ...

  9. ubuntu中安装Docker

    系统要求: 必须时64位的系统,内核最低要求是3.10 查看系统内核: $ uname -r 3.11.0-15-generic 获取最新版本打Docker: $ wget -qO- https:// ...

随机推荐

  1. mongodb的分布式集群(2、副本集)

    概述        副本集是主从复制的一种,是一种自带故障转移功能的主从复制.攻克了上述主从复制的缺点.实现主server发生问题后.不需人为介入.系统自己主动从新选举一个新的主server的功能. ...

  2. git使用教程1-本地代码上传到github

    前言 不会使用github都不好意思说自己是码农,github作为一个开源的代码仓库管理平台,我们可以把自己的代码放到github上,分享给小伙伴,自己也能随时随地同步更新代码. 问题来了:为什么越来 ...

  3. Linux进程间通信—消息队列

    四.消息队列(Message Queue) 消息队列就是消息的一个链表,它允许一个或者多个进程向它写消息,一个或多个进程向它读消息.Linux维护了一个消息队列向量表:msgque,来表示系统中所有的 ...

  4. iOS:风火轮活动刷新视图控件UIActivityIndicatorView的详细使用

    动态风火轮视图控件:UIActivityIndicatorView   介绍:它是一种类似于风火轮旋转的视图控件,可用作刷新数据时显示加载过程所用,继承自UIView.   类型: typedef N ...

  5. Error: Finish can only be called once

    Android studio 启动或者新建项目:报错“Error: Finish can only be called once” gradle缓存问题: 默认的额缓存路径在: on windows ...

  6. sqlmap使用帮助文档(1)

    当给sqlmap这么一个url的时候,它会: 1.判断可注入的参数 2.判断可以用那种SQL注入技术来注入 3.识别出哪种数据库 4.根据用户选择,读取哪些数据 sqlmap支持五种不同的注入模式: ...

  7. 第三章 线程安全的DateFormat工具类

    1.使用threadLocal包装DateFormat(太复杂,不推荐) 2.使用org.apache.commons.lang3.time.DateFormatUtils下的方法(推荐) DateF ...

  8. STL之set集合容器 【转】

    set集合容器实现了红黑树(Red-Black Tree)的平衡二叉检索树的的数据结构,在插入元素时,它会自动调整二叉树的排列,把该元素放到适当的位置,以确保每个子树根节点的键值大于左子树所有节点的键 ...

  9. json 数组操作

    用js有很久了,但都没有深究过js的数组形式.这段时间做的一个项目,用到数组的地方很多,自以为js还可以的自己居然无从下手,一下狠心,我学!呵呵. 1.数组的创建 var arrayObj = new ...

  10. 正向代理/反向代理理解、Nginx概述、安装及配置详解

    一.Nginx概述 nginx是一款自由的.开源的.高性能的HTTP服务器和反向代理服务器:同时也是一个IMAP.POP3.SMTP代理服务器:nginx可以作为一个HTTP服务器进行网站的发布处理, ...