Last active
June 4, 2018 18:35
-
-
Save nmilford/3c3e900c66b2788a8ff361e091e580a7 to your computer and use it in GitHub Desktop.
redis 5.0 deb with rebloom and redis graph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create build root | |
mkdir -p /tmp/build/etc/redis/ | |
mkdir -p /tmp/build/opt/redis/data/ | |
mkdir -p /tmp/build/opt/redis/modules/ | |
mkdir -p /tmp/build/etc/systemd/system/ | |
# Get Redis | |
wget https://github.com/antirez/redis/archive/5.0-rc1.tar.gz | |
tar zxvf 5.0-rc1.tar.gz | |
cd redis-5.0-rc1/ | |
# Override the version string. | |
sed -i 's|#define REDIS_VERSION.*|#define REDIS_VERSION "5.0-rc1"|g' src/version.h | |
# Buidl and install to the build root | |
make | |
make PREFIX=/tmp/build/opt/redis/ install | |
cp *.conf /tmp/build/etc/redis/ | |
# Set the data dior | |
sed -i 's|dir ./|dir /opt/redis/data/|g' /tmp/build/etc/redis/redis.conf | |
# Drop an init script | |
cat << EOF > /tmp/build/etc/systemd/system/redis.service | |
[Service] | |
Type=simple | |
User=redis | |
Group=root | |
ExecStart=/opt/redis/bin/redis-server /etc/redis/redis.conf | |
ExecReload=/bin/kill -USR2 $MAINPID | |
Restart=always | |
RestartSec=3 | |
WorkingDirectory=/opt/redis/data | |
LimitNOFILE=65536 | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
# Build rebloom module | |
mkdir -p /tmp/build/opt/redis/modules/ | |
wget https://github.com/RedisLabsModules/rebloom/archive/v1.1.0.zip | |
unzip v1.1.0.zip | |
cd rebloom-1.1.0/ | |
git clone https://github.com/RedisLabs/RedisModulesSDK | |
cd RedisModulesSDK/rmutil/ | |
make | |
cd ../.. | |
make | |
cp rebloom.so /tmp/build/opt/redis/modules/ | |
# Build the redis-graph module | |
cd .. | |
git clone https://github.com/swilly22/redis-graph | |
cd redis-graph/ | |
git clone https://github.com/RedisLabs/RedisModulesSDK | |
cd RedisModulesSDK/rmutil/ | |
make | |
cd ../.. | |
make | |
cp src/redisgraph.so /tmp/build/opt/redis/modules/ | |
# Add the modules to the config | |
sed -i 's|# loadmodule /path/to/my_module.so|loadmodule /opt/redis/modules/rebloom.so|g' /tmp/build/etc/redis/redis.conf | |
sed -i 's|# loadmodule /path/to/other_module.so|loadmodule /opt/redis/modules/redisgraph.so|g' /tmp/build/etc/redis/redis.conf | |
# Post-install script | |
echo 'test -d /opt/redis/data || mkdir /opt/redis/data | |
chown redis /opt/redis/data | |
for bin in redis-benchmark redis-cli; do | |
test -e /usr/bin/${bin} || ln -s /opt/redis/bin/${bin} /usr/bin/${bin} | |
done | |
systemctl daemon-reload | |
systemctl enable redis | |
systemctl start redis' > ./after-install | |
# Pre-install script | |
echo 'if ! $(getent passwd redis >/dev/null 2>&1); then | |
useradd -r redis; | |
fi' > ./before-install | |
# Pre-removeal script | |
echo 'systemctl stop redis' > ./before-remove | |
# Build the deb | |
sudo fpm \ | |
-s dir \ | |
-t deb \ | |
-n redis_full \ | |
-v 5.0-rc1 \ | |
-C /tmp/build \ | |
-m "PerformLine Engineering <[email protected]>" \ | |
--deb-user redis \ | |
--description "Persistent key-value database with network interface" \ | |
--before-remove ./before-remove \ | |
--before-install ./before-install \ | |
--after-install ./after-install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment