Skip to content

Instantly share code, notes, and snippets.

@lmj0011
Last active November 4, 2024 10:18
Show Gist options
  • Save lmj0011/820eea392f6f43c755fadc2ba56b69e9 to your computer and use it in GitHub Desktop.
Save lmj0011/820eea392f6f43c755fadc2ba56b69e9 to your computer and use it in GitHub Desktop.
Building and Loading the ReJSON v1 Module on Linux Ubuntu 16.04 for Redis

make sure you have at least redis v4.0+

redis-server --version

redis-cli --version

install the build-essential package

apt-get install build-essential


git clone https://github.com/RedisJSON/RedisJSON.git

git checkout v1.0.3

cd rejson/

make

cd src/

mkdir /etc/redis/modules/

mv rejson.so /etc/redis/modules/

add this line to /etc/redis/redis.conf

loadmodule /etc/redis/modules/rejson.so

restart redis server

service redis-server restart

--

ref: https://oss.redislabs.com/rejson/#linux-ubuntu-1604

@CaypoH
Copy link

CaypoH commented Mar 15, 2019

For CentOS:

UPDATING AND INSTALLING PACKAGES

yum update -y
yum install epel-release yum-utils -y
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
yum-config-manager --enable remi
yum install redis git -y

SETTING VARIABLES

REJSON_MODULES=$(rpm -ql redis | grep modules)  # default: /usr/lib64/redis/modules
REDIS_CONF=$(rpm -ql redis | grep "redis.conf$")  # default: /etc/redis.conf
HOST_IP=$(ip addr show eth0 | grep -Po "inet \K[\d.]+")

INSTALLING REJSON MODULE

cd /usr/src
git clone https://github.com/RedisLabsModules/rejson.git
cd rejson/
make
cp src/rejson.so ${REJSON_MODULES}
chown redis:redis ${REJSON_MODULES}/rejson.so
chmod 750 ${REJSON_MODULES}/rejson.so

CHANGING CONFIGURATION AND STARTING REDIS

sed -i "/MODULES/a loadmodule ${REJSON_MODULES}/rejson.so" ${REDIS_CONF}
sed -i "s/bind 127.0.0.1/bind ${HOST_IP}/g" ${REDIS_CONF}  # remove this line if you dont want redis server to be accessible from outside
systemctl start redis
systemctl enable redis

@p3t3r67x0
Copy link

Thank you so much for posting it here on Gist!

@GuyG-Saha
Copy link

Hi,

I ran into a severe problem today while trying to load this module.
After adding the line loadmodule /etc/redis/modules/rejson.so to redis.conf file (below other lines that started with loadmodule) and restarting the redis-server I found out that almost all my data got deleted. It was saved before and somehow only 3 keys were loaded this time.

I'm using Ubuntu 18.04 WSL (in Windows 10 PowerShell).

Can you please check whether it's a bug or tell if I did anything wrong?

@ghothan
Copy link

ghothan commented Apr 28, 2020

I keep getting this error when I run make

ubuntu@ip-10-53-10-226:~/rejson$ make
make -C ./src all
make[1]: Entering directory '/home/ubuntu/rejson/src'
make[1]: *** No rule to make target 'all'. Stop.
make[1]: Leaving directory '/home/ubuntu/rejson/src'
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 2

Is there something wrong with my make command

@Curlyhub
Copy link

Thanks for posting it, you save my day!!!, literally!!!

@praveenmak
Copy link

Thanks a ton! the Centos gist helped me a great deal.

@codewithkushagra
Copy link

--- stderr
thread 'main' panicked at 'Unable to find libclang: "couldn't find any valid shared libraries matching: ['libclang.so', 'libclang-.so', 'libclang.so.', 'libclang-.so.'], set the LIBCLANG_PATH environment variable to a path where one of these files can be found (invalid: [])"', /home/kushagra/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.59.2/src/lib.rs:2144:31
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
make: *** [Makefile:166: build] Error 10

I am getting this, when I enter the make command??

@lmj0011
Copy link
Author

lmj0011 commented Jan 22, 2022

@codewithkushagra

Trying doing git checkout v1.0.3, and then running the make command again. (updated the instructions)

This gist hasn't been tested for RedisJSON v2+

@binkabir
Copy link

this works for me.
##install redisJson on 20.04

git clone https://github.com/RedisJSON/RedisJSON.git
cd RedisJSON
cargo build --release
cd target/release/
mkdir /etc/redis/modules/
mv librejson.so /etc/redis/modules/

add this line to /etc/redis/redis.conf

loadmodule /etc/redis/modules/librejson.so
service redis-server restart

@rkrishd
Copy link

rkrishd commented May 25, 2022

sudo yum --enablerepo=remi install redis
yum install clang clang-devel -y
yum install centos-release-scl -y
yum install devtoolset-7-gcc* -y
yum install devtoolset-7-make -y
scl enable devtoolset-7 bash
yum install llvm-toolset-7 -y
scl enable llvm-toolset-7 bash
curl https://sh.rustup.rs -sSf | sh
REJSON_MODULES=$(rpm -ql redis | grep modules) # default: /usr/lib64/redis/modules
REDIS_CONF=$(rpm -ql redis | grep "redis.conf$") # default: /etc/redis.conf
HOST_IP=$(ip addr show eth0 | grep -Po "inet \K[\d.]+")
cd /usr/src
git clone https://github.com/RedisLabsModules/rejson.git
cd rejson/
make
cp ./bin/linux-x64-release/rejson.so ${REJSON_MODULES}
chown redis:redis ${REJSON_MODULES}/rejson.so
chmod 750 ${REJSON_MODULES}/rejson.so
sed -i "/MODULES/a loadmodule ${REJSON_MODULES}/rejson.so" ${REDIS_CONF}
systemctl start redis
systemctl enable redis

@csharpnewbie3
Copy link

While checking out I am not able to use the latest RedisJson version. Will the steps change in that case? Can someone help? I am using 16.04 Ubuntu. When checking out the version mentioned its working fine but not in case of latest version.

@tausifcreates
Copy link

Hello people, who are having problems. Download the latest release tarball from here:
wget https://github.com/RedisJSON/RedisJSON/archive/refs/tags/v2.0.9.tar.gz

Then run cargo build --release from the root path.

@sasthrajyothi
Copy link

this works for me. ##install redisJson on 20.04

git clone https://github.com/RedisJSON/RedisJSON.git
cd RedisJSON
cargo build --release
cd target/release/
mkdir /etc/redis/modules/
mv librejson.so /etc/redis/modules/

add this line to /etc/redis/redis.conf

loadmodule /etc/redis/modules/librejson.so
service redis-server restart

@sasthrajyothi
Copy link

can you please tell me how to know the path to load the the module

@tausifcreates
Copy link

can you please tell me how to know the path to load the the module

You can find librejson.so in release folder under build

@britisharmy
Copy link

@akshaysaini11
Copy link

please provide same as redis search install in Linux/Ubuntu
kindly provide commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment