zoukankan      html  css  js  c++  java
  • redis的安装(ubuntu版本)

    1.使用apt-get命令进行安装

    安装gcc依赖

    root@yatces-virtual-machine:~# apt-get update
    
    root@yatces-virtual-machine:~# apt-get install gcc

    安装redis-server

    root@yatces-virtual-machine:~# apt-get install redis-server

    安装位置

    root@yatces-virtual-machine:/etc# whereis redis
    redis: /etc/redis
    root@yatces-virtual-machine:/etc/redis# ll
    total 76
    drwxr-xr-x 6 root root 4096 8月 22 11:06 ./
    drwxr-xr-x 131 root root 12288 8月 22 11:06 ../
    -rw-r----- 1 redis redis 41623 12月 19 2015 redis.conf
    drwxr-xr-x 2 root root 4096 8月 22 11:06 redis-server.post-down.d/
    drwxr-xr-x 2 root root 4096 8月 22 11:06 redis-server.post-up.d/
    drwxr-xr-x 2 root root 4096 8月 22 11:06 redis-server.pre-down.d/
    drwxr-xr-x 2 root root 4096 8月 22 11:06 redis-server.pre-up.d/

    启动 redis

    root@yatces-virtual-machine:~# redis-server  #如果修改为后台进程启动方式:修改redis.conf 文件中的 daemonize no 为 yes

    客户端连接

    root@yatces-virtual-machine:~# redis-cli
    127.0.0.1:6379> set k1 helloworld
    OK
    127.0.0.1:6379> get k1
    "helloworld"

    卸载

    使用命令:dpkg --list查看使用apt-get安装的软件

    使用apt-get --purge remove 包名 移除软件

    安装redis-server会安装两个包:redis-server 和 redis-tools,直接使用以上方式移除即可。

    2.编译安装

    在以下网址查找需要安装的版本地址

    http://download.redis.io/releases/

    下载并解压redis

    root@yatces-virtual-machine:/usr/local/soft# wget http://download.redis.io/releases/redis-3.2.6.tar.gz
    root@yatces-virtual-machine:/usr/local/soft# tar -zxvf redis-3.2.6.tar.gz

    进入redis目录编译、安装

    root@yatces-virtual-machine:/usr/local/soft/redis-3.2.6# make&& make install

    安装完后,在/usr/local/bin目录中会生成一个redis-server启动命令

    将 redis.conf 复制到 /etc/redis/ 目录下,顺便将redis.conf几个配置修改(便于远程客户端连接)

    bind 127.0.0.1 ==》 bind 0.0.0.0  
    protected-mode no
    daemonize yes

    启动redis

    root@yatces-virtual-machine:/usr/local/soft/redis-3.2.6# /usr/local/bin/redis-server /etc/redis/redis.conf

    客户端连接redis

    root@yatces-virtual-machine:/usr/local/soft/redis-3.2.6# /usr/local/bin/redis-cli 

    停止redis服务,在客户端使用 shutdown 命令,退出客户端使用 exit 命令

    127.0.0.1:6379> shutdown
    not connected> exit

    卸载redis

    只需把/usr/local/bin/目录下的redis删除即可

  • 相关阅读:
    c++11 standardized memory model 内存模型
    C++和C API调用
    c+11 std::condition_variable and mutex
    Linux thread process and kernel mode and user mode page table
    c++ Initialization
    c++11 perfect forwarding
    C++11 template parameter deduction
    Cache缓存设计
    c++11 enable_shared_from_this
    大数相乘
  • 原文地址:https://www.cnblogs.com/Yatces/p/11393683.html
Copyright © 2011-2022 走看看