Installing Redis services with a regular account

Source: Internet
Author: User
Tags redis centos
installing Redis services with a regular account Start Installation

This is done using the 2.8 version of Redis for installation, with security in mind, installation using a regular account, and Redis general account setup scripts I've made into scripts. The script is long and is not posted here, and interested friends can download the script on my GitHub project: install_redis.sh, how to use the script:

./install_redis.sh Redis_pack_director [Port]

If you do not set ports, port is set to 16379 by default, preventing malicious programs from scanning and attacking the default 6379 port

The installation process is as follows:

Create a Redis account

Useradd Redis
Su-redis

Install package Download:

wget https://github.com/antirez/redis/archive/2.8.23.tar.gz

Start installation

Tar xzf 2.8.23.tar.gz
./install_redis.sh redis-2.8.23

After the installation is completed, a Redis directory is generated in the home directory of the Redis account, the directory structure bin:redis the executable file folder etc:redis the configuration file folder, the configuration file is redis.conf Db:redis data file folder, the data text Only open rdb files, data files Dump.rdb Log:redis log files folder, log files for Redis.log Lib:redis Library Files folder Pidfile will be placed directly under the Redis directory

Compared to the default configuration file, the resulting configuration file makes the following changes: After the change of the file (log file, pidfile, data file), the storage path of the above files is modified, the boot port is 16379 (security considerations) set MaxClients to 10000 (performance considerations) Close CON FIG command (Security Considerations)

After the installation is complete, the script will add the user's Home/redis/bin directory to path, set alias to Aliasredis−server=′redis−server Home/redis/bin directory to join Path, set alias to Alias redis-server= ' Redis-server home/redis/etc/redis.conf '. Users can start directly using Redis-server, which uses the $HOME/redis/etc/redis.conf as the configuration file by default

In addition, the Redis.service file is generated under the $HOME directory of the installation account, which is the Redis service file. Using this file, you can set up Redis as a service (start the service using the installation account), followed by instructions to start and stop Redis

Start

Execute directly under the Redis account

Redis-server

Stop

Execute under the Redis account

Redis-cli-p 16379 shutdown
Install as a service

Installation service requires a sysvinit-based service configuration using the root account

If the user is using a sysvinit system (System prior to CentOS 7 or REH 7)

Chown-r Root:root/non-root/home/path/redis.service
MV/NON-ROOT/HOME/PATH/REDIS.SERVICE/ETC/INIT.D

Start the service

Service Redis.service Start

Stop Service

Service Redis.service Stop

Restart Service

Service Redis.service Restart

Add Turn on Start

Chkconfig--add redis.service
chkconfig redis.service on
SYSTEMD-based service configuration

If the user is using a SYSTEMD system (System after CentOS 7 or REH 7)

Chown-r Root:root/non-root/home/path/redis.service
Mv/non-root/home/path/redis.service/etc/systemd/system

Start the service

Systemctl Start Redis.service

Stop Service

Systemctl Stop Redis.service

Restart Service

Systemctl Restart Redis.service

Add Turn on Start

Systemctl Enable Redis.service
Primary and Standby configuration scheme

The Redis master configuration scheme can be implemented using keepalived + Redis, in which the repository is hot-standby and only the main library data is synchronized. Specific configuration method reference redis+keepalived to achieve redis high availability, this is not a repeat

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.