-
-
Save tors/925665 to your computer and use it in GitHub Desktop.
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
| # http://antonio.ognio.com/2010/07/28/installing-redis-on-linux-and-mac-os-x/ | |
| wget http://redis.googlecode.com/files/redis-2.2.2.tar.gz | |
| tar -xzvf redis-2.2.2.tar.gz | |
| cd redis-2.2.2 && sudo make && sudo make install | |
| Five binaries will be installed to /usr/local/bin, redis-server, redis-benchmark, redis-cli, redis-check-dump and redis-check-aof. You’ll have to manually copy the Redis configuration file to /etc like this: | |
| sudo mkdir /etc/redis | |
| sudo cp redis.conf /etc/redis/redis.conf | |
| sudo nano /etc/redis/redis.conf | |
| daemonize yes | |
| pidfile /var/run/redis.pid | |
| port 6379 | |
| bind <privateip> | |
| timeout 300 | |
| logfile /var/log/redis/redis-server.log | |
| databases 16 | |
| dbfilename dump.rdb | |
| dir /var/lib/redis | |
| Startup redis: | |
| sudo redis-server /etc/redis/redis.conf | |
| Kill redis: | |
| sudo killall redis-server |
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
| Mac: | |
| brew install redis | |
| Automatically load on login with: | |
| launchctl load -w /usr/local/Cellar/redis/2.2.2/io.redis.redis-server.plist | |
| To start redis manually: | |
| redis-server /usr/local/etc/redis.conf | |
| To access the server: | |
| redis-cli |
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
| wget http://ftp.de.debian.org/debian/pool/main/r/redis/redis-server_2.0.0~rc4-1_i386.deb | |
| # or http://ftp.de.debian.org/debian/pool/main/r/redis/redis-server_1.2.6-1_i386.deb | |
| sudo dpkg -i redis-server_2.0.0~rc4-1_i386.deb | |
| # or redis-server_1.2.6-1_i386.deb | |
| sudo service redis-server start | |
| # ... redis should listen on <privateip>:6379. | |
| # /proc/sys/vm/overcommit_memory | |
| 1 | |
| # Settings in | |
| /etc/redis/redis.conf |
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
| # /etc/redis/redis.conf | |
| # By default Redis does not run as a daemon. Use 'yes' if you need it. | |
| # Note that Redis will write a pid file in /var/run/redis.pid when daemonized. | |
| daemonize yes | |
| # When running daemonized, Redis writes a pid file in /var/run/redis.pid by | |
| # default. You can specify a custom pid file location here. | |
| pidfile /var/run/redis.pid | |
| # Accept connections on the specified port, default is 6379. | |
| # If port 0 is specified Redis will not listen on a TCP socket. | |
| port 6379 | |
| # If you want you can bind a single interface, if the bind option is not | |
| # specified all the interfaces will listen for incoming connections. | |
| # | |
| bind 192.168.167.60 | |
| # Close the connection after a client is idle for N seconds (0 to disable) | |
| timeout 300 | |
| # Specify the log file name. Also 'stdout' can be used to force | |
| # Redis to log on the standard output. Note that if you use standard | |
| # output for logging but daemonize, logs will be sent to /dev/null | |
| logfile /var/log/redis/redis-server.log | |
| # Set the number of databases. The default database is DB 0, you can select | |
| # a different one on a per-connection basis using SELECT <dbid> where | |
| # dbid is a number between 0 and 'databases'-1 | |
| databases 16 | |
| ################################ SNAPSHOTTING ################################# | |
| save 900 1 | |
| save 300 10 | |
| save 60 10000 | |
| rdbcompression yes | |
| # The filename where to dump the DB | |
| dbfilename dump.rdb | |
| dir /var/lib/redis |
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
| #!/bin/sh | |
| # /etc/init.d/redis-server | |
| REDISPORT=6379 | |
| EXEC=/usr/local/bin/redis-server | |
| PIDFILE=/var/run/redis.pid | |
| CONF="/etc/redis/redis.conf" | |
| case "$1" in | |
| start) | |
| if [ -f $PIDFILE ] | |
| then | |
| echo -n "$PIDFILE exists, process is already running or crashed\n" | |
| else | |
| echo -n "Starting Redis server...\n" | |
| $EXEC $CONF | |
| fi | |
| ;; | |
| stop) | |
| if [ ! -f $PIDFILE ] | |
| then | |
| echo -n "$PIDFILE does not exist, process is not running\n" | |
| else | |
| PID=$(cat $PIDFILE) | |
| echo -n "Stopping ...\n" | |
| echo -n "SHUTDOWN\r\n" | nc localhost $REDISPORT & | |
| while [ -x /proc/${PIDFILE} ] | |
| do | |
| echo "Waiting for Redis to shutdown ..." | |
| sleep 1 | |
| done | |
| echo "Redis stopped" | |
| fi | |
| ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment