• [nosql之redis]yum安装redis


    1.首先对于这种nosql来说目前我用到的功能很少,所以感觉没有必要去优化他跟不需要去编译安装。今天来介绍下一个yum安装redis

    步骤1:安装扩展yum库

    [root@localhost ~]# yum install epel-release
    ##在查看下yum源中是否有redis
    [root@localhost ~]# yum search redis
    [root@localhost ~]# yum -y install redis
    ##ok安装完成!

    启动:

    ##CentOS7
    [root@localhost ~]# systemctl start redis.service
    ##CentOS7以下
    [root@localhost ~]# service redis start
    ##查看启动:
    [root@localhost ~]# ps -ef | grep redis
    redis     12683      1  0 23:19 ?        00:00:00 /usr/bin/redis-server 127.0.0.1:6379
    root      12696  12454  0 23:20 pts/2    00:00:00 grep --color=auto redis
    

    客户端连接:

    [root@localhost ~]# redis-cli 
    127.0.0.1:6379> 
    127.0.0.1:6379> keys *
    (empty list or set)
    127.0.0.1:6379> set a 1
    OK
    127.0.0.1:6379> get a
    "1"
    127.0.0.1:6379> keys *
    1) "a"
    127.0.0.1:6379> del a
    (integer) 1
    127.0.0.1:6379> keys *
    (empty list or set)

    开机自启动:两种方式

    方法1: 启动命令写入 /etc/rc.d/rc.local 文件里面

    [root@localhost ~]# echo 'systemctl start redis.service' >> /etc/rc.d/rc.local 
    [root@localhost ~]# cat /etc/rc.d/rc.local 
    #!/bin/bash
    # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
    #
    # It is highly advisable to create own systemd services or udev rules
    # to run scripts during boot instead of using this file.
    #
    # In contrast to previous versions due to parallel execution during boot
    # this script will NOT be run after all other services.
    #
    # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
    # that this script will be executed during boot.
    
    touch /var/lock/subsys/local
    memcached -u memcached -p 11211 -m 64 -c 512 &
    systemctl start redis.service

    方法2:加入系统服务 :我这里用yum安装本身就是加入了系统服务了只需要设置开机自启动就可以:

    [root@localhost ~]# systemctl enable redis.service
  • 相关阅读:
    delphi 实体类 JSON 数组 TJsonSerializer Deserialize
    IIS 禁止访问:在 Web 服务器上已拒绝目录列表
    ASP.NET 一般处理程序
    .net 架构
    delphi XE8 NetHTTPRequest NetHTTPClient
    ASP.NET web 应用程序项目
    HttpClient
    eclipse Android 开发基础 Activity 窗体 界面
    关闭 iTunes 自动同步
    could not be installed at this time
  • 原文地址:https://www.cnblogs.com/patf/p/5805054.html
Copyright © 2020-2023  润新知