顯示具有 Linux 標籤的文章。 顯示所有文章
顯示具有 Linux 標籤的文章。 顯示所有文章

2018年8月30日

安裝Parity筆記

安裝rust

curl https://sh.rustup.rs -sSf | sh

安裝parity

  
git clone https://github.com/paritytech/parity-ethereum
cd parity-ethereum
git checkout stable //只安裝stable版本
cargo build --release --features final

或直接下載 binary :
https://github.com/paritytech/parity-ethereum/releases

缺少套件

  • libudev.h
yum install systemd-devel
  • cmake3:
下載cmak3 source (https://cmake.org/)
./bootstrap --prefix=/usr/local
make
make install

執行

./parity --jsonrpc-interface=w.x.y.z --jsonrpc-apis=eth,web3,personal,net,traces --jsonrpc-cors=all --chain=ropsten --jsonrpc-threads=1 --tracing=on
interface 表示要綁在哪一張網卡上

參數說明

  • --jsonrpc-interface 綁定rpc service的IP
  • --jsonrpc-apis 5 RPC支援的API
  • --jsonrpc-cors 允許CORS的網域
  • --chain 使用的ether網路名稱
  • --jsonrpc-threads RPC服務耗用CPU的資源
  • --tracing=on 開啟trace模式
  • --geth geth相容模式,讓RCP的指令可以跟geth相容一點點
  • --warp 使用snapshot方式同步最近的資料,之後有空的時候會慢慢同步前面的資料

config

  • parity也可以使用設定檔,設定檔位址在~/.local/share/io.parity.ethereum/config.toml
[parity]
mode = "active"
mode_timeout = 300
mode_alarm = 3600
auto_update = "critical"
release_track = "current"
public_node = false
no_download = false
no_consensus = false
no_persistent_txqueue = false

chain = "kovan"
base_path = "$HOME/.local/share/io.parity.ethereum"
db_path = "$HOME/.local/share/io.parity.ethereum/chains"
keys_path = "$HOME/.local/share/io.parity.ethereum/keys"
identity = ""
light = false

[rpc]
disable = false
port = 8545
interface = "w.x.y.z"
cors = ["all"]
apis = ["web3", "eth", "net", "personal", "traces"]
hosts = ["none"]
server_threads = 1

[websockets]
disable = true

[ipc]
disable = true

[footprint]
tracing = "on"

[misc]
logging = "own_tx=trace"
log_file = "/var/log/parity.log"
color = true

問題排除

  • 錯誤訊息 : TraceDB resync required
    修改~/.local/share/io.parity.ethereum/chains/test/user_defaults,把tracing改為true
  • 當啟動tracing模式的時候將無法使用warp sync

RPC 執行範例

  • Command
curl --data '{"method":"trace_filter","params":[{"fromBlock":"0x1","toBlock":"latest","fromAddress":["0x..............."]"]}],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST w.x.y.z:8545
curl -X POST --data '{"jsonrpc": "2.0", "id":"curltest", "method": "eth_getTransactionByHash", "params": ["0x..............."] }' -H 'content-type: application/json' http://w.x.y.z:8545
  • Result
{"jsonrpc":"2.0","result":[{....}],"id":1}

2018年6月13日

重設Mysql密碼(5.7 以上)

關閉mysql 服務:
sudo mysqld_safe --skip-grant-tables &
sudo /etc/init.d/mysqld stop
mysql -uroot 
登入後指令:
use mysql;          
update user set authentication_string=PASSWORD("") where User='root';
update user set plugin="mysql_native_password" where User='root';
flush privileges;
quit;
重設密碼:
mysqladmin -u root password

2016年11月26日

不需要利用ntpdate就可以校時

       網路上看到有人的Server需透過proxy才能上網,但是ntpdate不支援proxy設定;竟然想到用wget連到google去取得http response heade來作時間同步,真是有夠神。
http_proxy=http://youruser:yourpassword@proxyip:proxyport;export http_proxy
date -s "$(wget --no-cache -S -O /dev/null google.com 2>&1 | sed -n -e '/ *Date: */ {' -e s///p -e q -e '}')"
       來源網址 :

2007年5月11日

設定ssh自動登入

一般ssh都必須要輸入密碼才可以登入遠端系統主機,如果因為某些理由不想輸入密碼的話,可以利用交換密鑰來達到認證的方式:
假設現在有
  • 遠端伺服器Server A
  • 近端伺服器Server B
使用者想從ServerB連線到ServerA伺服器而不使用密碼,則可以在ServerB執行以下指令:
ssh-keygen -t rsa (指定產生的密鑰類型)
Generating public/private rsa key pair.
Enter file in which to save the key (/home/wales/.ssh/id_rsa): <<金鑰放置的地點>>
Created directory '/home/wales/.ssh'.
Enter passphrase (empty for no passphrase): <<輸入金鑰密碼,請留空白>>
Enter same passphrase again: <<再輸入一次密碼>>
Your identification has been saved in /home/wales/.ssh/id_rsa.
Your public key has been saved in /home/wales/.ssh/id_rsa.pub.
The key fingerprint is:xx:xx:xx:xx:xx:xx
之後在/home/wales/.ssh/會產生兩個檔案id_rsa及id_rsa.pub:
id_rsa.pub記載著公鑰的資訊,請將此公鑰發佈到ServerA,並儲存到/home/wales/.ssh/authorized_keys
完成設定之後,回到ServerB並執行ssh wales@serverA
The authenticity of host 'serverA' can't be established.
RSA key fingerprint is :xx:xx:xx:xx:xx:xx
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'serverA' (RSA) to the list of known hosts.
wales@serverA's password:
輸入這次密碼後 下次就不會再詢問了。
附註:在/etc/ssh/sshd_conf 底下的StrictModes要改為no,並重開sshd服務

2002年10月21日

Apache與Tomcat整合方法

  • Install mod_JK
    將mod_jk.so(http://jakarta.apache.org/tomcat/)複製到/www/modules/mod_jk.so
    如果找不到已經編譯好的檔案,請下載原始碼來編譯,方法如下:
    將下載的檔案jakarta-tomcat-connectors-jk-1.2-src-current.tar.gz放到一各暫存資料夾(/usr/local/src/)解壓縮
    cd /usr/local/src/jakarta-tomcat-connectors-jk2-2.0.2-src/jk/native
    ./buildconf.sh
    ./configure --with-apxs=/www/bin/apxs
    make ; make install
    再把產生的mod_jk.so拷貝到/www/modules/
    請注意mod_jk.so的屬性是否為可執行以及擁有人屬性應該跟執行apache的人一樣
  • 在/www/conf/下建立一個workers.properties的檔案,內容如下,基本上不需要修改內容:
    # In Unix, we use forward slashes:
    ps=/
    # list the workers by name
    worker.list=tomcat
    worker.tomcat.port=8009
    worker.tomcat.host=localhost
    worker.tomcat.type=ajp13
  • 變更檔案擁有者屬性,改成可執行apache的人chown apache.users workers.properties
  • 修改/www/conf/httpd.conf
  • 在LoadModule那一大串宣告裡加上一段
    LoadModule jk_module modules/mod_jk.so
    JkWorkersFile /www/conf/workers.properties
    JkLogFile /www/logs/mod_jk.log
    JkLogLevel info
  • 在"DocumentRoot"附近加上
    JkMount /servlets/* tomcat
    JkMount /*/servlets/* tomcat
    JkMount /*.jsq tomcat
    JkMount /*.jsp tomcat
    主要是在宣告要mount進去的目錄,例如JkMount /*.jsp表示會將Tomcat的ROOT目錄底下的所有.jsp檔案都看成跟apache的文件目錄下一樣,類似IIS的虛擬路徑。
  • 修改/www/tomcat/conf/server.xml
    尋找

    把註解取消掉
  • 啟動tomcat和apache
    /www/tomcat/bin/startup.sh
    Using CATALINA_BASE: /www/tomcat
    Using CATALINA_HOME: /www/tomcat
    Using CATALINA_TMPDIR: /www/tomcat/temp
    Using JAVA_HOME: /usr/local/jdk
    /www/bin/apachectl startssl
    httpd (pid 729) already running

精選文章

利用Selenium IDE進行UI測試

安裝與執行 Selenium IDE是Firefox的一個plugin,用來做UI的自動測試:下載網址為http://docs.seleniumhq.org/download/ 安裝後,點一下firefox 的工具 -> Selenium IDE ,就會...