##### Installing Redis-server #####
# Create a running user
Useradd redis-s/sbin/nologin-m
# Upload the software to the specified location, my software is saved in the location
Mkdir-p/server/tools/
# Unzip, configure, compile, install
CD/SERVER/TOOLS/TAR-ZXF redis-3.0.5.tar.gz CD Redis-3.0.5make prefix=/usr/local/redismake PREFIX=/usr/local/redis Install
# Configure REDIS Environment variables
Echo ' >>/etc/profile echo ' PATH for Redis-server ' >>/etc/profile echo ' Export path=/usr/local/redis/bin/: $PATH ' >>/etc/profile tail-3/etc/profilesource/etc/profileecho $PATH
# or (restart disabled)
Export path=/usr/local/redis/bin/: $PATHecho $PATH
# Create profiles, data, logs and other related directories, and copy configuration files
# Creating a canonical directory structure helps to make good habits and improve efficiency.
Mkdir-p/usr/local/redis/confmkdir-p/usr/local/redis/datamkdir-p/USR/LOCAL/REDIS/LOGSCP redis.conf/usr/local/ Redis/conf/cd/usr/local/redis/conf/tree/usr/local/redis
# to this Redis basic configuration is complete and can be started using Redis initial configuration
# Start command
/usr/local/redis/bin/redis-server/usr/local/redis/conf/redis.conf &
# View startup status, processes and ports
Ps-ef |grep REDISNETSTAT-ANPTL |grep Redis
# Test and use
# The Client connection command is:
/usr/local/redis/bin/redis-cli-p 6379[[email protected] redis]# redis-cli-p 6379127.0.0.1:6379> set a 1OK127.0.0.1 :6379> get a "1" 127.0.0.1:6379> set B 2ok127.0.0.1:6379> set C 3ok127.0.0.1:6379> keys *) "C" 2) "a" 3) "B" 127. 0.0.1:6379> exit
# above is a simple test, verify the installation is correct or not
# Secure off Redis
/USR/LOCAL/REDIS/BIN/REDIS-CLI shutdown
# when Redis is turned off, data is saved by default at the location where Redis was started and saved as Dump.rdb
--------Simple Redis---------optimization
# starting Redis-server with the default configuration the following warning message appears: No impact on use,
# However, the author's habits naturally do not tolerate the existence of such warning messages:
[[Email protected] redis]# redis-server /usr/local/redis/conf/redis.conf &[1] 4570[[email protected] redis]# [4570] 07 Dec 03:54:50.938 * increased maximum number of open files to 10032 (it was originally set to 1024) . _._ _.-' __ '-._ _.-' ' . ' _. '-._ Redis 3.0.5 (00000000/0) 64 bit .-' .-' . ' \/ _.,_ '-._ ( ' , .-' | ', ) running in stand alone mode | ' -._ '-...-' __...-. '-._| ' ' _.-' | port: 6379 | '-._ '. _ / _.-' | PID: 4570 '-._ '-._ '-./ _.-' _.-' | '-._ '-._ '-.__.-' _.-' _.-' | | '-._ '-._ _.-' _.-' | http://redis.io '-._ '-._ '-.__.-' _.-' _.-' | '-._ '-._ '-.__.-' _.-' _.-' | | '-._ '-._ _.-' _.-' | '-._ '-._ '-.__.-' _.-' _.-' '- ._ '-.__.-' _.-' '-._ _.-' '-.__.-' [4570] 07 dec 03:54:50.939 # server started, redis version 3.0.5[4570] 07 dec 03:54:50.939 # warning overcommit_memory is set to 0! Background save may fail under low memory condition. to fix this issue add ' Vm.overcommit_ Memory = 1 ' to /etc/sysctl.conf and then reboot or run the command ' Sysctl vm.overcommit_memory=1 ' for this to take effect. [4570] 07 dec 03:54:50.939 # warning you have transparent huge Pages (THP) support enabled in your kernel. this will create latency and Memory usage issues with redis. to fix this issue run the command ' echo never > /sys/kernel/mm/transparent_hugepage/enabled ' as Root, and add it to your /etc/rc.local in order to retain the setting after a reboot. redis must be restarted after thp is disabled. [4570] 07 dec 03:54:50.939 # warning: the tcp backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. [4570] 07 dec 03:54:50.939 * the server is now ready to accept connections on port 6379
# According to the boot log prompts need to optimize some kernel parameters, follow the instructions:
echo Never >/sys/kernel/mm/transparent_hugepage/enabledcat/sys/kernel/mm/transparent_hugepage/enabledecho 511 >/proc/sys/net/core/somaxconncat/proc/sys/net/core/somaxconnecho "vm.overcommit_memory = 1" >>/etc/ Sysctl.confsysctl-p
# above operation restart failure, you can press the operation to configure the next power on, the way to set up Redis boot
echo "" >>/etc/rc.localecho "# Redis-server by ZS in $ (date +%f)" >>/etc/rc.localecho "echo Never >/sys /kernel/mm/transparent_hugepage/enabled ">>/etc/rc.localecho" echo 511 >/proc/sys/net/core/somaxconn "> >/etc/rc.localecho "/usr/local/redis/bin/redis-server/usr/local/redis/conf/redis.conf" >>/etc/ Rc.localtail-5/etc/rc.local
# Continue to optimize configuration files
Vim/usr/local/redis/conf/redis.conf
# Look for the following keywords in the configuration file, which can be modified as follows:
daemonize yes # Whether to run in the background, yes for background run pidfile /usr/local/redis/logs/redis.pid # Redis's PID File save location port 6379 # redis Monitoring Port bind 0.0.0.0 # redis Monitoring of the iptimeout 0 # the length of time that the service side remains connected when the client connection is closed, timeout # 0 for continuous connection, waiting for client to connect again logfile "/usr/local/redis/logs/redis.log" # log File Save location dbfilename redis.rdb # redis Data file name dir /usr/local/redis/data/ # redis Data Save Location appendonly yes # write log, similar to MySQL's Bin-log
The above is a simple Redis optimized configuration
If you need more detailed configuration, you can refer to the instructions in "Redis configuration Explained" later.
###### END ######
This article is from the "Qin Notes" blog, please be sure to keep this source http://ciqin.blog.51cto.com/10608412/1794688
Source Installation redis-3.0.5