您好,登錄后才能下訂單哦!
1.操作系統參數和服務配置:
sed -i 's@SELINUX=enforcing@SELINUX=disabled@g' /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
關閉大頁內存:
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 a+x /etc/rc.d/rc.local
操作系統ntp服務設置:
#檢查當前系統時區,如果不是上海,修改為上海
timedatectl |grep "Time zone"
timedatectl set-timezone Asia/Shanghai
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
安裝ntp服務
yum install ntpdate -y
#寫入定時任務同步時間
crontab -e
0-59/10 /usr/sbin/ntpdate ntp1.aliyun.com | logger -t NTP
#測試同步時間是否可以成功
/usr/sbin/ntpdate ntp1.aliyun.com
服務部署、依賴部署:
yum install gcc wget -y
2.redis軟件下載及安裝:
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
#驗證是否安裝成功,如果出現版本號則說明安裝成功:
redis-cli -v
mkdir -p /data/redis-6379/logs/
mkdir -p /data/redis-6379/run/
編輯redis配置文件:
根據需要修改maxmemory和port參數以及對應的bind,例如端口號為6379,sed -i 's/6379/xxxx/g' xxxx.conf
配置文件port6379,IP地址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地址和端口
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
啟動Redis:
redis-server /data/redis-6379/6379.conf
登錄:
redis-cli -p 6379
添加定時任務定時做rdb備份和aof備份:
0 redis-cli -p 6379 bgsave
0 1 * redis-cli -p 6379 BGREWRITEAOF
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。