zoukankan      html  css  js  c++  java
  • mac 安装 redis


    相当于 Ubuntu/Linux 的 apt-get,用来安装一些零零碎碎的东西很方便,而且更新很快,安装的软件也都是最新版本。

    1. 安装

    Homebrew 是使用 ruby 写的,采用 github 来存放信息库,很方便吧。

    Ruby 已经内置,最好装上 Xcode,因为可能需要一些编译包。然后在终端执行以下命令。
    $ ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"
    brew 安装的软件存放在 /usr/local/Cellar 中,同时会在 /usr/local/bin, /usr/local/sbin, /usr/local/lib 中创建链接。你可能需要将 /usr/local/sbin 添加到搜索路径中。
    $ vim ~/.profile

    PATH="$PATH:/usr/local/sbin"
    export PATH
    2. 使用

    (1) 更新库信息
    $ brew update

    remote: Counting objects: 116, done.
    remote: Compressing objects: 100% (95/95), done.
    remote: Total 95 (delta 73), reused 0 (delta 0)
    Unpacking objects: 100% (95/95), done.
    From http://github.com/mxcl/homebrew
    * branch master -> FETCH_HEAD
    Updated Homebrew from 780c85bd to d7ff3a29.
    ==> The following formulae are new:
    dfu-programmer grass
    ==> The following formulae were updated:
    bash-completion fiwalk git-flow hub mkclean xapian
    cherokee flac groovy id3lib mkvalidator
    ctags git guile kyoto-cabinet poco
    No external commands were updated.
    (2) 搜索软件
    $ brew search redis

    redis redis-tools

    $ brew search jpg # 局部搜索

    libjpg

    $ brew search /^libjp[e]?g/ # 正则表达式搜索

    libjpeg libjpg
    (3) 查看软件信息
    $ brew info redis

    redis 2.0.4
    http://redis.io/
    /usr/local/Cellar/redis/2.0.4 (147 files, 1.2M)

    If this is your first install, automatically load on login with:
    cp /usr/local/Cellar/redis/2.0.4/io.redis.redis-server.plist ~/Library/LaunchAgents
    launchctl load -w ~/Library/LaunchAgents/io.redis.redis-server.plist

    If this is an upgrade and you already have the io.redis.redis-server.plist loaded:
    launchctl unload -w ~/Library/LaunchAgents/io.redis.redis-server.plist
    cp /usr/local/Cellar/redis/2.0.4/io.redis.redis-server.plist ~/Library/LaunchAgents
    launchctl load -w ~/Library/LaunchAgents/io.redis.redis-server.plist

    To start redis manually:
    redis-server /usr/local/etc/redis.conf

    To access the server:
    redis-cli

    http://github.com/mxcl/homebrew/commits/master/Library/Formula/redis.rb
    (4) 浏览软件主页
    $ brew home redis
    (5) 安装软件
    $ brew install redis

    ==> Downloading https://github.com/antirez/redis/tarball/v2.0.4-stable
    ######################################################################## 100.0%
    ==> make -C .
    ==> Caveats
    If this is your first install, automatically load on login with:
    cp /usr/local/Cellar/redis/2.0.4/io.redis.redis-server.plist ~/Library/LaunchAgents
    launchctl load -w ~/Library/LaunchAgents/io.redis.redis-server.plist

    If this is an upgrade and you already have the io.redis.redis-server.plist loaded:
    launchctl unload -w ~/Library/LaunchAgents/io.redis.redis-server.plist
    cp /usr/local/Cellar/redis/2.0.4/io.redis.redis-server.plist ~/Library/LaunchAgents
    launchctl load -w ~/Library/LaunchAgents/io.redis.redis-server.plist

    To start redis manually:
    redis-server /usr/local/etc/redis.conf

    To access the server:
    redis-cli
    ==> Summary
    /usr/local/Cellar/redis/2.0.4: 147 files, 1.2M, built in 6 seconds
    (6) 删除软件
    $ brew uninstall redis

    Uninstalling /usr/local/Cellar/redis/2.0.4...
    (7) 查看已经安装的软件
    $ brew list

    binutils gettext libevent nginx pstree readline valgrind
    erlang glib libiconv pcre python3 redis wget
    gdbm libev mongodb pkg-config rabbitmq sqlite
    (8) 查看某软件的安装文件
    $ brew list redis

    /usr/local/Cellar/redis/2.0.4/bin/redis-server
    /usr/local/Cellar/redis/2.0.4/bin/redis-cli
    /usr/local/Cellar/redis/2.0.4/bin/redis-check-dump
    /usr/local/Cellar/redis/2.0.4/bin/redis-check-aof
    /usr/local/Cellar/redis/2.0.4/bin/redis-benchmark
    /usr/local/Cellar/redis/2.0.4/io.redis.redis-server.plist
    /usr/local/Cellar/redis/2.0.4/share/doc/ (138 files)
    (9) 查看某软件的 brew 安装脚本
    $ brew cat redis

    require 'formula'

    class Redis <Formula
    url '
    head 'git://github.com/antirez/redis.git'
    homepage '
    sha1 '48300996d3d34cccf076330859f37248fa5f6c1b'
    version '2.0.4'

    def install
    fails_with_llvm "Breaks with LLVM"

    # Head and stable have different code layouts
    src = File.exists?('src/Makefile') ? 'src' : '.'
    system "make -C #{src}"

    %w( redis-benchmark redis-cli redis-server redis-check-dump redis-check-aof ).each { |p|
    bin.install "#{src}/#{p}" rescue nil
    }

    %w( run db/redis log ).each { |p| (var+p).mkpath }

    # Fix up default conf file to match our paths
    inreplace "redis.conf" do |s|
    s.gsub! "/var/run/redis.pid", "#{var}/run/redis.pid"
    s.gsub! "dir ./", "dir #{var}/db/redis/"
    end

    doc.install Dir["doc/*"]
    etc.install "redis.conf"
    (prefix+'io.redis.redis-server.plist').write startup_plist
    end

    def caveats
    <<-EOS.undent
    If this is your first install, automatically load on login with:
    cp #{prefix}/io.redis.redis-server.plist ~/Library/LaunchAgents
    launchctl load -w ~/Library/LaunchAgents/io.redis.redis-server.plist

    If this is an upgrade and you already have the io.redis.redis-server.plist loaded:
    launchctl unload -w ~/Library/LaunchAgents/io.redis.redis-server.plist
    cp #{prefix}/io.redis.redis-server.plist ~/Library/LaunchAgents
    launchctl load -w ~/Library/LaunchAgents/io.redis.redis-server.plist

    To start redis manually:
    redis-server #{etc}/redis.conf

    To access the server:
    redis-cli
    EOS
    end

    def startup_plist
    return <<-EOPLIST
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>io.redis.redis-server</string>
    <key>ProgramArguments</key>
    <array>
    <string>#{bin}/redis-server</string>
    <string>#{etc}/redis.conf</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>UserName</key>
    <string>#{`whoami`.chomp}</string>
    <key>WorkingDirectory</key>
    <string>#{var}</string>
    <key>StandardErrorPath</key>
    <string>#{var}/log/redis.log</string>
    <key>StandardOutPath</key>
    <string>#{var}/log/redis.log</string>
    </dict>
    </plist>
    EOPLIST
    end
    end
    (10) 删除所有软件升级后的遗留旧版本
    $ brew cleanup

  • 相关阅读:
    Oracle学习(四)--sql及sql分类讲解
    Oracle学习(三)--数据类型及常用sql语句
    Oracle学习(二)--启动与关闭
    Tomcat学习笔记--启动成功访问报404错误
    有关Transaction not successfully started问题解决办法
    百度富文本编辑器UEditor1.3上传图片附件等
    hibernate+junit测试实体类生成数据库表
    js登录与注册验证
    SVN安装配置与使用
    [LeetCode] #38 Combination Sum
  • 原文地址:https://www.cnblogs.com/qinyan20/p/3643272.html
Copyright © 2011-2022 走看看