Non-root users install redis
For detailed redis installation steps, please refer to my other article: http://meiling.blog.51cto.com/6220221/1979156
1. Ordinary users install redis
[centos6@localhost ~] $tar-xfredis-4.0.2.tar.gz [centos6@localhost ~] $cd redis-4.0.2 [centos6@localhost redis-4.0.2] $make [centos6@localhost redis-4.0.2] $sudo make install
2. Use sudo command to start with root under ordinary users.
2.1. Start the redis service as root
$sudo / usr/local/bin/redis-server/home/centos6/redisconf/redis.conf [centos6@localhost ~] $ps-ef | grep redisroot 33547 1 0 09:52? 00:00:00 / usr/local/bin/redis-server127.0.0.1:7200 centos6 33552 33452 0 09:52 pts/1 00:00:00 grep redis
2.2. To stop the redis service, use sudo to execute root permissions:
$sudo / usr/local/bin/redis-cli-p 7200 shutdown
3. Start redis as an ordinary user:
3.1. Modify the pid generation path to an ordinary user and define it yourself.
$vi / home/centos6/redisconf/redis.conf$ pidfile / home/centos6/redisconf/run/redis_7200.pid
Start the redis service:
$/ usr/local/bin/redis-server / home/centos6/redisconf/redis.conf
Stop redis as a normal user:
/ usr/local/bin/redis-cli-p 7200 shutdown
4. Configuration file redis.conf
# specify the port on which redis is running. The default is 6379.
Port 7200
# daemonize no by default, redis does not run in the background. If you need to run in the background, change the value of this item to yes
Daemonize yes
# when redis is running in the background, Redis will put the pid file in / var/run/redis.pid by default, and you can configure it to another address.
# when running multiple redis services, you need to specify different pid files and ports
# pidfile / var/run/redis_6379.pid
Pidfile / home/centos6/redisconf/run/redis_7200.pid
# specify that redis will only receive requests from this IP address. If not set, all requests will be processed.
# it is best to set this item in a production environment. Only local connections are allowed by default.
Bind 127.0.0.1
# set the timeout for client connection (in seconds). When the client does not issue any instructions during this period, then close the connection
# 0 is to disable this setting
Timeout 0
# specify logging level
# Redis supports a total of four levels: debug, verbose, notice and warning. Default is verbose.
# debug records a lot of information for development and testing
# varbose useful information, not as much as debug will record
# notice ordinary verbose, commonly used in production environment
# warning only very important or serious information will be logged
Loglevel debug
# configure log file address
# default value is stdout, standard output, if background mode will be output to / dev/null
# modify the location of the default log file generated
# logfile ""
Logfile "/ home/centos6/redisconf/logs/redis.log"
# configure the location where persistent files are stored
Dir / home/centos6/redisconf/data/redisData