http://www.ithome.com.tw/news/88025
Create Your Own Private Docker Registry
$ docker run -p 5000:5000 -d registry
move docker image to disk directly
docker mysql
grep "車" Day19TestData.txt | awk {'print $2" - "$3'}
#!/bin/bashfilename='/home/cdrs/temp/ilake/nomoj.txt'
exec < $filename #執行打開檔案
while read line #讀檔案內容
do#echo ${line:0:3} 取每一行的前三個字元cd /home/cdrs/backup/response/${line:0:3}/ #移到此目錄if [ -e $line.pgp ];then #檢查此內容檔案是否存在echo $line exists >>/home/cdrs/temp/ilake/nomojcheck.txtelseecho $line does not exist >> /home/cdrs/temp/ilake/nomojcheck.txtfidone
# ll –a 查看有沒有.ssh
# mkdir .ssh 建立.ssh
#cd .ssh 進入.ssh
#ssh-keygen -t rsa 執行創建密鑰命令
#scp/home/ap/ilake/.ssh/id_rsa.pub ilake@28.192.141.129:/ilake/.ssh
#ssh-keygen
# cd /.ssh 進入到.ssh目錄 .ssh權限必须是755或者700
# cp id_rsa.pub authorized_keys 第一次添加時將公鑰重命名為authorized_keys
# chmod 644 authorized_keys 公鑰文件的權限必须是644
# cat /tmp/id_rsa.pub >> authorized_keys
# sftp ilake@ip 成功的話就可以直接登入
若只輸入sftp ip 則扔然要有密碼awk '/^01/{x="'file.'"++i;}{print > x;}' file
此指令會以01開頭的行數為依據 切割檔案sed -e '1d' file > file-temp
刪除file的第一行 存在file-tempSELECT
htx.ID, Longitude, Latitude
,acos(sin(radians(24.80181500042168)) * sin(radians(Latitude )) + cos(radians(24.80181500042168)) * cos(radians(Latitude )) * cos(radians(120.971596999978 - Longitude))) * 6372.8
as rout_distance
, 24.80181500042168 as route_lat
, 120.971596999978 as route_lon
FROM Info htx
WHERE
(Longitude BETWEEN 120.961801499978
AND 120.981392499978) and(Latitude BETWEEN 24.7928168004217
AND 24.8108132004217) order by rout_distance , Type desc , Name
說明1: 24.80181500042168 是我要查詢的中心點 LAT, 120.971596999978 是我的中心點 LON.
$ ssh-keygen -t rsa1
Generating RSA keys: Key generation complete.
Enter file in which to save the key ($HOME/.ssh/identity): [按 Enter 使用預設值(建議)]
Enter passphrase: 輸入你的 Passphrase [建議要使用 passphrase,最少 9 碼]
Enter same passphrase again: 再一次輸入你的 Passphrase
Your identification has been saved in /home/username/.ssh/identity.
Your public key has been saved in /home/username/.ssh/identity.pub.
The key fingerprint is: 6c:96:8c:a8:86:1b:3b:eb:1b:48:8d:3d:8d:c1:4f:dc username@abc.com
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa): [按 Enter 使用預設值(建議)]
Enter passphrase: 輸入你的 Passphrase
Enter same passphrase again: 再一次輸入你的 Passphrase
Your identification has been saved in /home/username/.ssh/id_rsa.
Your public key has been saved in /home/username/.ssh/id_rsa.pub.
The key fingerprint is: cc:e8:a9:da:a3:41:c6:a9:97:52:59:ef:0c:cf:45:b6 username@abc.com
$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_dsa): [按 Enter 使用預設值(建議)]
Enter passphrase: 輸入你的 Passphrase
Enter same passphrase again: 再一次輸入你的 Passphrase
Your identification has been saved in /home/username/.ssh/id_dsa.
Your public key has been saved in /home/username/.ssh/id_dsa.pub.
The key fingerprint is: cc:e8:a9:da:a3:41:c6:a9:97:52:59:ef:0c:cf:45:b6 username@abc.com
$ scp ~/.ssh/*.pub 你欲登入的主機:~/.ssh/.
$ ssh 你欲登入的主機
$ cat ~/.ssh/identity.pub >> ~/.ssh/authorized_keys
$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
$ chmod 711 ~/.ssh
$ chmod 644 ~/.ssh/authorized_keys
$ eval `ssh-agent -s`
$ ssh-add
Enter passphrase for /home/username/.ssh/id_rsa:你的 Passphrase
Identity added: /home/username/.ssh/id_rsa (/home/username/.ssh/id_rsa)
Identity added: /home/username/.ssh/id_dsa (/home/username/.ssh/id_dsa)
Identity added: /home/username/.ssh/identity (username@username.com)
SH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/lull
/usr/bin/ssh-add;
}
# Source SSH settings, if applicable
if [ -f "${SSH_ENV}" ]; then
. "${SSH_ENV}" > /dev/null
#ps ${SSH_AGENT_PID} doesn’t work under cywgin
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
start_agent;
}
else
start_agent;
fi
[root@localhost ~]# rpm -qa | grep 'rsync'step2
rsync-2.6.8-3.1
#如果沒有安裝的話 請自行補上
[root@localhost ~]# yum -y install rsync
[root@localhost ~]# vim /etc/xinetd.d/rsync service rsync{ disable = yes 改為 no socket_type = stream wait = no user = root server = /usr/bin/rsync server_args = --daemon log_on_failure += USERIDstep3
[root@localhost ~]# vim /etc/rsyncd.conf###backup config### //註解 [web] //module name comment = backup dmz web //說明 hosts allow = 192.168.1.222 //允許使用rsync連入的ip hosts deny = * //不允許連入的ip,*表示全檔 path = /home/backup/ //存放備份資料的目錄 auth users = root //認證帳號 (要設定於rsyncd.secrets 內的帳號) uid = root //用來啟動rsync server 的uid gid = root //用來啟動rsync server 的gid secrets file = /etc/rsyncd.secrets //密碼檔存放路徑 read only = no //是否設定為唯讀 dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz //不要對這些附檔名的檔案做壓縮
[root@localhost ~]# vim /etc/rsyncd.secretsroot:12345 (設定格式: 帳號:密碼)修改rsyncd.secrets使用權限 (很重要)[root@localhost ~]# chmod 600 /etc/rsyncd.secrets[root@localhost ~]# chown root.root /etc/rsyncd.secretsstep5
[root@localhost ~]# netstat -tnlp | grep 873Rsync Client
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 4235/xinetd
[root@localhost ~]# telnet localhost 873
#若出現下列訊息表示正常
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
@RSYNCD: 29
[root@localhost ~]# vim /etc/rsyncd.secrets
12345 (設定格式: 密碼)
#修改rsyncd.secrets使用權限 (很重要)
[root@localhost ~]# chmod 600 /etc/rsyncd.secrets
[root@localhost ~]# chown root.root /etc/rsyncd.secrets
[root@localhost ~]# /usr/bin/rsync -avrHS --delete --password-file=/etc/rsyncd.secrets /opt root@192.168.1.122::webstep3
#或是
[root@localhost ~]#/usr/bin/rsync -rvlHpogDtS --delete --password-file=/etc/rsyncd.secrets /opt/ root@192.168.1.122::web
#rsync結束後會看到下列訊息
sent 19380160 bytes received 1062 bytes 1685323.65 bytes/sec
total size is 19374133 speedup is 1.00
[root@localhost ~]# vim /root/bin/rsync.sh #存放在/root/bin/#!/bin/sh/usr/bin/rsync -avrHS --delete --password-file=/etc/rsyncd.secrets /opt root@192.168.1.122::web
#crontab -e 0 0 * * * /home/weithenn/rsyncweb.sh