Install redis on Alibaba Cloud CentOS7

download

  • Official download
    https://redis.io/download
  • wget download ( wget introduction )
    wget http://download.redis.io/releases/redis-6.0.6.tar.gz

Unzip

  • The official download needs to be transferred to the linux system through rz or other methods
  • Create a redis folder under usr/local, move the downloaded or rz uploaded file to usr/local/redis, or directly upload rz or wget download in this directory
  • Unzip tar xzf redis-6.0.6.tar.gz, and then there will be a folder for redis-6.0.6 under usr/local/redis
    Insert picture description here

Compile and install

Enter the folder cd redis-6.0.6
maketo compile, there will be some more executable files under redis-6.0.6/src, such as redis-server, redis-cli and other
Insert picture description here
make installinstallations. This is the default installation used, so there are a few more under usr/local/bin A redis executable file
before
Insert picture description here
installation and after installation (a few more redis executable files)
Insert picture description here

Change setting

  • daemonize Whether to start with a daemon thread, the default is no, which means that the redis process will be closed when exiting or closing the connection; yes means that the process daemon is turned on, and it will run in the background until the
    cd usr/local/redis/redis-6.0.6
    vim redis-conf
    specified location is manually stopped , and enter i to enter the insert editing mode , Change to yes, and then press esc to exit the editing mode.
    Insert picture description here
    Enter ":wq" and press Enter, save and exit
    Insert picture description here
  • If other machines need access, you need to comment or modify the bound bind 127.0.0.1 to 0.0.0.0; and add access rules on Alibaba Cloud
    Insert picture description here
  • Other references can refer to the following table or rookie tutorial
    Sex meaning
    daemonize no Redis does not run as a daemon by default. You can modify this configuration item to enable the daemon with yes (Windows does not support the configuration of daemon threads as no)
    location 6379 Specify the Redis listening port, the default port is 6379
    bind 127.0.0.1 Bound host address
    requirepass foobared Set the Redis connection password. If the connection password is configured, the client needs to provide the password through the AUTH command when connecting to Redis, which is closed by default

Start method

  • Start by default (bind 127.0.0.1 can only be local, no password) to
    redis-serverstart the redis service.
    redis-cliStart the client and reopen an xshell connection for testing.
    Insert picture description here
    redis-cli shutdownClose the redis service
  • Specify the configuration file to start
    redis-server usr/local/redis/redis-6.0.6/redus.conf
  • The script content of redis_init_script
    which comes with redis_init_script to automatically start under redis-6.0.6/utils
    Insert picture description here
    is as follows:
    #!/bin/sh
    #
    # Simple Redis init.d script conceived to work on Linux systems
    # as it does use of the /proc filesystem.
    
    ### BEGIN INIT INFO
    # Provides:     redis_6379
    # Default-Start:        2 3 4 5
    # Default-Stop:         0 1 6
    # Short-Description:    Redis data structure server
    # Description:          Redis data structure server. See https://redis.io
    ### END INIT INFO
    
    REDISPORT=6379
    EXEC=/usr/local/bin/redis-server
    CLIEXEC=/usr/local/bin/redis-cli
    
    PIDFILE=/var/run/redis_${
          
          REDISPORT}.pid
    CONF="/etc/redis/${REDISPORT}.conf"
    
    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
            ;;
        *)
            echo "Please use start or stop as first argument"
            ;;
    esac
    
    
    Create a redis folder under /etc,
    cd etcswitch to the etc directory,
    mkdir rediscreate a redis folder,
    cp /usr/local/redis/redis-6.0.6/redis.conf /etc/redis/6379.confcopy the modified configuration file to etc/redis and rename it to 6379.conf
    cp /usr/local/redis/redis-6.0.6/utils/redis_init_script /etc/init.d/redisredis_init_script to automatically start the script under etc/init.d/ and rename it to redis
    chkconfig redis onset at startup redis service, Ali cloud services purchased using the restart after viewing redis process, the configuration is complete
    Insert picture description here
    addition can be closed manually open and close from the start redis service
    chkconfig redis offset the boot does not start automatically redis service
    service redis startopen redis service
    service redis stopclosed redis service

stop

  • Check the redis service status,
    ps aux|grep redisyou can see that the redis-server is running
    Insert picture description here

  • Stop the redis service
    redis-cli shutdownwithout setting the redis password to use.
    redis-cli -a password shutdownSet the redis password to use, here password is replaced with the password you set (if you set the password and use redis-cli shutdown, it will report "NOAUTH Authentication required")

  • Again, ps aux|grep redisyou can see that the redis service has stopped
    Insert picture description here

Uninstall

  • Delete several redis files generated by make installation
    Insert picture description here
  • Delete the downloaded redis and the decompressed redis file
    Insert picture description here

Debugging tool (Redis free client Another Redis DeskTop Manager)

AnotherRedisDesktopManager

Reference connection:
Three ways to
start
Redis Configure redis under Linux to automatically start Redis installation and uninstall Redis installation and uninstallation in
Linux
Add link description
linux install redis complete steps Alibaba
Cloud install redis and remotely connect to
CentOS7 install Redis
linux install redis complete steps

Guess you like

Origin blog.csdn.net/nongminkouhao/article/details/108058151
Recommended