In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to configure single instance redis in Linux. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Introduction of redis
Redis is an advanced key-value database. It is similar to memcached, except that data can be persisted and supports a wide range of data types. There are strings, linked lists, sets and ordered collections. Support in the server-side calculation of the collection union, intersection and complement set (difference), etc., but also supports a variety of sorting functions. So Redis can also be seen as a data structure server. PS: this installation stores the user session session in the form of a redis storage string.
Installation planning package save location: / usr/local/src package compilation location: / usr/local/src/redis-x-x/ software installation location: / usr/local/redis/ software command location: / usr/local/redis/bin software log save location: / usr/local/reids/redis.log software configuration file location: / usr/local/redis/etc/redis.conf software pid file location: / var/ Run/redis.pid software startup service location: / etc/init.d/redis software authentication requires password Redis installation
Preparation for redis, installation of dependency packages
Centos series:
Yum repolistyum-y install gcc gcc-c++ make gmake cmake zlib tcl
Ubuntu series:
Agt-get updateAgt-get install gcc gcc-c++ make zlib tcl
Download the package and install redis
Cd / usr/local/src\\ enter the package directory (normalization) wget http://download.redis.io/releases/redis-3.2.9.tar.gz\\ download the package tar-xzf redis-3.2.9.tar.gz\\ # extract and enter the redis directory cd redis-3.2.9 \\ extract and enter the redis directory # run the test. / runtest# precompiled compile install makemake test# enter the src directory to install cd srcmake PREFIX=/usr/local/redis installPS:redis the compilation and installation process is long Here we have installed the redis compilation to the "/ usr/local/redis" directory. By default, the bin command can be called directly under the "/ usr/bin" command. We need to add system environment variables at a later stage after the installation path.
Redis profile
Create the configuration file directory for redis and copy the configuration file redis.conf
Mkdir-p / usr/local/redis/etccp / usr/local/src/redis-3.2.9/redis.conf / usr/local/redis/etc/redis.conf
Modify the configuration file
Vim / usr/local/redis/etc/redis.conf cat / usr/local/redis/etc/redis.conf | grep-v "^ $" | grep-v "#
Bind 0.0.0.0\\ modify content = external monitoring protected-mode yesport 6379\\ modify port number = open according to demand tcp-backlog 511timeout 0tcp-keepalive 300daemonize yes\\ daemon mode Add supervised nopidfile / var/run/redis.pid\\ pid location loglevel verbose\\ Log startup level logfile / usr/local/redis/redis.log\\ Log save location databases 16\\ reids database number save 900 1save 300 10save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename dump.rdbdir. / slave- Serve-stale-data yesslave-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay noslave-priority 100requirepass mima\\ access authentication = password maxmemory 256m\\ maximum memory setting maxmemory-policy volatile-ttl\\ redis maximum memory discard rule appendonly noappendfilename "appendonly.aof" appendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite -percentage 100auto-aof-rewrite-min-size 64mbaof-load-truncated yeslua-time-limit 5000slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events "" hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-size-2list-compress-depth 0set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64hll-sparse-max-bytes 3000activerehashing yesclient-output-buffer-limit normal 000000
Profile modifications:
Port 6379 modify port number bind 0.0.0.0 modify binding IP (on demand) timeout 0 modify connection timeout loglevel verbose log three types debug, verbose, notice, Warnlogfile / var/log/redis.log log directory * memory size of maxmemory 256m redis * * maxmemory-policy volatile-ttl memory discard policy requirepass password redis authentication rules * * (on demand)
PS: pay attention to the location of the configuration log, pid, etc., which should be associated with the startup script. The password is also associated with the startup script.
Create and modify system startup configuration file
Create a system service startup file
Template for startup file: / usr/local/src/redis-3.2.9/utils/redis_init_script
Cp / usr/local/src/redis-3.2.9/utils/redis_init_script / etc/init.d/redischmod 755 / etc/init.d/redis
Modify the system startup script
#! / bin/sh#Configurations injected by install_server below....EXEC=/usr/local/redis/bin/redis-server # Service Command launch # CLIEXEC=/usr/local/redis/bin/redis-cli # client command path # PIDFILE=/var/run/redis.pid # pid file location # to be consistent with the configuration file CONF= "/ usr/local/redis/etc / redis.conf "# path to the redis configuration file # # REDISPORT=" 6379 "# Startup Port # SysV Init Information# chkconfig:-58 74 # add content Note but meaningful # description: redis_6379 is the redis daemon.### BEGIN INIT INFO# Provides: redis_6379 # startup port # Required-Start: $network $local_fs $remote_fs# Required-Stop: $network $local_fs $remote_fs# Default-Start: 2 3 4 "Default-Stop: 0 1" Should-Start: $syslog $named# Should-Stop: $syslog $named # Short-Description: start and stop redis_6379# Description: Redis daemon### END INIT INFO case "$1" in start) if [- f $PIDFILE] then echo "$PIDFILE exists Process is already running or crashed "else echo" Starting Redis server... "$EXEC $CONF fi Stop) if [!-f $PIDFILE] then echo "$PIDFILE does not exist, process is not running" else PID=$ (cat $PIDFILE) echo "Stopping..." $CLIEXEC-p $REDISPORT-a mima shutdown\\ # Add-a password authentication project # while [- x / proc/$ {PID}] do echo "Waiting for Redis to shutdown..." Sleep 1 done echo "Redis stopped" fi;; status) PID=$ (cat $PIDFILE) if [!-x / proc/$ {PID}] then echo 'Redis is not running' else echo "Redis is running ($PID)" fi;; restart) $0 stop $0 start *) echo "Please use start, stop, restart or status as first argument"; esac
PS: anyone who has read "this is how to learn from Linux" knows how to write and format the system boot file, so we won't explain it here.
There are two ways to add authentication to redis startup script
Method 1:
Method 2:
Add a startup script to the system service
Chkconfig-- add redis # add system Services chkconfig redis on # set up Boot service redis startservice redis statusservice redis stopservice redis restart
Ubuntu system does not have chkconfig
PS:chkconfig may not be easy to install on ubuntu systems and can be used using the update-rc.d command.
Update-rc.d redisd defaults 80 80root@linuxprobe:/etc/redis# update-rc.d redisd defaults 80 80Adding system startup for / etc/init.d/redisd... / etc/rc0.d/K80redisd->.. / init.d/redisd/etc/rc1.d/K80redisd->.. / init.d/redisd/etc/rc6.d/K80redisd->.. / init.d/redisd/etc/rc2.d/S80redisd->.. / init.d/redisd/etc/rc3.d/S80redisd ->.. / init.d/redisd/etc/rc4.d/S80redisd->.. / init.d/redisd/etc/rc5.d/S80redisd->.. / init.d/redisd 2345 start 0 1 6 shut down
If the authentication field is not added in the startup script:
Consistency of startup files
This is the end of the article on "how to configure single instance redis in Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.