2013年11月28日星期四

檔案大小的概念


目前最常用的容量的單位為MB,GB,TB 常用M,G,T來作為表示,

8 Bits = 1Byte
1024Byte =1k

1204KB = 1MB  (常用)
1024MB = 1GB
  (常用)
1024GB = 1TB  (常用)

1024TB = 1PB
1024PB = 1EB
1204EB = 1ZB
1024ZB = 1YB


Gmail免費給你15G的容量,單封信最大一次 可以寄25MB,





1TB 外接碟


藍光 25G


DVD 4.7G
CD 700mb

2.5吋軟碟 1.44mb

從 Evernote 傳送記事

2013年10月2日星期三

2. 架設Tomcat 6 MySql VPS CentOs 6 設定SSH及金鑰設定

From Evernote:

2. 架設Tomcat 6 MySql VPS CentOs 6 設定SSH及金鑰設定

2. 設定SSH及金鑰設定


SSH2的公鑰與私鑰的建立→ 下戴私鑰 → SSH相關配​​置文件的修改, putty 轉成 .ppk 檔。


2-1 先用申請帳號密碼登入

login as: root                                            #已root 最高權限登入

root@198.136.31.233's password:              #輸入所設定的密碼

Last login: Fri Jun 28 03:38:35 2013 from 60-249-72-68.hinet-ip.hinet.net

[root@jay ~]#                                           #已成功登入


2-2 SSH2的公鑰與私鑰的建立


[root@jay ~]# su - root                             #選擇權限 製作rootd的公鑰

[root@jay ~]# ssh-keygen -t rsa                #製作公鑰

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):        #按Enter即可

Created directory '/root/.ssh'.

Enter passphrase (empty for no passphrase):                   #按Enter即可

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:                                                      #按Enter即可

6c:85:35:6c:0b:fe:cc:2e:45:88:65:55:8b:1e:d3:6f root@jay.cnkk.org

The key's randomart image is:

+--[ RSA 2048]----+

|         o+..    |

|        +oo+ .   |

|       =.+=.o    |

|      ..oooo .   |

|        S=.   E  |

|       .  =  .   |

|         o       |

|        . .      |

|         .       |

+-----------------+             #製作完成

[root@jay ~]#


2-2 SSH2的公鑰與私鑰的建立

[root@jay ~]# cd ~/.ssh          #進入SSH配置文件的目錄

[root@jay .ssh]# ls -l              #列出文件

total 8

-rw------- 1 root root 1675 Jun 28 04:17 id_rsa                                    #確認私鑰已被建立

-rw-r--r-- 1 root root  399 Jun 28 04:17 id_rsa.pub                              #確認公鑰已被建立

[root@jay .ssh]# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys    #公鑰內容輸出到相應文件中

[root@jay .ssh]# rm -f ~/.ssh/id_rsa.pub                                          #刪除原來的公鑰文件

[root@jay .ssh]# chmod 400 ~/.ssh/authorized_keys                       #將新建立的公鑰文件屬性設置為400

[root@jay .ssh]# exit                                                                     #退出一般用戶的登錄

logout

[root@jay ~]#


2-3 下戴私鑰

將私鑰 id_rsa 下戴好保護好作為以後登入的主要依據,下一步要設定成金鑰登入方式所以要先下戴好。

下戴方法一 配合 Xshell4 與 Xftp4 下載

在目錄 /root/.ssh

下戴方法二 用FileZilla下戴

下戴id.rsa

★有時後無法出現目錄時,在遠端站台打上 /root/.ssh 即可出現


2-3 SSH相關配​​置文件的修改

用vi 文字編輯器修改文件檔

[root@jay .ssh]# vi /etc/ssh/sshd_config


#       $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm Exp $


# This is the sshd server system-wide configuration file.  See

# sshd_config(5) for more information.


# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin


# The strategy used for options in the default sshd_config shipped with

# OpenSSH is to specify options with their default value where

# possible, but leave them commented.  Uncommented options change a

# default value.


#Port 22

#AddressFamily any

#ListenAddress 0.0.0.0

#ListenAddress ::


# Disable legacy (protocol version 1) support in the server for new

# installations. In future the default will change to require explicit

# activation of protocol 1

Protocol 2


# HostKey for protocol version 1

#HostKey /etc/ssh/ssh_host_key

# HostKeys for protocol version 2

#HostKey /etc/ssh/ssh_host_rsa_key

#HostKey /etc/ssh/ssh_host_dsa_key


# Lifetime and size of ephemeral version 1 server key

#KeyRegenerationInterval 1h

#ServerKeyBits 1024        #找到這一行,將行首的「#」去掉

ServerKeyBits 1024          #修改後變為此狀態

# Logging

# obsoletes QuietMode and FascistLogging

#SyslogFacility AUTH

SyslogFacility AUTHPRIV

#LogLevel INFO


# Authentication:


#LoginGraceTime 2m

#PermitRootLogin yes        #找到這一行,將行首的「#」去掉

PermitRootLogin yes          #修改後變為此狀態 允許用root進行登錄

#StrictModes yes

#MaxAuthTries 6

#MaxSessions 10


#RSAAuthentication yes

#PubkeyAuthentication yes

#AuthorizedKeysFile .ssh/authorized_keys

#AuthorizedKeysCommand none

#AuthorizedKeysCommandRunAs nobody


# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts

#RhostsRSAAuthentication no

# similar for protocol version 2

#HostbasedAuthentication no

# Change to yes if you don't trust ~/.ssh/known_hosts for

# RhostsRSAAuthentication and HostbasedAuthentication

#IgnoreUserKnownHosts no

# Don't read the user's ~/.rhosts and ~/.shosts files

#IgnoreRhosts yes


# To disable tunneled clear text passwords, change to no here!

#PasswordAuthentication yes

#PermitEmptyPasswords no      #找到此行將行頭的「#」刪除,不允許空密碼登錄

PermitEmptyPasswords no       #修改後變為此狀態,禁止空密碼進行登:錄


PasswordAuthentication yes  #找到這一行,將yes改為no

PasswordAuthentication no    #修改後變為此狀態,不允許密碼方式的登錄


# Change to no to disable s/key passwords

#ChallengeResponseAuthentication yes

ChallengeResponseAuthentication no


# Kerberos options

#KerberosAuthentication no

#KerberosOrLocalPasswd yes

#KerberosTicketCleanup yes

#KerberosGetAFSToken no

#KerberosUseKuserok yes


# GSSAPI options

#GSSAPIAuthentication no

GSSAPIAuthentication yes

#GSSAPICleanupCredentials yes

GSSAPICleanupCredentials yes

#GSSAPIStrictAcceptorCheck yes

#GSSAPIKeyExchange no


# Set this to 'yes' to enable PAM authentication, account processing,

# and session processing. If this is enabled, PAM authentication will

# be allowed through the ChallengeResponseAuthentication and

# PasswordAuthentication.  Depending on your PAM configuration,

# PAM authentication via ChallengeResponseAuthentication may bypass

# the setting of "PermitRootLogin without-password".

# If you just want the PAM account and session checks to run without

# PAM authentication, then enable this but set PasswordAuthentication

# and ChallengeResponseAuthentication to 'no'.

#UsePAM no

UsePAM yes


# Accept locale-related environment variables

AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES

AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT

AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE

AcceptEnv XMODIFIERS


#AllowAgentForwarding yes

#AllowTcpForwarding yes

#GatewayPorts no

#X11Forwarding no

X11Forwarding no

#X11DisplayOffset 10

#X11UseLocalhost yes

#PrintMotd yes

#PrintLastLog yes

#TCPKeepAlive yes

#UseLogin no

#UsePrivilegeSeparation yes

#PermitUserEnvironment no

#Compression delayed

#ClientAliveInterval 0

#ClientAliveCountMax 3

#ShowPatchLevel no

#UseDNS yes

#PidFile /var/run/sshd.pid

#MaxStartups 10

#PermitTunnel no

#ChrootDirectory none


# no default banner path

#Banner none


# override default of no subsystems

Subsystem sftp /usr/libexec/openssh/sftp-server


# Example of overriding settings on a per-user basis

#Match User anoncvs

# X11Forwarding no

# AllowTcpForwarding no

# ForceCommand cvs server


2-4 重新啟動SSH服務

重新啟動後SSH無法以正常的密碼的方式是無法登錄SERVER,一定要用私鑰才能登入

[root@jay .ssh]# /etc/init.d/sshd restart

Stopping sshd:                                             [  OK  ]

Starting sshd:                                               [  OK  ]

[root@jay .ssh]#


2-5 透過金鑰使用SSH

方法一  Xshell4

使用Xshell最為簡單

2-5-1-1輸入VPS的IP主機

2-5-1-2輸入IP主機使用者root 並選擇 使用金鑰id_rsa

2-5-1-3連線之後直接進入主機root最高權限

方法二  putty

2-5-2-1

因為putty金鑰格式為ppk所以要先用puttygen.exe轉換

存成id_rsa.ppk後開啟putty






1. 架設Tomcat 6 MySql VPS CentOs 6 - VPS 先前準備

From Evernote:

1. 架設Tomcat 6 MySql VPS CentOs 6 - VPS 先前準備

Clipped from: http://www.acsite.net/tw/vps/linux_lowend_vps.htm
0.前言


把Tomcat架在VPS上,最大的好處就是省錢,因為在國內外的JSP虛擬主機難尋,不然就是非常的貴,一年五、六千以上。
筆者一直使用http://www.acsite.net/tw/vps/linux_lowend_vps.htm 提供PHP的服務PC值算非常的高,他們的低階VPS 一年1500非常便宜。
VPS 基本上是虛擬專屬主機 (Virtual Private Server)
簡單的說就是把一部伺服器主機分割成多個獨立的單位電腦,每個腦有如實體主機運作一樣,擁有自已的CPU、RAM、碟碟空間、IQ資源等…,
不像一般的虛擬主機,會因其它的網站流量運算過大而互相影響。基本上VPS不只可以架設JSP,也可以架PHP、VPN等等各式各樣的伺股器。
台灣用Tomcat 架在Linux VPS少有人討論,筆者參考國內外網站架並實作寫成以下的筆記。因為筆者也是初次跨入Linux VPS,如有錯誤歡迎來信。

這次筆記教學所架設環境為:
CentOS 6
JDK 1.7
Tomcat 6
MySql 5.5

內文會需要用的vi 文字編輯器:
可以參考鳥哥所寫的



第一章 筆者寫不詳盡,因原架VPS是一點點難度的,如果能自行google "xhell4"並進入主機
我想依這八個步驟架JSP server是不成問題的!

1.VPS 先前準備
2. 設定SSH及金鑰設定
3. JDK 安裝設定
4. 更改Apache2 Server port
5. 安裝Tomcat60
6. Tomcat60自動啟動
7. 安裝MySql5.5
8. Navicat 遠端登入 Mysql


1. VPS 先前準備



1-1 可以到申請VPS 筆者一開始所用的最低階的一年1500元
申請付費後大約24小內會給你開站

1-2 收到開站的信
請選CentOS 6 32位元系統(安裝系統通常不超過三分鐘)

的並取得主機ip
與自已所設的root的密碼。
最就可以開始以下的架站了

1-3 連線程式 登入主機
可以google "xhell4"
安裝後打入IP 、帳號(root)、密碼後進入主機

login as: root                                            #已root 最高權限登入

root@198.136.31.233's password:              #輸入所設定的密碼

Last login: Fri Jun 28 03:38:35 2013 from 60-249-72-68.hinet-ip.hinet.net

[root@jay ~]#                                           #已成功登入