centos7 redis 使用,查看Redis工具(安装、添加权限验证、添加开机自启)

  • 安装
$ wget http://download.redis.io/releases/redis-4.0.7.tar.gz
$ tar xzf redis-4.0.7.tar.gz
$ cd redis-4.0.7
$ make

注意:如果make时报错,gcc:未找到命令错误,
# [Linux安装redis时报gcc:未找到命令错误](http://blog.csdn.net/wenwen360360/article/details/70162169)



mv  redis-4.0.7/ /usr/local/redis                         # 将解压包拷贝到指定目录

  • redis查看工具:
- mac安装Redis可视化工具-Redis Desktop Manager

- ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null ; brew install caskroom/cask/brew-cask 2> /dev/null

- brew cask install rdm

re.: https://www.jianshu.com/p/214baa511f2e

  • redis 允许远程访问
    配置redis

    redis的配置文件是redis.conf

vim redis.conf
  • 配置说明:

    • 键空间通知功能: notify-keyspace-events Ex
    • 后台启动: daemonize yes
    • 使用密码: requirepass redispwd
    • 允许远程连接: bind 0.0.0.0
  • 命令行中运行 redis 服务
./redis-server /path/to/redis.conf
  • Redis 开机自启 和 后台启动
vim /lib/systemd/system/Redis.service

[Unit]
Description=Redis
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/redis/src/redis-server /usr/local/redis/redis.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target

 说明:
    1. Description:描述服务
    2. After:描述服务类别
    3. [Service] :服务运行参数的设置
    4. Type=forking:是后台运行的形式
    5. ExecStart为:服务的具体运行命令
    6. ExecReload:重启命令
    7. ExecStop:停止命令
    8. PrivateTmp=True:给服务分配独立的临时空间
    9. 注意: [Service]的启动、重启、停止命令全部要求使用绝对路径
    [Install]运行级别下服务安装的相关设置,可设置为多用户,即系统运行级别为3,重启和停止命令也可以不设置 
                               
#开启MongoDB服务:
systemctl start Redis.service
#停止MongoDB服务:
systemctl stop Redis.service

#加入开机自启:
systemctl enable Redis.service


猜你喜欢

转载自blog.csdn.net/weixin_34377065/article/details/87636017
今日推荐