生產(chǎn)環(huán)境可用redis4.0.11安裝全過程
操作系統(tǒng)版本為 centos6.5
先執(zhí)行initialization.sh優(yōu)化腳本 詳情見 初始化腳本
我們線上用的是redis-4.0.11.tar.gz
根據(jù)日志內(nèi)容進行優(yōu)化 //后面會提現(xiàn)處理,我們這里可以先執(zhí)行,不明白的同學(xué),可以繼續(xù)往后看。
優(yōu)化1:
[root@prd3-redis01-10-183 conf]# echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf
[root@prd3-redis01-10-183 conf]# sysctl -p
優(yōu)化2:
[root@prd3-redis01-10-183 conf]# echo "net.core.somaxconn = 511" >> /etc/sysctl.conf
[root@prd3-redis01-10-183 conf]# sysctl -p
優(yōu)化3:
還有一個就是關(guān)閉透明大頁,我們優(yōu)化腳本中做了
第一步:執(zhí)行優(yōu)化腳本 initialization.sh
第二步:下載redis的安裝包
[root@prd3-redis01-10-183 opt]# wget http://download.redis.io/releases/redis-4.0.11.tar.gz
第三步:下載必要的依賴:yum install -y tcl tcl-devel
[root@prd3-redis01-10-183 opt]# yum install -y tcl tcl-devel
提示:在安裝過程中出現(xiàn)一個報錯為:解決方法如下
在安裝redis的時候 在執(zhí)行make && make install 的時候 出現(xiàn)報錯
make[3]: gcc: Command not found
/bin/sh: cc: command not found
[root@mysql-redis-mgdb redis-4.0.11]# yum -y install gcc+ gcc-c++
然后需要 刪除掉解壓的redis包 再重新壓縮后 再次執(zhí)行 make && make install
第四步:創(chuàng)建相關(guān)的目錄
[root@prd3-redis01-10-183 opt]# mkdir -p /ivargo/{app,log}
[root@prd3-redis01-10-183 opt]# cd /ivargo/
[root@prd3-redis01-10-183 ivargo]# ll
total 8
drwxr-xr-x 2 root root 4096 Apr 24 15:16 app
drwxr-xr-x 2 root root 4096 Apr 24 15:16 log
[root@prd3-redis01-10-183 ivargo]# cd app/
[root@prd3-redis01-10-183 app]# mkdir redis sentinel
[root@prd3-redis01-10-183 app]# ll
total 8
drwxr-xr-x 2 root root 4096 Apr 24 15:18 redis
drwxr-xr-x 2 root root 4096 Apr 24 15:18 sentinel
[root@prd3-redis01-10-183 app]# cd redis/
[root@prd3-redis01-10-183 redis]# mkdir conf data log
[root@prd3-redis01-10-183 redis]# ll
total 12
drwxr-xr-x 2 root root 4096 Apr 24 15:19 conf
drwxr-xr-x 2 root root 4096 Apr 24 15:19 data
drwxr-xr-x 2 root root 4096 Apr 24 15:19 log
[root@prd3-redis01-10-183 app]# cd sentinel/
[root@prd3-redis01-10-183 sentinel]# ll
total 0
[root@prd3-redis01-10-183 sentinel]# mkdir conf
[root@prd3-redis01-10-183 ivargo]# pwd
/ivargo
[root@prd3-redis01-10-183 ivargo]# tree
.
├── app
│?? ├── redis
│?? │?? ├── conf
│?? │?? ├── data
│?? │?? └── log
│?? └── sentinel
│?? └── conf
└── log
第五步:安裝redis
[root@prd3-redis01-10-183 ivargo]# cd /opt/
[root@prd3-redis01-10-183 opt]# ll
total 1708
-rw-r--r-- 1 root root 1739656 Aug 4 2018 redis-4.0.11.tar.gz
drwxr-xr-x. 2 root root 4096 Nov 22 2013 rh
drwxr-xr-x 2 root root 4096 Apr 24 2019 scripts
[root@prd3-redis01-10-183 opt]# tar zxvf redis-4.0.11.tar.gz
[root@prd3-redis01-10-183 opt]# cd redis-4.0.11
[root@prd3-redis01-10-183 redis-4.0.11]# make && make install
...
...
...
第六步:上傳配置文件到
[root@prd3-redis01-10-183 conf]# pwd
/ivargo/app/redis/conf
[root@prd3-redis01-10-183 conf]# ll
total 4
-rw-r--r-- 1 root root 3946 Apr 24 15:28 6379.conf
第七步,啟動redis
[root@prd3-redis01-10-183 conf]# redis-server /ivargo/app/redis/conf/6379.conf
[root@prd3-redis01-10-183 conf]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:6379 0.0.0.0: LISTEN 5195/redis-server 0
tcp 0 0 0.0.0.0:22 0.0.0.0: LISTEN 1543/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0: LISTEN 1619/master
tcp 0 0 :::22 ::: LISTEN 1543/sshd
tcp 0 0 ::1:25 :::* LISTEN 1619/master
[root@prd3-redis01-10-183 conf]# ps -ef|grep redis
root 5195 1 0 15:34 ? 00:00:00 redis-server 0.0.0.0:6379
root 5201 1709 0 15:35 pts/0 00:00:00 grep --color=auto redis
第八步檢查 redis
[root@prd3-redis01-10-183 log]# vim 6379.log
5194:C 24 Apr 15:34:51.909 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
5194:C 24 Apr 15:34:51.909 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=5194, just started
5194:C 24 Apr 15:34:51.909 # Configuration loaded
5195:M 24 Apr 15:34:51.935 Running mode=standalone, port=6379.
5195:M 24 Apr 15:34:51.935 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/c
ore/somaxconn is set to the lower value of 128.
5195:M 24 Apr 15:34:51.935 # Server initialized
5195:M 24 Apr 15:34:51.935 # WARNING overcommit_memory is set to 0! Background save may fail under low memory c
ondition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the comma
nd 'sysctl vm.overcommit_memory=1' for this to take effect.
5195:M 24 Apr 15:34:51.935 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This
will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/k
ernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting
after a reboot. Redis must be restarted after THP is disabled.
5195:M 24 Apr 15:34:51.935 Ready to accept connections
根據(jù)日志內(nèi)容進行優(yōu)化
優(yōu)化1:
[root@prd3-redis01-10-183 conf]# echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf
[root@prd3-redis01-10-183 conf]# sysctl -p
優(yōu)化2:
[root@prd3-redis01-10-183 conf]# echo "net.core.somaxconn = 511" >> /etc/sysctl.conf
[root@prd3-redis01-10-183 conf]# sysctl -p
優(yōu)化3:
還有一個就是關(guān)閉透明大頁,我們優(yōu)化腳本中做了
溫柔的關(guān)閉redis的方法
[root@web03 ~]# redis-server /ivargo/app/redis/conf/6379.conf
[root@web03 ~]# ps -ef|grep redis
root 1718 1 0 18:31 ? 00:00:00 redis-server 0.0.0.0:6379
root 1723 1693 0 18:31 pts/0 00:00:00 grep --color=auto redis
[root@web03 ~]# redis-cli -a xxx
Warning: Using a password with '-a' option on the command line interface may not be safe.
127.0.0.1:6379> shutdown //溫柔關(guān)閉redis的方法
not connected>
[root@web03 ~]# ps -ef|grep redis
root 1727 1693 0 18:32 pts/0 00:00:00 grep --color=auto redis
[root@prd3-redis01-10-183 conf]# sh /etc/rc.local
再次啟動redis,就沒有任何的報警了
到此,我們就安裝好了redis,接下來,我們實現(xiàn)redis的sentinel 架構(gòu) 請期待
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
分享名稱:生產(chǎn)環(huán)境可用redis4.0.11安裝全過程-創(chuàng)新互聯(lián)
網(wǎng)頁網(wǎng)址:http://jinyejixie.com/article8/diship.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計、關(guān)鍵詞優(yōu)化、外貿(mào)網(wǎng)站建設(shè)、ChatGPT、動態(tài)網(wǎng)站、微信公眾號
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容