In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Official main site: http://www.redis.io/
Download address: http://www.redis.cn/download.html
Command API: http://www.redis.cn/commands.html
Redis official document: http://redis.io/documentation
I. introduction to Redis:
Redis is the abbreviation of Remote Dictionary Server. He is essentially a Key/Value database, a NoSQL database similar to Memcached, but his data can be persisted on disk, solving the problem of no data loss after service restart. His values can be string (string), list (list), sets (collection) or ordered sets (sorted collection). All data types have operations such as push/pop, add/remove, union of execution server, intersection, difference between two sets sets, and so on. These operations are atomic, and Redis also supports a variety of different sorting capabilities.
II. Redis deployment
1. Install related dependency packages:
Yum-y install gcc gcc-c++ cmake make
two。 Install the tcmalloc package [try a new memory allocation method]
Redis does not implement its own memory pool and does not add its own stuff to the standard system memory allocator.
Therefore, the performance and fragmentation rate of the system memory allocator will have some impact on the performance of Redis.
In the latest version, jemalloc is already included in the source package as part of the source package, so it can be used directly.
If you want to use tcmalloc, you need to install it yourself.
Tcmalloc is part of google-proftools (http://code.google.com/p/gperftools/downloads/list))
So we actually need to install google-proftools. If you are installing on a 64-bit machine, you need to install the dependent libunwind library first. 32-bit systems do not need it.
Download address: http://download.savannah.gnu.org/releases/libunwind/libunwind-0.99-alpha.tar.gz
(1)。 Install libunwind
Tar zxvf libunwind-0.99-alpha.tar.gz
Cd libunwind-0.99-alpha/
CFLAGS=-fPIC. / configure
Make CFLAGS=-fPIC
Make CFLAGS=-fPIC install
(2)。 Install gperftools
Tar zxvf gperftools-2.1.tar.gz
Cd gperftools-2.1
. / configure-disable-cpu-profiler-disable-heap-profiler-disable-heap-checker-disable-debugalloc-enable-minimal
Make & & make install
Cd / usr/local/lib
Ln-sv libtcmalloc_minimal.so.4.1.2 libtcmalloc.so
# if you don't do the bold part, you will get an error when compiling redis: usr/bin/ld: cannot find ltcmalloc
Echo "/ usr/local/lib" > / etc/ld.so.conf.d/usr_local_lib.conf # if you don't have this file, create one yourself
/ sbin/ldconfig
3.Redis installation:
Tar zxvf redis-3.0.0.tar.gz
Cd redis-3.0.0
Mkdir-p / usr/local/redis-3.0
# make prefix= install
# install redis under / bin / usr/local/redis-3.0/bin
# make PREFIX=/usr/local/redis-3.0 install # installed this way, using the default memory allocation method of linux
Make PREFIX=/usr/local/redis-3.0 USE_TCMALLOC=yes FORCE_LIBC_MALLOC=yes install
4. Create related directories and configure redis.conf files [simple configuration]
Cd / usr/local/redis-3.0/
Mkdir etc # stores the configuration file, where the directory name can be created as: conf
Mkdir log # stores logs and pid files
Mkdir data # storing data
Vim etc/redis.conf
Daemonize yes
Port 6379
Pidfile / usr/local/redis-3.0/log/redis_6379.pid
Dir / usr/local/redis-3.0/data
Logfile / usr/local/redis-3.0/log/redis_6379.log
5.Redis service starts, shuts down
(1)。 Start the service:
/ usr/local/redis-3.0/bin/redis-server / usr/local/redis-3.0/etc/redis.conf
Note:
This command has only one startup parameter, specifies the configuration file in the directory, and performs the default configuration without parameters.
Test start:
/ usr/local/redis-3.0/bin/redis-cli ping
If PONG is returned, the startup is successful.
Check to see if the port is occupied:
Netstat-ntlp | grep 6379
(2)。 Shut down the service:
/ usr/local/redis-3.0/bin/redis-cli shutdown
If it is not the default port, you can specify the port:
/ usr/local/redis-3.0/bin/redis-cli-p 6380 shutdown
(3)。 Verify that tcmalloc is being used in redis memory allocation
Lsof-n | grep tcmalloc
Redis-ser 2754 root mem REG 253,0 1078467 1725996 / usr/local/lib/libtcmalloc_minimal.so.4.1.2
6.Redis service startup script
Redis itself provides a redis installation script: utils/install_server.sh
But this script includes the installation service, which is a bit annoying, so let's just take the installation script:
#! / bin/sh
# Configurations injected by install_server below....
EXEC=/usr/local/redis-3.0/bin/redis-server
CLIEXEC=/usr/local/redis-3.0/bin/redis-cli
PIDFILE=/usr/local/redis-3.0/log/redis_6379.pid
CONF= "/ usr/local/redis-3.0/etc/redis.conf"
REDISPORT= "6379"
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 shutdown
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
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.