Last active
June 20, 2020 22:51
-
-
Save DorkNstein/c20a414808eab772af93035649439860 to your computer and use it in GitHub Desktop.
Installing redis server in AWS servers for sockets io connections in nodejs
This file contains hidden or 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
https://redis.io/topics/quickstart | |
wget http://download.redis.io/redis-stable.tar.gz | |
tar xvzf redis-stable.tar.gz | |
cd redis-stable | |
make distclean | |
make # If this throws an error | |
# Do | |
cd deps | |
make hiredis lua jemalloc linenoise | |
cd .. | |
make | |
make test # If test fails with You need tcl 8.5 or newer in order to run the Redis test | |
sudo yum install -y tcl | |
make test | |
# Set Overcommit to TRUE | |
# Redis is going to complain unless you have some level of overcommit memory enabled. | |
# This is easy to do (again, you must be root or sudoer to do this). | |
# Add ‘vm.overcommit_memory = 1’ to /etc/sysctl.conf and then reboot, | |
# IF you can safely do so on your machine | |
# (best to check and make sure there are no live service interruptions or other personnel using the system). | |
vi /etc/sysctl.conf | |
## Add this to the end of the file: | |
# Required by Redis to enable overcommit setting: | |
vm.overcommit_memory = 1 | |
# OR RUN | |
sudo sysctl vm.overcommit_memory=1 | |
# To start redis server RUN | |
redis-server # If throws 'redis-server: command not found' Error | |
sudo cp src/redis-server /usr/local/bin/ | |
sudo cp src/redis-cli /usr/local/bin/ | |
# Run | |
redis-server | |
# Config changes required to start redis server in Proper mode | |
sudo mkdir /etc/redis | |
sudo mkdir /var/redis | |
sudo cp utils/redis_init_script /etc/init.d/redis_6379 | |
sudo vi /etc/init.d/redis_6379 # REDISPORT to 6379 | |
sudo cp redis.conf /etc/redis/6379.conf | |
sudo mkdir /var/redis/6379 | |
# Edit the configuration file, making sure to perform the following changes: | |
# Set daemonize to no (by default it is set to no). | |
# Set the pidfile to /var/run/redis_6379.pid (modify the port if needed). | |
# Change the port accordingly. In our example it is not needed as the default port is already 6379. | |
# Set your preferred loglevel. | |
# Set the logfile to /var/log/redis_6379.log | |
# Set the dir to /var/redis/6379 (very important step!) | |
sudo chkconfig redis_6379 defaults # Add the new Redis init script to all the default runlevels | |
sudo /etc/init.d/redis_6379 start # To start server | |
# TO daemonize redis server | |
sudo vi /etc/systemd/system/redis.service | |
# Add following lines to it | |
# Start of Copy | |
[Unit] | |
Description=Redis | |
After=syslog.target | |
[Service] | |
ExecStart=/usr/local/bin/redis-server /etc/redis/6379.conf | |
RestartSec=5s | |
Restart=on-success | |
[Install] | |
WantedBy=multi-user.target | |
# END of Copy | |
sudo systemctl enable /etc/systemd/system/redis.service | |
sudo systemctl start redis # To start service | |
sudo systemctl status redis # To check redis status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment