码迷,mamicode.com
首页 > 系统相关 > 详细

Ubuntu 安装Redis

时间:2017-02-20 23:04:24      阅读:409      评论:0      收藏:0      [点我收藏+]

标签:lda   echo   emd   建议   sudo   security   log   mod   oca   

在Ubuntu中安装Redis有两种方式,

我用的是Ubuntu自带的apt-get

什么的是apt-get:

高级包装工具(英语:Advanced Packaging Tools,简称:APT)是Debian及其衍生发行版(如:ubuntu)的软件包管理器。

APT可以自动下载,配置,安装二进制或者源代码格式的软 件包,因此简化了 Unix系统上管理软件的过程,apt-get命令一般需要root权限执行,所以一般跟着sudo命令。

在 Ubuntu 系统安装 Redi 可以使用以下命令:

$sudo apt-get update
$sudo apt-get install redis-server

启动 Redis

$ redis-server

查看 redis 是否启动?

$ redis-cli

以上命令将打开以下终端:

redis 127.0.0.1:6379>

127.0.0.1 是本机 IP ,6379 是 redis 服务端口。现在我们输入 PING 命令。

redis 127.0.0.1:6379> ping
PONG

以上说明我们已经成功安装了redis。

操作shell命令:

hongdada@ubuntu:~$ sudo
usage: sudo -h | -K | -k | -V
usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]
usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user]
            [command]
usage: sudo [-AbEHknPS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
            prompt] [-u user] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p
            prompt] [-u user] file ...
hongdada@ubuntu:~$ sudo apt-get update
[sudo] hongdada 的密码: 
获取:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
命中:2 http://us.archive.ubuntu.com/ubuntu xenial InRelease           
获取:3 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
命中:4 http://archive.ubuntukylin.com:10006/ubuntukylin xenial InRelease
获取:5 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
获取:6 http://us.archive.ubuntu.com/ubuntu xenial/main Translation-zh_CN [74.8 kB]
获取:7 http://us.archive.ubuntu.com/ubuntu xenial/restricted Translation-zh_CN [1,652 B]
获取:8 http://us.archive.ubuntu.com/ubuntu xenial/universe Translation-zh_CN [172 kB]
获取:9 http://us.archive.ubuntu.com/ubuntu xenial/multiverse Translation-zh_CN [4,984 B]
已下载 559 kB,耗时 14秒 (38.0 kB/s)                                  
E: 无法获得锁 /var/lib/dpkg/lock - open (11: 资源暂时不可用)
E: 无法锁定管理目录(/var/lib/dpkg/),是否有其他进程正占用它?
hongdada@ubuntu:~$ ^C
hongdada@ubuntu:~$ sodo rm /var/cache/apt/archives/lock
未找到 sodo 命令,您要输入的是否是:
 命令 todo 来自于包 devtodo (universe)
 命令 solo 来自于包 sgt-puzzles (universe)
 命令 sudo 来自于包 sudo-ldap (universe)
 命令 sudo 来自于包 sudo (main)
sodo:未找到命令
hongdada@ubuntu:~$ sudo rm /var/cache/apt/archives/lock
hongdada@ubuntu:~$ sudo rm /var/lib/dpkg/lock
hongdada@ubuntu:~$ sudo apt-get update
命中:1 http://archive.ubuntukylin.com:10006/ubuntukylin xenial InRelease
获取:2 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
命中:3 http://us.archive.ubuntu.com/ubuntu xenial InRelease
获取:4 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
获取:5 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
已下载 306 kB,耗时 8秒 (37.6 kB/s)                                   
正在读取软件包列表... 完成
hongdada@ubuntu:~$ sudo apt-get install redis-server
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
下列软件包是自动安装的并且现在不需要了:
  libpango1.0-0 libpangox-1.0-0
使用sudo apt autoremove来卸载它(它们)。
将会同时安装下列软件:
  libjemalloc1 redis-tools
建议安装:
  ruby-redis
下列【新】软件包将被安装:
  libjemalloc1 redis-server redis-tools
升级了 0 个软件包,新安装了 3 个软件包,要卸载 0 个软件包,有 27 个软件包未被升级。
需要下载 517 kB 的归档。
解压缩后会消耗 1,505 kB 的额外空间。
您希望继续执行吗? [Y/n] Y
获取:1 http://us.archive.ubuntu.com/ubuntu xenial/universe amd64 libjemalloc1 amd64 3.6.0-9ubuntu1 [78.9 kB]
获取:2 http://us.archive.ubuntu.com/ubuntu xenial/universe amd64 redis-tools amd64 2:3.0.6-1 [95.3 kB]
获取:3 http://us.archive.ubuntu.com/ubuntu xenial/universe amd64 redis-server amd64 2:3.0.6-1 [343 kB]
已下载 517 kB,耗时 37秒 (13.9 kB/s)                                  
正在选中未选择的软件包 libjemalloc1。
(正在读取数据库 ... 系统当前共安装有 205743 个文件和目录。)
正准备解包 .../libjemalloc1_3.6.0-9ubuntu1_amd64.deb  ...
正在解包 libjemalloc1 (3.6.0-9ubuntu1) ...
正在选中未选择的软件包 redis-tools。
正准备解包 .../redis-tools_2%3a3.0.6-1_amd64.deb  ...
正在解包 redis-tools (2:3.0.6-1) ...
正在选中未选择的软件包 redis-server。
正准备解包 .../redis-server_2%3a3.0.6-1_amd64.deb  ...
正在解包 redis-server (2:3.0.6-1) ...
正在处理用于 libc-bin (2.23-0ubuntu5) 的触发器 ...
正在处理用于 man-db (2.7.5-1) 的触发器 ...
正在处理用于 systemd (229-4ubuntu16) 的触发器 ...
正在处理用于 ureadahead (0.100.0-19) 的触发器 ...
正在设置 libjemalloc1 (3.6.0-9ubuntu1) ...
正在设置 redis-tools (2:3.0.6-1) ...
正在设置 redis-server (2:3.0.6-1) ...
正在处理用于 libc-bin (2.23-0ubuntu5) 的触发器 ...
正在处理用于 systemd (229-4ubuntu16) 的触发器 ...
正在处理用于 ureadahead (0.100.0-19) 的触发器 ...
hongdada@ubuntu:~$ redis-server
5703:C 20 Feb 22:02:38.206 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
5703:M 20 Feb 22:02:38.206 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ‘‘-._                                             
      _.-``    `.  `_.  ‘‘-._           Redis 3.0.6 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ‘‘-._                                   
 (          ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|` _.-|     Port: 6379
 |    `-._   `._    /     _.-    |     PID: 5703
  `-._    `-._  `-./  _.-    _.-                                   
 |`-._`-._    `-.__.-    _.-_.-|                                  
 |    `-._`-._        _.-_.-    |           http://redis.io        
  `-._    `-._`-.__.-_.-    _.-                                   
 |`-._`-._    `-.__.-    _.-_.-|                                  
 |    `-._`-._        _.-_.-    |                                  
  `-._    `-._`-.__.-_.-    _.-                                   
      `-._    `-.__.-    _.-                                       
          `-._        _.-                                           
              `-.__.-                                               

5703:M 20 Feb 22:02:38.206 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
5703:M 20 Feb 22:02:38.206 # Server started, Redis version 3.0.6
5703:M 20 Feb 22:02:38.206 # 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.
5703:M 20 Feb 22:02:38.206 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command echo never > /sys/kernel/mm/transparent_hugepage/enabled as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
5703:M 20 Feb 22:02:38.206 * The server is now ready to accept connections on port 6379

可以看出安装完成,其中有一个小的问题,在安装的过程中遇到的小麻烦,进程被占用,

E: 无法获得锁 /var/lib/dpkg/lock - open (11: 资源暂时不可用)
E: 无法锁定管理目录(/var/lib/dpkg/),是否有其他进程正占用它?
hongdada@ubuntu:~$ ^C
hongdada@ubuntu:~$ sodo rm /var/cache/apt/archives/lock
未找到 sodo 命令,您要输入的是否是:
 命令 todo 来自于包 devtodo (universe)
 命令 solo 来自于包 sgt-puzzles (universe)
 命令 sudo 来自于包 sudo-ldap (universe)
 命令 sudo 来自于包 sudo (main)
sodo:未找到命令
hongdada@ubuntu:~$ sudo rm /var/cache/apt/archives/lock
hongdada@ubuntu:~$ sudo rm /var/lib/dpkg/lock

 

 

 

http://www.cnblogs.com/langtianya/p/5187681.html

http://blog.csdn.net/zkp0601/article/details/41349253

Ubuntu 安装Redis

标签:lda   echo   emd   建议   sudo   security   log   mod   oca   

原文地址:http://www.cnblogs.com/hongdada/p/6421814.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!