• Redis 4.0.14 单实例安装


    安装依赖包
    yum install gcc gcc-c++ automake autoconf lib tool make tcl zlib-devel -y
    
    下载地址:
    http://download.redis.io/releases/

    创建用户 groupadd
    --gid 500 redis useradd redis --uid 500 --gid 500 echo "redis" | passwd redis --stdin 创建目录 mkdir -p /data/redis/{base,redis_port,conf} mkdir -p /data/redis/data/6379 修改网络、内存及资源限制相关内核参数 cat >> /etc/sysctl.conf << EOF net.ipv4.tcp_max_syn_backlog = 65535 net.core.somaxconn = 65535 net.ipv4.tcp_max_tw_buckets = 262144 net.ipv4.tcp_keepalive_intvl = 15 net.ipv4.tcp_keepalive_probes = 3 net.ipv4.tcp_keepalive_time = 120 vm.overcommit_memory = 1 vm.swappiness = 1 fs.file-max = 1024000 EOF sysctl -p 检查THP(Transparent Huge Pages)是否开启(以下情况为开启) cat /sys/kernel/mm/transparent_hugepage/defrag [always] madvise never cat /sys/kernel/mm/transparent_hugepage/enabled [always] madvise never 禁用THP(立即生效) echo 'never' > /sys/kernel/mm/transparent_hugepage/enabled echo 'never' > /sys/kernel/mm/transparent_hugepage/defrag cat /sys/kernel/mm/transparent_hugepage/defrag cat /sys/kernel/mm/transparent_hugepage/enabled 禁用THP(重启生效) cat >> /etc/rc.d/rc.local << EOF if test -f /sys/kernel/mm/transparent_hugepage/enabled; then echo 'never' > /sys/kernel/mm/transparent_hugepage/enabled fi if test -f /sys/kernel/mm/transparent_hugepage/defrag; then echo 'never' > /sys/kernel/mm/transparent_hugepage/defrag fi EOF chmod +x /etc/rc.d/rc.local 修改 ulimit cat >> /etc/security/limits.conf <<EOF redis soft nofile 1024000 redis hard nofile 1024000 EOF cat >> /etc/security/limits.d/redis.conf <<EOF redis soft nofile 1024000 redis hard nofile 1024000 EOF 安装Redis软件 tar xf redis-4.0.14.tar.gz -C /data/redis/base cd /data/redis/base mv redis-4.0.14 4.0.14 cd /data/redis/base/4.0.14/deps make hiredis lua linenoise jemalloc cd /data/redis/base/4.0.14 make make PREFIX=/data/redis/base/4.0.14 install chown -R redis:redis /data/redis 配置环境变量,添加REDIS_HOME并且修改PATH, 注意:切换到redis用户下操作 su - redis vi ~/.bash_profile ### REDIS ### REDIS_HOME=/data/redis/base/4.0.14 PATH=$PATH:$REDIS_HOME/bin source ~/.bash_profile 参数配置 vi /data/redis/conf/redis_6379.conf ### Server ### pidfile /data/redis/data/6379/redis_6379.pid port 6379 bind 0.0.0.0 logfile "/data/redis/data/6379/redis_6379.log" dbfilename dump_6379.rdb dir /data/redis/data/6379 appendfilename "redis_6379.aof" daemonize yes loglevel notice databases 16 activerehashing yes hz 10 ### Auth ### requirepass "AY*s23y7Qt5w+J#rz^FoEBBB*Rc$u^qg" masterauth "AY*s23y7Qt5w+J#rz^FoEBBB*Rc$u^qg" ### Memory ### maxmemory 20gb maxmemory-policy noeviction maxmemory-samples 5 ### Persistence ### save " " stop-writes-on-bgsave-error no rdbcompression yes rdbchecksum yes appendonly no appendfsync everysec no-appendfsync-on-rewrite yes auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 2gb aof-load-truncated yes ### Clients ### maxclients 10000 tcp-backlog 65535 timeout 0 tcp-keepalive 60 client-output-buffer-limit normal 0 0 0 client-output-buffer-limit slave 256mb 64mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 ### Replication ### slave-serve-stale-data yes slave-read-only yes repl-diskless-sync no repl-diskless-sync-delay 5 repl-ping-slave-period 10 repl-disable-tcp-nodelay no repl-backlog-size 2gb repl-backlog-ttl 3600 slave-priority 100 ### Command ### rename-command flushall "" rename-command flushdb "" ### Slowlog ### slowlog-log-slower-than 1000 slowlog-max-len 1024 ### Redis 4.0 New ### lazyfree-lazy-eviction no lazyfree-lazy-expire yes lazyfree-lazy-server-del yes slave-lazy-flush yes 配置Redis启动脚本
    使用root用户操作 vi
    /etc/init.d/redis_6379 #!/bin/sh # # Simple Redis init.d script conceived to work on Linux systems # as it does use of the /proc filesystem. REDIS_PORT=6379 PASSWORD='AY*s23y7Qt5w+J#rz^FoEBBB*Rc$u^qg' EXEC=/data/redis/base/4.0.14/bin/redis-server CLIEXEC=/data/redis/base/4.0.14/bin/redis-cli PIDFILE=/data/redis/data/${REDIS_PORT}/redis_${REDIS_PORT}.pid CONF="/data/redis/conf/redis_${REDIS_PORT}.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 $REDIS_PORT -a $PASSWORD shutdown 2>/dev/null 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 修改启动脚本权限 chmod 770 /etc/init.d/redis_6379 chown redis.redis /etc/init.d/redis_6379 使用Redis用户启动redis server su - redis /etc/init.d/redis_6379 start
  • 相关阅读:
    「系统集成方案」智慧工地
    「Django」学习之路,持续更改
    「Django」与mysql8连接的若干问题
    「Python」socket指南
    「Python」35个知识点
    「CSS」文本编排相关的CSS属性设置
    「CSS」css基础
    bWAPP----HTML Injection
    bWAPP----HTML Injection
    bWAPP----HTML Injection
  • 原文地址:https://www.cnblogs.com/l10n/p/9410381.html
Copyright © 2020-2023  润新知