第21周作業

2022-08-12 08:15:13 字數 2036 閱讀 4420

1、搭建乙個 redis 哨兵集群

實驗環境:主節點 10.0.0.81 從節點1 10.0.0.82 從節點2 10.0.0.83

首先安裝redis,yum install -y redis

實現redis的主從複製

在主節點,修改配置檔案 /etc/redis.conf

sed -ei.bak 's/bind 127.0.0.1/bind 0.0.0.0/' /etc/redis.conf

requirepass 123456

在全部從節點,修改配置檔案 /etc/redis.conf

sed -ei.bak 's/bind 127.0.0.1/bind 0.0.0.0/' /etc/redis.conf

replicaof 10.0.0.81 6379

requirepass 123456

masterauth 123456

主,從節點設定服務的開機自啟與服務啟動

systemctl enable --now redis

設定哨兵環境

主節點修改配置檔案 /etc/redis-sentinel.conf

sentinel monitor mymaster 10.0.0.81 6379 2

sentinel auth-pass mymaster 123456

sentinel down-after-milliseconds mymaster 3000

將修改好的主節點sentinel的配置檔案傳送到全部從節點

確保每個哨兵主機的muid不同

主從節點啟動服務

systemctl enable --now redis-sentinel.conf

ss -ntl 檢視26379埠是否開啟

2、實現 redis cluster 得部署

實驗環境:6臺機器 81-86

每台機器安裝redis

yum install -y redis

修改每台機器的配置檔案,同時檢查機器是否有資料,確保沒有資料

sed -i.bak -e 's/bind 127.0.0.1/bind 0.0.0.0/' -e '/masterauth/a masterauth 123456' -e '/# requirepass/a requirepass 123456' -e '/# cluster-enabled yes/a cluster-enabled yes' -e '/# cluster-config-file nodes-6379.conf/a cluster-config-file nodes-6379.conf' -e '/cluster-require-full-coverage yes/c cluster-require-full-coverage no' /etc/redis.conf

每台機器啟動服務

systemctl enable --now redis

類似meet的操作

redis-cli -a 123456 --cluster create 10.0.0.81:6379 10.0.0.82:6379 10.0.0.83:6379 10.0.0.84:6379 10.0.0.85:6379 10.0.0.86:6379 --cluster-replicas 1

輸入 yes

檢視主從狀態

redis-cli -a 123456 -c info replication

redis-cli cluster nodes

3、部署乙個 tomcat 服務

#!/bin/bash

. /etc/init.d/functions

dir=`pwd`

jdk_file="jdk-8u271-linux-x64.tar.gz"

tomcat_file="apache-tomcat-8.5.59.tar.gz"

jdk_dir="/usr/local"

tomcat_dir="/usr/local"

install_jdk()

}install_tomcat()

}install_jdk

install_tomcat

第8周作業作業

1 對稱加密過程由那三部分組成 加密 傳送方將資訊通過對稱金鑰加密形成密文 傳輸 傳送方通過網路把密文傳出 解密 接收者將資訊用對稱金鑰進行解密形成明文 2 使用 openssl 中的 aes 對稱加密演算法對檔案 file.txt 進行加密,然後解密 openssl enc aes 128 cbc...

第4周作業

習題5 include using namespace std int main cout 自然對數 e 的近似值為 習題6 includeusing namespace std int main cout 習題7 include using namespace std int main 習題9 i...

第4周作業

百錢百雞 includeusing namespace std int main cout 該數是 4 高度 include includeusing namespace std int main cout sn 1 2 3 n 其中n為整數,n 表示計算n階乘 為 猴子摘蘋果 include in...