1. Redis¸¦ ÄÄÆÄÀÏ ÇÏ°í Å×½ºÆ® ÇÒ ¼ö Àִ ȯ°æ±¸¼º
aptgetÀ» ÀÌ¿ëÇÏ¿© ¸ÞŸÆäÅ°Áö build-essential ¹× Å×½ºÆ®¸¦ À§ÇÑ tcl À» ¼³Ä¡
$sudo apt-get update $sudo apt-get install build-essential tcl
2. ÃֽŠ¾ÈÁ¤µÈ ¹öÀüÀÇ ¼Ò½ºÄڵ带 ´Ù¿î
Àӽà tempµð·ºÅ丮¿¡ ÃֽŠredis ¼Ò½ºÄڵ带 ¹Þ¾Æ¼ ¾ÐÃàÀ» ÇØÁ¦
$mkdir temp $cd /temp $curl -O http://download.redis.io/redis-stable.tar.gz $tar xzvf redis-stable.tar.gz
3. ÄÄÆÄÀÏ ¹× ¼³Ä¡
¾ÐÃàÀ» Ǭ redisµð·ºÅ丮·Î À̵¿ÇÏ¿© make¸¦ ÀÌ¿ëÇÑ ÄÄÆÄÀϹ×
make test¸¦ ÀÌ¿ëÇÏ¿© ±â´É»ó ÀÌ»óÀÌ ¾ø´ÂÁö Å×½ºÆ® ÈÄ,
ÃÖÁ¾ install¸¦ ÀÌ¿ëÇÏ¿© ½Ã½ºÅÛ¿¡ ¼³Ä¡
$cd redis-stable $make $make test $sudo make install
4. redis½ÇÇàÀ» À§ÇÑ ±¸¼ºÆÄÀÏ ÆíÁý
¾ÐÃàÇØÁ¦½Ã »ý¼ºµÈ redis.conf ¸¦ /etc/redis ¿¡ ¿Å±ä ÈÄ, ȯ°æÀ» ±¸¼º
ȯ°æ ±¸¼º½Ã supervised ¸¦ no¿¡¼ systemdÀ¸·Î À¸·Î º¯°æÇÏ¿© ¼ºñ½ºÈ¯°æÀ¸·Î ±¸µ¿µÉ ¼ö ÀÖµµ·Ï º¯°æ
ȯ°æ ±¸¼º½Ã dir À» /var/lib/redis ¼³Á¤ÇÏ¿© ´ýÇÁÆÄÀÏ¹× ÀúÀå°ø°£ À§Ä¡¼³Á¤
$sudo mkdir /etc/redis $sudo cp /tmp/redis-stable/redis.conf /etc/redis $sudo nano /etc/redis/redis.conf
ȯ°æ¼³Á¤ supervised /etc/redis/redis.conf
# If you run Redis from upstart or systemd, Redis can interact with your # supervision tree. Options: # supervised no - no supervision interaction # supervised upstart - signal upstart by putting Redis into SIGSTOP mode # supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET # supervised auto - detect upstart or systemd method based on # UPSTART_JOB or NOTIFY_SOCKET environment variables # Note: these supervision methods only signal "process is ready." # They do not enable continuous liveness pings back to your supervisor. supervised systemd
ȯ°æ¼³Á¤ dir /etc/redis/redis.conf
# The working directory. # # The DB will be written inside this directory, with the filename specified # above using the 'dbfilename' configuration directive. # # The Append Only File will also be created inside this directory. # # Note that you must specify a directory here, not a file name. dir /var/lib/redis
5. ¼ºñ½º µî·ÏÀ» À§ÇÑ systemd unit ÆÄÀÏ »ý¼º
¼ºñ½º ¸í·ÂÀ» ÀÌ¿ëÇÏ¿© ½ÃÀÛ ¹× Á¾·á 󸮸¦ À§ÇÏ¿© systemd unit ÆÄÀÏÀ» »ý¼º ÇÑ´Ù.
¼ºñ½º¸¦ À§ÇÑ redis¼³¸í¹× ¼ºñ½º°¡ ½ÇÇàµÇ±âÀü¿¡ ³×Æ®¿öÅ©°¡ µÇ¾î¾ß µÈ´Ù´Â ¼³Á¤À»ÇÑ´Ù.
½ÃÀÛÀº redis-server¸í·ÉÀ» ÀÌ¿ë redis.conf¸¦ ȯ°æ¼³Á¤À» ÀÌ¿ëÇϵµ·Ï /usr/local/bin/redis-server /etc/redis/redis.conf ·Î Á¤¸®ÇÏ°í
Á¾·á´Â redis-cli¸¦ ÀÌ¿ëÇÏ¿© Á¾·áÇϵµ·Ï /usr/local/bin/redis-cli shutdown ·Î Á¤ÀÇÇÑ´Ù.
½Ã½ºÅÛ ºÎÆýà ÀÚµ¿±¸µ¿¿¡ µî·Ï ÇÒ¼ö ÀÖµµ·Ï Installg Ç׸ñÀ» ¼³Á¤ÇÑ´Ù.
$sudo nano /etc/systemd/system/redis.service
ȯ°æ¼³Á¤ /etc/systemd/system/redis.service
[Unit] Description=Redis In-Memory Data Store After=network.target [Service] User=redisuser Group=redisuser ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf ExecStop=/usr/local/bin/redis-cli shutdown Restart=always [Install] WantedBy=multi-user.target
6. redis¸¦ ±¸µ¿ÇÒ »ç¿ëÀÚ »ý¼º
redis¸¦ ±¸µ¿ÇÒ »ç¿ëÀÚ¸¦ »ý¼ºÇÑ´Ù. »ç¿ëÀÚ »ý¼º½Ã »ç¿ëÀÚ µð·ºÅ丮´Â Á¦¿Ü½ÃÅ°°í
redis ȯ°æ¼³Á¤¿¡¼ ÀúÀå°ø°£À» ÀÌ¿ëÇÒ /var/lib/redis µð·ºÅ丮 »ý¼º¹× redis»ç¿ëÀÚ
Á¢±Ù±ÇÇÑÀ» ÁØ´Ù.
$sudo adduser --system --group --no-create-home redisuser $sudo mkdir /var/lib/redis $sudo chown redisuser:redisuser /var/lib/redis $sudo chmod 770 /var/lib/redis
7. ½Ã½ºÅÛ ºÎÆýà ½ÇÇàµÇµµ·Ï ±¸¼º
½Ã½ºÅÛ ºÎÆýà redis°¡ ÀÚµ¿½ÇÇà µÇµµ·Ï ¼ºñ½º¿¡ µî·Ï ÇÑ´Ù.
$sudo systemctl enable redis
½ÇÇà°á°ú
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /etc/systemd/system/redis.service.
8. redis±¸µ¿ ¹× »óÅÂÈ®ÀÎ
redis¸¦ ¼ºñ½º¸í·ÉÀ¸·Î ±¸µ¿¹× »óŸ¦ È®ÀÎÇÑ´Ù.
¼ºñ½º ½ÃÀÛ¹× »óÅÂÈ®ÀÎ
$sudo systemctl start redis $sudo systemctl status redis
°á°ú´Â ´ÙÀ½°ú °°ÀÌ ³ª¿Â´Ù.
¡Ü redis.service - Redis In-Memory Data Store Loaded: loaded (/etc/systemd/system/redis.service; enabled; vendor preset: enabled) Active: active (running) since ¸ñ 2017-09-28 10:27:20 KST; 51min ago Main PID: 5050 (redis-server) Tasks: 4 Memory: 6.3M CPU: 1.576s CGroup: /system.slice/redis.service ¦¦¦¡5050 /usr/local/bin/redis-server 127.0.0.1:6379
¼ºñ½º Àç½ÃÀÛ
$sudo systemctl restart redis
9. redis ½ÇÇà Å×½ºÆ®
redis ¸í·ÉÀ» ó¸®ÇÒ ¼ö ÀÖ´Â redis-cli¸¦ ÀÌ¿ëÇÏ¿© Å×½ºÆ® Çغ»´Ù.
$redis-cli 127.0.0.1:6379>ping
°á°ú´Â ´ÙÀ½°ú °°ÀÌ ³ª¿Â´Ù.
Output PONG
10. ¿ø°Ý¿¡¼ Á¢¼ÓÇÒ ¼ö ÀÖµµ·Ï ¼³Á¤
±âº»ÀûÀ¸·Î ¼ºñ½º´Â ·ÎÄÿ¡¼¸¸ Á¢¼ÓÇÒ ¼ö°¡ ÀÖ´Ù À̸¦ ¿ø°ÝÀ¸·Î Á¢¼ÓÇÒ ¼ö ÀÖµµ·Ï º¯°æÇÑ´Ù.
/etc/redis·Î À̵¿ÈÄ redis.conf ¸¦ º¯°æÇÑ´Ù.
ȯ°æ ±¸¼º½Ã bind Ç׸ñÀ» ±âÁ¸ 127.0.0.1 À» 0.0.0.0 À¸·Î º¯°æÈÄ
¼ºñ½º¸¦ Àç½ÃÀÛÇÑ´Ù.
ȯ°æ¼³Á¤ bind /etc/redis/redis.conf
################################## NETWORK ##################################### # By default, if no "bind" configuration directive is specified, Redis listens # for connections from all the network interfaces available on the server. # It is possible to listen to just one or multiple selected interfaces using # the "bind" configuration directive, followed by one or more IP addresses. # # Examples: # # bind 192.168.1.100 10.0.0.1 # bind 127.0.0.1 ::1 # # ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the # internet, binding to all the interfaces is dangerous and will expose the # instance to everybody on the internet. So by default we uncomment the # following bind directive, that will force Redis to listen only into # the IPv4 lookback interface address (this means Redis will be able to # accept connections only from clients running into the same computer it # is running). # # IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES # JUST COMMENT THE FOLLOWING LINE. # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bind 0.0.0.0
11. redis UtileÀ»ÀÌ¿ëÇÑ È¯°æ¼³Ä¡
redis¸¦ ¼³Á¤À» ÇѲ¨¹ø¿¡ ½ºÅ©¸³Æ®¸¦ ÀÌ¿ëÇÏ¿© ÀÚµ¿À¸·Î ¼³Ä¡ÇÏ´Â ¹æ¹ýÀÌ ÀÖ´Ù
redis¿¡¼ ³»·Á¹Þ°í make¸¦ ½ÇÇàÇÏ¿© ÄÄÆÄÀÏ ÇÑ »óÅ¿¡¼
utileÀ» ÀÌ¿ëÇÏ¿© ¼³Ä¡ºÎÅÍ portº°·Î ȯ°æÀ» ¼³Ä¡ÇÏ¸é µÈ´Ù.
´ÙÀ½°ú??ÀÌ ½ÇÇàÇÑ´Ù.
$cd redis-stable $cd utils sudo ./install_server.sh
°¢°¢ ½ºÅ©¸³Æ®¿¡¼ ¹°¾îº¼¶§ Æ÷Æ®¸¸ ¹Ù²Ù¾î¼ default·Î ¼±ÅÃÇÏ¸é µÈ´Ù.
ex) 7001Æ÷Æ®
Welcome to the redis service installer This script will help you easily set up a running redis server Please select the redis port for this instance: [6379] 7001 Please select the redis config file name [/etc/redis/7001.conf] /etc/redis/redis_7001.conf Please select the redis log file name [/var/log/redis_7001.log] Selected default - /var/log/redis_7001.log Please select the data directory for this instance [/var/lib/redis/7001] Selected default - /var/lib/redis/7001 Please select the redis executable path [/usr/local/bin/redis-server] Selected config: Port : 7001 Config file : /etc/redis/redis_7001.conf Log file : /var/log/redis_7001.log Data dir : /var/lib/redis/7001 Executable : /usr/local/bin/redis-server Cli Executable : /usr/local/bin/redis-cli Is this ok? Then press ENTER to go on or Ctrl-C to abort.
–ÁÖÀÇ»çÇ× ÀÚµ¿½ÇÇà ȯ°á ¼³Á¤½Ã redis¿¡ ºñ¹Ð¹øÈ£¸¦ ¼³Á¤Çϸé Á¾·á󸮰¡ ¾ÈµÈ´Ù.
/etc/init.d ÀÇ redisȯ°æ¼³Á¤¿¡ ºñºô¹øÈ£¸¦ Ãß°¡ÇÑ´Ù.
stop) ..»ý·« $CLIEXEC -p $REDISPORT -a ºñ¹Ð¹øÈ£ shutdown ..»ý·«
–replication ÀÚµ¿º¹±¸ ¼³Á¤½Ã master ¿Í slaveÀÇ ºñ¹Ð¹øÈ£´Â µ¿ÀϽà ÇÑ´Ù.
Ç׸ñ masterauth, requirepass
–Momory»ç¿ë Çã¿ë·® ÃÊ°ú Ç㰡ó¸®
sudo sysctl vm.overcommit_memory=1 sudo echo "vm.overcommit_memory=1" >> /etc/sysctl.conf
È®ÀÎ
sudo sysctl -a | grep vm.overcommit_memory
–redis TCP Backlog ¿À·ù¼³Á¤ ³×Æ®¿öÅ©Çã°¡ µ¿Á¢Ç㰡ó¸®
sudo sysctl -w net.core.somaxconn=65535 sudo echo "net.core.somaxconn=65535" >> /etc/sysctl.conf
È®ÀÎ
sudo sysctl -a | grep net.core.somaxconn=65535