Redis installation configuration reference
1. Operating system parameters and service configuration:
Sed-I's setting SELINUXFORCING'/ etc/selinux/config
Systemctl stop firewalld
Systemctl disable firewalld
Echo "vm.overcommit_memory=1" > > / etc/sysctl.conf
Echo "vm.swappiness=10" > > / etc/sysctl.conf
Echo 10 > / proc/sys/vm/swappiness
Echo "net.core.somaxconn=65535" > > / etc/sysctl.conf
Echo "net.ipv4.tcp_max_syn_backlog=65535" > > / etc/sysctl.conf
Echo "net.ipv4.tcp_max_syn_backlog=65535" > > / etc/sysctl.conf
Echo "net.core.somaxconn=65535" > > / etc/sysctl.conf
Echo "soft nofile 288000" > > / etc/security/limits.conf
Echo "hard nofile 288000" > > / etc/security/limits.conf
Sysctl-p
Turn off large page memory:
Echo never > / sys/kernel/mm/transparent_hugepage/enabled
Echo never > / sys/kernel/mm/transparent_hugepage/defrag
Echo "echo never > / sys/kernel/mm/transparent_hugepage/enabled" > > / etc/rc.d/rc.local
Echo "echo never > / sys/kernel/mm/transparent_hugepage/defrag" > > / etc/rc.d/rc.local
Chmod axix / etc/rc.d/rc.local
Operating system ntp service settings:
# check the current system time zone, if it is not Shanghai, modify it to Shanghai
Timedatectl | grep "Time zone"
Timedatectl set-timezone Asia/Shanghai
Cp / usr/share/zoneinfo/Asia/Shanghai / etc/localtime
Install the ntp service
Yum install ntpdate-y
# write timing task synchronization time
Crontab-e
0-59 take 10 / usr/sbin/ntpdate ntp1.aliyun.com | logger-t NTP
# Test whether the synchronization time can be successful
/ usr/sbin/ntpdate ntp1.aliyun.com
Service deployment, dependent deployment:
Yum install gcc wget-y
Download and install 2.redis software:
Cd / usr/local
Wget http://download.redis.io/releases/redis-4.0.11.tar.gz
Tar xvzf redis-4.0.11.tar.gz
Ln-s redis-4.0.11 redis
Cd redis
Make
Make install
Cd ~
Vim .bash _ profile
PATH=$PATH:$HOME/bin:/usr/local/redis/src
Source .bash _ profile
# verify whether the installation is successful. If the version number appears, the installation is successful:
Redis-cli-v
Mkdir-p / data/redis-6379/logs/
Mkdir-p / data/redis-6379/run/
Edit the redis configuration file:
Modify the maxmemory and port parameters and the corresponding bind as needed, for example, the port number is 6379
Configuration file port6379,IP address 192.168.56.201:
Bind 127.0.0.1 192.168.56.201
Protected-mode no
Port 6379
Tcp-backlog 10000
Timeout 0
Tcp-keepalive 60
Daemonize yes
Supervised no
Pidfile "/ data/redis-6379/run/redis_6379.pid"
Loglevel notice
Logfile "/ data/redis-6379/logs/6379.log"
Databases 16
Stop-writes-on-bgsave-error yes
Rdbcompression yes
Rdbchecksum yes
Dbfilename "dump6379.rdb"
Dir "/ data/redis-6379"
# slaveof 192.168.56.201 6379 # master ip address and port
Slave-serve-stale-data yes
Slave-read-only yes
Repl-diskless-sync no
Repl-diskless-sync-delay 5
Repl-timeout 60
Repl-disable-tcp-nodelay no
Repl-backlog-size 10mb
Repl-backlog-ttl 3600
Slave-priority 100
Maxclients 10000
Maxmemory 5000000kb
Maxmemory-policy volatile-lru
Appendonly yes
Appendfilename "appendonly6379.aof"
Appendfsync everysec
No-appendfsync-on-rewrite no
Auto-aof-rewrite-percentage 0
Auto-aof-rewrite-min-size 64mb
Aof-load-truncated yes
Aof-use-rdb-preamble yes
Lua-time-limit 5000
Slowlog-log-slower-than 1000
Slowlog-max-len 1000
Latency-monitor-threshold 0
Notify-keyspace-events ""
Hash-max-ziplist-entries 512
Hash-max-ziplist-value 64
List-max-ziplist-size-2
List-compress-depth 0
Set-max-intset-entries 512
Zset-max-ziplist-entries 128
Zset-max-ziplist-value 64
Hll-sparse-max-bytes 3000
Activerehashing yes
Client-output-buffer-limit normal 0 0 0
Client-output-buffer-limit slave 512mb 128mb 60
Client-output-buffer-limit pubsub 32mb 8mb 60
Hz 10
Aof-rewrite-incremental-fsync yes
Start Redis:
Redis-server / data/redis-6379/6379.conf
Login:
Redis-cli-p 6379
Add scheduled tasks to do scheduled rdb backup and aof backup:
0 redis-cli-p 6379 bgsave
0 1 * redis-cli-p 6379 BGREWRITEAOF