鍐呯綉闆嗙兢鍑嗗悓姝hell鑴氭湰
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了鍐呯綉闆嗙兢鍑嗗悓姝hell鑴氭湰相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/cloc' title='cloc'>cloc
auth one tab The 闆嗙兢 鍚堝苟 keygen second鍦ㄥ叕鍙哥殑鍐呯綉涓厤缃泦缇ゅ悓姝ワ紝鍙兘鏄唬鐞嗛棶棰橈紝ntpd鍜宑hrony閮芥病鏈夌敤锛屾墍浠ュ彧濂藉啓shell鑴氭湰瑙e喅
鍓嶆彁鏉′欢闆嗙兢涓悇鍙版満鍣ㄥ凡缁忛厤缃ソ浜嗗厤瀵嗙櫥褰?/p>
涓€銆佸厤瀵嗙櫥褰曢厤缃?/p>
1. 鐢?root 鐢ㄦ埛鐧诲綍銆傛瘡鍙版湇鍔″櫒閮界敓鎴愬叕閽ワ紝鍐嶅悎骞跺埌 authorized_keys銆?br>2. CentOS 榛樿娌℃湁鍚姩 ssh 鏃犲瘑鐧诲綍 锛屾瘡鍙版湇鍔″櫒閮借閰嶇疆 /etc/ssh/sshd_config銆?br>vi /etc/ssh/sshd_config 淇敼
UseDNS no
PubkeyAuthentication yes
3. 姣忓彴鏈嶅姟鍣ㄤ笅閮借緭鍏ュ懡浠?ssh-keygen -t rsa锛岀敓鎴?key锛屼竴寰嬩笉杈撳叆瀵嗙爜锛岀洿鎺ュ洖杞︼紝/root 灏变細鐢熸垚 .ssh 鏂囦欢澶广€?br>4. 鍦?Master 鏈嶅姟鍣ㄤ笅锛屽悎骞跺叕閽ュ埌 authorized_keys 鏂囦欢锛岃繘鍏?/root/.ssh 鐩綍锛岄€氳繃 SSH 鍛戒护鍚堝苟.
cat id_rsa.pub>> authorized_keys
ssh [email protected] cat ~/.ssh/id_rsa.pub>> authorized_keys
ssh [email protected] cat ~/.ssh/id_rsa.pub>> authorized_keys
5. 鎶?Master 鏈嶅姟鍣ㄧ殑 authorized_keys銆乲nown_hosts 澶嶅埗鍒?Slave 鏈嶅姟鍣ㄧ殑 `/root/.ssh 鐩綍
scp authorized_keys [email protected]:/root/.ssh/
scp authorized_keys [email protected]:/root/.ssh/
scp known_hosts [email protected]:/root/.ssh/
scp known_hosts [email protected]:/root/.ssh/
浜屻€佸噯鍚屾鑴氭湰timer.sh锛屽湪master涓绘満鐨勬椂闂翠笂鍔犱簡5绉掗挓锛屽洜涓烘墽琛岃剼鏈湁鐐瑰欢杩燂紝灏嗗噯鍚屾鐨勮寖鍥寸缉灏?/p>
#!/usr/bin/env bash #hosts array hosts=("bigdata02" "bigdata03" "bigdata04" "bigdata05") #localhost current time date1=`date "+%Y/%m/%d %H:%M:%S"` date2=`date -d "$date1 5 second" +"%Y/%m/%d %H:%M:%S"` echo "Now the time is $date1" #loop host to set time for hostname in ${hosts[*]} do theDay=`date -d "$date2" +"%Y-%m-%d"` theTime=`date -d "$date2" +"%H:%M:%S"` echo $hostname ssh -t $hostname bash -c "鈥榙ate -s 鈥?theDay鈥?&&hwclock --systohc鈥? ssh -t $hostname bash -c "鈥榙ate -s 鈥?theTime鈥?&&hwclock --systohc鈥? done
涓夈€佸湪master涓婅缃畾鏃朵换鍔?/p>
閰嶇疆centos7瀹氭椂浠诲姟 姣忓皬鏃舵墽琛屼竴娆?寮€鍚畾鏃朵换鍔?systemctl start crond
systemctl enable crond.service
缂栬緫褰撳墠crontab锛岃緭鍏?crontab -e
* */1 * * * sh /home/timer.sh
以上是关于鍐呯綉闆嗙兢鍑嗗悓姝hell鑴氭湰的主要内容,如果未能解决你的问题,请参考以下文章