轉載來自:https://www.nodebeginner.org/index-zh-tw.html
很好用的方法,記錄留存備用
 
function start(){
  console.log("Request handler 'start' was called.");
  function sleep(milliSeconds){
    var startTime =newDate().getTime();
    while(newDate().getTime()< startTime + milliSeconds);
  }
  sleep(10000);
  return"Hello Start";
}

Will(小威) 發表在 痞客邦 留言(0) 人氣()

最近比較大的範例都直接做一個測試專案放在雲端硬碟了,這個範例又小又常用,故此記錄一下。
import java.util.ArrayList;
import java.util.Arrays;

public class Test{

Will(小威) 發表在 痞客邦 留言(0) 人氣()

/*************** 轉換function  ***************/
// Java to JavaScript
public static String convertToJavaScriptValue(String str)
throws IOException
{
if ((str != null) && (!"".equals(str)))
{
str = replaceChar(str, '\n', "\\n");
str = replaceChar(str, '\r', "");
str = replaceChar(str, '\'', "&#039;");
str = replaceChar(str, '"', "&#034;");
}
return str;
}

Will(小威) 發表在 痞客邦 留言(0) 人氣()

 
如題,此情況常發生在把舊的server刪掉後再新增時,解法如下:
Quote:
1. Close Eclipse
2. In {workspace-directory}/.metadata/.plugins/org.eclipse.core.runtime/.settings delete the following two files:
org.eclipse.wst.server.core.prefs
org.eclipse.jst.server.tomcat.core.prefs
3. Restart Eclipse

Will(小威) 發表在 痞客邦 留言(0) 人氣()

youtube repeat 1
介紹一下原理,簡單來說就是透過javascript去做一些字串處理與網頁導向的功能,
然後再利用listenonrepeat網站實現youtube的影片自動重播,以下是步驟:
一.新增書籤:

Will(小威) 發表在 痞客邦 留言(0) 人氣()

Invalid project path: Duplicate path entries found (/Test [Include path] isSystemInclude:true includePath:C:/MinGW/include), path: [/Test]. 
對於以上error我使用以下方法解決,但不見得對所有人的情況都適用:
1.對程式所屬專案名鍵->性properties -> C/C++ Build -> Discovery Options
2.點擊界面中的Clear
3.Eclipse重開

以上感謝hccloud大大提供

Will(小威) 發表在 痞客邦 留言(0) 人氣()

[PHP]參數傳遞遇特殊字元的解決方法
傳送端
<a href ="index.php?time=<?=urlencode("2013/04/11")?>&title=<?=urlencode("北市府系統架構(伺服器、服務項目、軟體系統)")?>">請點我</a>
接收端

Will(小威) 發表在 痞客邦 留言(0) 人氣()

新增admin使用者
useradd -d /home/staff/admin -s /bin/bash -g wheel admin
visudo

Will(小威) 發表在 痞客邦 留言(0) 人氣()

ffmpeg -formats:查看ffmpeg支援的格式
D=解碼,E=編碼
ffmpeg -i (檔案名稱):查看檔案資訊,如解析度、bitrate

Will(小威) 發表在 痞客邦 留言(0) 人氣()

1.安裝Java JDK-1.6版本(自行至
http://www.oracle.com/technetwork/java/javase/downloads/index.html下載)

Will(小威) 發表在 痞客邦 留言(0) 人氣()

此文章轉貼自:http://www.zrwm.com/?p=3652
感謝Jose大大分享~~


環境說明


NFS-Server: 192.168.1.189 (Centos 6.3) 
NFS-Client: 192.168.1.193 (Centos 6.3)




NFS服務端(NFS-Server)




  • NFS-Server安裝

    [root@centos189 ~]# yum install nfs-utils portmap



  • NFS-Server配置

    創建共享目錄(設置讀寫權限):


    [root@centos189 ~]# mkdir -p /data/nfs_storage
    [root@centos189 ~]# chmod 755 /data/nfs_storage/

    導出共享目錄設置:


    [root@centos189 ~]# vi /etc/exports 
    [root@centos189 ~]# cat /etc/exports

    /data/nfs_storage 192.168.1.0/24(rw,sync,no_root_squash,no_all_squash)

    注:NFS共享目錄為:/data/nfs_storage 
    192.168.1.0/24表示192.168.1.0-192.168.1.254區間的IP都可以訪問
    rw表示允許客戶端有讀寫權限(如只允許只讀,可使用ro) 
    sync表示當有新的文件/文件夾的時候即同步共享目錄
    no_root_squash表示允許root權限(用戶可以讀/寫/刪除共享目錄中的文件) 
    no_all_squash表示允許用戶的權限




  • iptables防火牆設置

    設置nfs相關端口:


    [root@centos189 ~]# vi /etc/sysconfig/nfs 
    [root@centos189 ~]# cat /etc/sysconfig/nfs

    #

    # Define which protocol versions mountd

    # will advertise. The values​​ are "no" or "yes"

    # with yes being the default

    #MOUNTD_NFS_V2="no"

    #MOUNTD_NFS_V3="no"

    #

    #

    # Path to remote quota server. See rquotad(8)

    #RQUOTAD="/usr/sbin/rpc.rquotad"

    # Port rquotad should listen on.

    RQUOTAD_PORT=875
    # Optinal options passed to rquotad

    #RPCRQUOTADOPTS=""

    #

    #

    # Optional arguments passed to in-kernel lockd

    #LOCKDARG=

    # TCP port rpc.lockd should listen on.

    LOCKD_TCPPORT=32803
    # UDP port rpc.lockd should listen on.

    LOCKD_UDPPORT=32769
    #

    #

    # Optional arguments passed to rpc.nfsd. See rpc.nfsd(8)

    # Turn off v2 and v3 protocol support

    #RPCNFSDARGS="-N 2 -N 3"

    # Turn off v4 protocol support

    #RPCNFSDARGS="-N 4"

    # Number of nfs server processes to be started.

    # The default is 8.

    #RPCNFSDCOUNT=8

    # Stop the nfsd module from being pre-loaded

    #NFSD_MODULE="noload"

    # Set V4 grace period in seconds

    #NFSD_V4_GRACE=90

    #

    #

    #

    # Optional arguments passed to rpc.mountd. See rpc.mountd(8)

    #RPCMOUNTDOPTS=""

    # Port rpc.mountd should listen on.

    MOUNTD_PORT=892
    #

    #

    # Optional arguments passed to rpc.statd. See rpc.statd(8)

    #STATDARG=""

    # Port rpc.statd should listen on.

    STATD_PORT=662
    # Outgoing port statd should used. The default is port

    # is random

    STATD_OUTGOING_PORT=2020
    # Specify callout program

    #STATD_HA_CALLOUT="/usr/local/bin/foo"

    #

    #

    # Optional arguments passed to rpc.idmapd. See rpc.idmapd(8)

    #RPCIDMAPDARGS=""

    #

    # Set to turn on Secure NFS mounts.

    #SECURE_NFS="yes"

    # Optional arguments passed to rpc.gssd. See rpc.gssd(8)

    #RPCGSSDARGS=""

    # Optional arguments passed to rpc.svcgssd. See rpc.svcgssd(8)

    #RPCSVCGSSDARGS=""

    #

    # To enable RDMA support on the server by setting this to

    # the port the server should listen on

    #RDMA_PORT=20049

    重啟nfs:


    [root@centos189 ~]# /etc/init.d/nfs restart
    Shutting down NFS daemon: [ OK ]

    Shutting down NFS mountd: [ OK ]

    Shutting down NFS qu​​otas: [ OK ]

    Shutting down NFS services: [ OK ]

    Starting NFS services: [ OK ]

    Starting NFS qu​​otas: [ OK ]

    Starting NFS mountd: [ OK ]

    Starting NFS daemon: [ OK ]

    添加iptables規則(藍色粗體部分):


    [root@centos189 data]# vi /etc/sysconfig/iptables
    [root@centos189 data]# cat /etc/sysconfig/iptables

    # Firewall configuration written by system-config-firewall

    # Manual customization of this file is not recommended.

    *filter

    -A INPUT -m state --state NEW -m udp -p udp --dport 2049 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT

    -A INPUT -m state --state NEW -m udp -p udp --dport 111 -j ACCEPT

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 111 -j ACCEPT

    -A INPUT -m state --state NEW -m udp -p udp --dport 32769 -j ACCEPT

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 32803 -j ACCEPT

    -A INPUT -m state --state NEW -m udp -p udp --dport 892 -j ACCEPT

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 892 -j ACCEPT

    -A INPUT -m state --state NEW -m udp -p udp --dport 875 -j ACCEPT

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 875 -j ACCEPT

    -A INPUT -m state --state NEW -m udp -p udp --dport 662 -j ACCEPT

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 662 -j ACCEPT


    :INPUT ACCEPT ​​[0:0]

    :FORWARD ACCEPT ​​[0:0]

    :OUTPUT ACCEPT ​​[0:0]

    -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

    -A INPUT -p icmp -j ACCEPT

    -A INPUT -i lo -j ACCEPT

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 11300:11301 -j ACCEPT

    -A INPUT -m state --state NEW -m tcp -p tcp --dport 4730:4731 -j ACCEPT

    -A INPUT -m state --state NEW -m udp -p udp --dport 514 -j ACCEPT

    -A INPUT -m state --state NEW -m udp -p udp --dport 3999:4000 -j ACCEPT

    -A INPUT -j REJECT --reject-with icmp-host-prohibited

    -A FORWARD -j REJECT --reject-with icmp-host-prohibited

    COMMIT

    重啟iptables:


    [root@centos189 data]# service iptables restart
    iptables: Flushing firewall rules: [ OK ]

    iptables: Setting chains to policy ACCEPT: filter [ OK ]

    iptables: Unloading modules: [ OK ]

    iptables: Applying firewall rules: [ OK ]



  • NFS啟動

    [root@centos189 ~]# chkconfig portmap on
    [root@centos189 ~]# chkconfig nfs on

    [root@centos189 ~]# service portmap start

    [root@centos189 ~]# service nfs start

    Starting NFS services: [ OK ]

    Starting NFS qu​​otas: [ OK ]

    Starting NFS mountd: [ OK ]

    Starting NFS daemon: [ OK ]

    檢查配置是否成功:


    [root@centos189 ~]# exportfs
    /data/nfs_storage

    192.168.1.0/24





NFS客戶端




  • NFS-Client安裝

    [root@centos193 ~]# yum install nfs-utils portmap



  • NFS-Client啟動

    [root@centos193 ~]# chkconfig portmap on
    [root@centos193 ~]# chkconfig nfs on

    [root@centos193 ~]# service portmap start

    [root@centos193 ~]# service nfs start

    Starting NFS services: [ OK ]

    Starting NFS qu​​otas: [ OK ]

    Starting NFS mountd: [ OK ]

    Starting NFS daemon: [ OK ]



  • NFS-Client掛載共享目錄

    創建掛載點:


    [root@centos193 ~]# mkdir -p /data/nfs_shared

    查看nfs能否訪問:


    [root@centos193 ~]# showmount -e 192.168.1.189
    Export list for 192.168.1.189:

    /data/nsf_storage 192.168.1.0/24

    掛載NFS-Server的共享目錄:


    [root@centos193 ~]# mount -t nfs 192.168.1.189:/data/nfs_storage /data/nfs_shared

    查看是否掛載成功:


    [root@centos193 data]# mount
    /dev/mapper/vg_centos6-lv_root on / type ext4 (rw)

    proc on /proc type proc (rw)

    sysfs on /sys type sysfs (rw)

    devpts on /dev/pts type devpts (rw,gid=5,mode=620)

    tmpfs on /dev/shm type tmpfs (rw)

    /dev/sda1 on /boot type ext4 (rw)

    /dev/mapper/vg_centos6-lv_home on /home type ext4 (rw)

    none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

    sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
    nfsd on /proc/fs/nfsd type nfsd (rw)

    192.168.1.189:/data/nfs_storage on /data/nfs_shared type nfs (rw,vers=4,addr=192.168.1.189,clientaddr=192.168.1.193)



  • 配置開機自動掛載

    編輯/etc/fstab文件,末尾添加如下藍色字部分內容:


    [root@centos193 ~]# vi /etc/fstab 
    [root@centos193 ~]# cat /etc/fstab


    #

    # /etc/fstab

    # Created by anaconda on Fri Nov 23 20:21:40 2012

    #

    # Accessible filesystems, by reference, are maintained under '/dev/disk'

    # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

    #

    /dev/mapper/vg_centos6-lv_root / ext4 defaults 1 1

    UUID=edfaf4cd-ee8b-42c9-a45c-07339b42cc1c /boot ext4 defaults 1 2

    /dev/mapper/vg_centos6-lv_home /home ext4 defaults 1 2

    /dev/mapper/vg_centos6-lv_swap swap swap defaults 0 0

    tmpfs /dev/shm tmpfs defaults 0 0

    devpts /dev/pts devpts gid=5,mode=620 0 0

    sysfs /sys sysfs defaults 0 0

    proc /proc proc defaults 0 0


    //192.168.1.189:/data/nfs_storage /data/nfs_shared nfs rw,sync,hard,intr 0 0
    192.168.1.1:/services/Content /services/Content nfs rsize=8192,wsize=8192,timeo=14,intr







  • 測試NFS


    客戶端: 
    [root@centos193 nfs_shared]# mkdir testdir 
    [root@centos193 nfs_shared]# touch testfile1 testfile2 
    服務端: 
    [root@centos189 ~]# cd /data/nfs_storage/ 
    [root@centos189 nfs_storage]# ls 
    testdir testfile1 testfile2





Will(小威) 發表在 痞客邦 留言(0) 人氣()

一.安裝NFS server
yum install nfs-utils
二.設定NFS server
vi /etc/exports

Will(小威) 發表在 痞客邦 留言(0) 人氣()

1 2 3 4
Blog Stats
⚠️

成人內容提醒

本部落格內容僅限年滿十八歲者瀏覽。
若您未滿十八歲,請立即離開。

已滿十八歲者,亦請勿將內容提供給未成年人士。