zoukankan      html  css  js  c++  java
  • centos8安装redis5.0x和redisearch

    2020年10月6日01:11:16

    github:https://github.com/RediSearch/RediSearch

    操作手册 https://oss.redislabs.com/redisearch/Quick_Start/

    安装redis

    wget http://download.redis.io/releases/redis-6.0.8.tar.gz
    解压文件
    make PREFIX=/usr/local/redis install
    注意这里需要gcc,注意自己yum一下

    注意一下redis版本和redisearch的版本对应,我但是我在官网没看到之间的关系说明,所以这里采用的是最新版本的redis和redisearch

    不然就会出现下面日志报错内容

    <search> Redis version found by RedisSearch : 5.0.3 - oss
    <search> Redis version is to old, please upgrade to redis 6.0.0 and above

    注意你的redis运行用户和编译的成so文件用户和用户组一致,不然会出现访问deny

    在redis目录建立log config data

    cp redis.conf /usr/local/redis/conf/

    vi redis.conf 


    #绑定访问的ip
    注释掉 bind 0.0.0.0

    #使以daemon方式运行
    daemonize yes

    #日志保存目录
    logfile "/usr/local/redis/log/redis.log"

    #数据保存目录
    dir /usr/local/redis/data

    vi /lib/systemd/system/redis.service

    [Unit]
    Description=Redis
    After=network.target
    
    [Service]
    Type=forking
    PIDFile=/var/run/redis_6379.pid
    ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/conf/redis.conf
    ExecReload=/bin/kill -s HUP $MAINPID
    ExecStop=/bin/kill -s QUIT $MAINPID
    PrivateTmp=true
    
    [Install]
    WantedBy=multi-user.target

    重新加载service文件
    systemctl daemon-reload

    systemctl start redis

    开机启动

    systemctl enable redis

    gitee镜像 https://gitee.com/mirrors/redisearch.git

    git clone --recursive https://gitee.com/mirrors/redisearch.git

    make setup

    这个操作挺慢的,耐心等待,注意这里我没有成功

    出现yum install -q -y git cmake wget lcov Error: Unable to find a match: lcov

    我就直接 make all就生产成功了

    从源代码构建和运行 
    首先,克隆git repo(确保不忽略该 --recursive 选项,以正确克隆子模块):

    git clone --recursive https://github.com/RediSearch/RediSearch.git
    接下来,安装依赖项并进行构建:

    sudo make setup
    make build
    最后,使用RediSearch运行Redis:

    make run

    注意官网是使用RediSearch运行Redis

    我这里建议是编译成RediSearch.so添加在redis.conf

    在redis.conf最后一行添加

    loadmodule /home/redisearch/build/redisearch.so

     测试:

    因为这里编译安装,没有全局redis-cli

    进入到/usr/local/redis/bin

    127.0.0.1:6379> FT.CREATE myIdx ON HASH PREFIX 1 doc: SCHEMA title TEXT WEIGHT 5.0 body TEXT url TEXT
    127.0.0.1:6379> hset doc:1 title "hello world" body "lorem ipsum" url "http://redis.io"
    127.0.0.1:6379> FT.SEARCH myIdx "hello world" LIMIT 0 10 1) (integer) 1 2) "doc:1" 3) 1) "title"  2) "hello world"  3) "body"  4) "lorem ipsum"  5) "url"  6) "http://redis.io"

  • 相关阅读:
    三道趣味题目
    iOS开发中使用静态库 .a 文件
    java Graphics2D 画图
    堆和栈的区别
    iOS开发中KVC、KVO简介
    GPUImage的简单使用
    OC中 self.view.frame.size.height = 100; 不能通过编译的原因
    Xcode7 低版本iOS系统上下有黑边的问题
    c语言数组赋值
    ELF interpreter /libexec/ld-elf32.so.1 not found
  • 原文地址:https://www.cnblogs.com/zx-admin/p/13772193.html
Copyright © 2011-2022 走看看