【目標】
創(chuàng)新互聯(lián)建站堅持“要么做到,要么別承諾”的工作理念,服務領域包括:成都做網(wǎng)站、成都網(wǎng)站建設、
成都外貿網(wǎng)站建設、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣等服務,滿足客戶于互聯(lián)網(wǎng)時代的
紫云網(wǎng)站設計、移動媒體設計的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡建設合作伙伴!
配置 redis 單機主從,6378 端口連接 master,6379 端口連接 slave,master 可讀寫,slave 只讀。
【安裝及測試】
sudo?apt?update
sudo?apt?install?redis
walker@Ubuntu:~$?redis-cli
127.0.0.1:6379>?ping
PONG
#?查看狀態(tài)
$?systemctl?status?redis
#?啟動redis
$?systemctl?start?redis
#重啟redis
$?systemctl?restart?redis
#?停止redis
$?systemctl?stop?redis
#?將?redis?服務加入開機啟動
$?systemctl?enable?redis
#?禁止開機啟動
$?systemctl?disable?redis
【配置單機主從】
mkdir?-p??/data/redis/{6378-master,6379-slave}/{conf,db,log}
cp?/etc/redis/redis.conf?/data/redis/6378-master/conf/
cp?/etc/redis/redis.conf?/data/redis/6379-slave/conf/
daemonize?yes?
pidfile?/data/redis/6378-master/redis.pid?
bind?0.0.0.0
port?6378?
logfile?/data/redis/6378-master/log/redis.log
dir?/data/redis/6378-master/db/
daemonize?yes?
pidfile?/data/redis/6379-slave/redis.pid?
bind?0.0.0.0
port?6379?
logfile?/data/redis/6379-slave/log/redis.log
dir?/data/redis/6379-slave/db/?
slaveof?127.0.0.1?6378
sudo?systemctl?stop?redis
sudo?systemctl?disable?redis
sudo?redis-server?/data/redis/6378-master/conf/redis.conf????#?啟動?master
sudo?redis-server?/data/redis/6379-slave/conf/redis.conf????#?啟動?slave
#?ps?aux?|?grep?redis
root??6069??0.0??0.1??50148??3952???????????Ssl??03:15 0:00?redis-server?0.0.0.0:6378
root??6451??0.0??0.0??50148??3852???????????Ssl??03:27 0:00?redis-server?0.0.0.0:6379
root??6457??0.0??0.0??13136??1084??pts/0????S+???03:28 0:00?grep?--color=auto?redis
redis-cli?-h?127.0.0.1?-p?6378?shutdown????#?關閉?master
redis-cli?-h?127.0.0.1?-p?6379?shutdown????#?關閉?slave
【持久化】
默認已啟用了 rdb 方式的持久化。(/data/redis/6378-master/conf/redis.conf)
#?save?
?
#?save?""
save?900?1???#?若?900?秒內有?1?個更改則將內存中的數(shù)據(jù)快照寫入磁盤?
save?300?10?????#?若?300?秒內有?10?個更改則將內存中的數(shù)據(jù)快照寫入磁盤?
save?60?10000???#?若?60??秒內有?10000?個更改則將內存中的數(shù)據(jù)快照寫入磁盤walker 猜想實現(xiàn)方式應該是時間從小到大:設置定時器監(jiān)測,60 秒內有 10000 個更改則保存,300 秒內有 10 個更改則保存,900 秒內有 1 個更改則保存。
【大內存】
#?maxmemory?
#?1G
maxmemory?1073741824【查看版本】
#?redis-server?-v?
Redis?server?v=4.0.9?sha=00000000:0?malloc=jemalloc-3.6.0?bits=64?build=1bc80a08306a3efd【查看配置】
$redis-cli?-h?127.0.0.1?-p?6378?-a?"mypass"
127.0.0.1:6378>?info【配置開機啟動】
[Unit]
Description=/etc/rc.local?Compatibility
ConditionPathExists=/etc/rc.local
After=network.target
[Service]
Type=forking
ExecStart=/etc/rc.local?start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target#!/bin/bash
redis-server?/data/redis/6378-master/conf/redis.conf
redis-server?/data/redis/6379-slave/conf/redis.conf
/home/walker/Python3Project/proxy_gather/start.sh
exit?0sudo?chmod?754?/etc/rc.localsudo?systemctl?enable?rc-local
#?等價于
ln?-s?/etc/systemd/system/rc-local.service?/etc/systemd/system/multi-user.target.wants/sudo?systemctl?start?rc-local.service
sudo?systemctl?status?rc-local.service*** walker ***
另外有需要云服務器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
當前文章:UbuntuServer18.04配置Redis單機主從-創(chuàng)新互聯(lián)
分享鏈接:http://weahome.cn/article/ddjcic.html