Last active
January 23, 2024 13:29
-
-
Save srimaln91/bea81d8c5ba36a64b0cd1b3b5324f687 to your computer and use it in GitHub Desktop.
Install RocksDB on Ubuntu 20.04 (Focal Fossa)
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
#!/bin/bash | |
ROCKSDB_VERSION=5.11.3 | |
#Run as a root user | |
if [ "$EUID" -ne 0 ] | |
then echo "Please run as root (with sudo command)" | |
exit | |
fi | |
if ! command -v wget &> /dev/null | |
then | |
echo "wget command could not be found. installing..." | |
apt install -y wget | |
fi | |
if ! command -v make &> /dev/null | |
then | |
echo "make command could not be found. installing..." | |
apt install -y cmake | |
fi | |
if ! command -v g++ &> /dev/null | |
then | |
echo "g++ command could not be found. installing..." | |
apt install -y g++ | |
fi | |
echo "installing required dependancies..." | |
sudo apt install -y libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev | |
echo "downloading rocksdb..." | |
pushd /tmp || return | |
wget https://github.com/facebook/rocksdb/archive/refs/tags/v${ROCKSDB_VERSION}.tar.gz | |
tar -xvf v${ROCKSDB_VERSION}.tar.gz && cd rocksdb-${ROCKSDB_VERSION} || return | |
# Ignore GCC warnings | |
export CXXFLAGS='-Wno-error=deprecated-copy -Wno-error=pessimizing-move -Wno-error=class-memaccess' | |
# Build as a shared library | |
make shared_lib | |
# The following command installs the shared library in /usr/lib/ and the header files in /usr/include/rocksdb/: | |
make install-shared INSTALL_PATH=/usr | |
popd || return | |
# cleanup | |
rm -rf /tmp/rocksdb-${ROCKSDB_VERSION} /tmp/v${ROCKSDB_VERSION}.tar.gz | |
echo "installation successful" | |
# To uninstall | |
#make uninstall INSTALL_PATH=/usr |
Thanks for pointing that out. Let me update the script. 👍
Might need sudo
to play with /usr/lib
and /usr/include
folders. So,
sudo make install-shared INSTALL_PATH=/usr
@roshsoftco Thanks for the feedback. I think it's not a good practice to use sudo
in scripts. We can run the script with root privileges when we execute it.
sudo ./install.sh
I have updated the script. This can be executed as a script now.
Alternatively we can execute this in the following way
curl -s https://gist.githubusercontent.com/srimaln91/bea81d8c5ba36a64b0cd1b3b5324f687/raw/ba679250ebf3917203d61c60f01da5c01f441874/rocksdb-install.sh | sudo bash
Alternatively we can execute this in the following way
curl -s https://gist.githubusercontent.com/srimaln91/bea81d8c5ba36a64b0cd1b3b5324f687/raw/ba679250ebf3917203d61c60f01da5c01f441874/rocksdb-install.sh | sudo bash
very good
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Before checking out need to cd to the rocksdb folder.
+cd rocksdb