# Stellar-core(package) ###### tags: `BlockChain` 將SDF(stellar development foundation)穩定存儲庫添加到系統 ### 下載並安裝公共簽名密鑰 wget -qO - https://apt.stellar.org/SDF.asc | sudo apt-key add - ### 將存儲庫定義保存到/etc/apt/sources.list.d/SDF.list echo "deb https://apt.stellar.org/public stable/" | sudo tee -a /etc/apt/sources.list.d/SDF.list 安裝stellar-quickstart sudo apt-get update && sudo apt-get install stellar-quickstart stellar-core-cmd info(看stelalr-core指令) 初始化stellar-core資料庫 sudo -u stellar stellar-core --conf /etc/stellar/stellar-core.cfg new-db ------ ## 個人化stellar ### 安裝stellar-core && stellar-horizon apt-get update && apt-get install stellar-core apt-get update && apt-get install stellar-horizon 啟動指令 systemctl start stellar-core systemctl start stellar-horizon ### 刪除logrotate,由於目前stellar管理日誌方式是這樣(不太了解) rm /etc/logrotate.d/stellar-core 查詢stellar數據庫並檢查分類帳標題中是否存在空白的簡單腳本。 stellar-core-gap-detect ---- ### 安裝數據庫 apt-get install stellar-core-postgres 預設為連接到testnet,若要連接到publicnet需先重置資料庫 sudo -u stellar stellar-core --conf /etc/stellar/stellar-core.cfg new-db ### 設定為full validator stellar-core gen-seed nano ~/etc/stellar/stellar-core.cfg 加入NODE_SEED="剛剛產生的seed" 加入NODE_IS_VALIDATOR=true ### 停止核心實例(只要有初始化檔案就要先停止stellar-core或是直接重新啟動) systemctl stop stellar-core ### 使用Nginx發布的本地歷史檔案 nano /etc/stellar/stellar-core.cfg [HISTORY.local] get="cp /mnt/xvdf/stellar-core-archive/node_001/{0} {1}" put="cp {0} /mnt/xvdf/stellar-core-archive/node_001/{1}" mkdir="mkdir -p /mnt/xvdf/stellar-core-archive/node_001/{0}" ### 運行new-hist創建本地存檔 sudo -u stellar stellar-core --conf /etc/stellar/stellar-core.cfg new-hist local 若出現/mnt/xvdf permission denied chmod 777 ~/mnt 查看本地存檔結構 tree -a /mnt/xvdf/stellar-core-archive/ 啟動核心實例 systemctl start stellar-core 或Amazon S3支持的歷史檔案 nano /etc/stellar/stellar-core.cfg [HISTORY.s3] get='curl -sf http://history.example.com/{0} -o {1}' # Cached HTTP endpoint put='aws s3 cp --region us-east-1 {0} s3://bucket.name/{1}' # Direct S3 access 運行new-hist創建s3存檔 sudo -u stellar stellar-core --conf /etc/stellar/stellar-core.cfg new-hist s3 ---- ### 查看完整的歷史檔 stellar-archivist scan file:///mnt/xvdf/stellar-core-archive/node_001 ### 可以發現有些資料遺失,連結到testnet去修復檔案 stellar-archivist repair http://history.stellar.org/prd/core-testnet/core_testnet_001/ file:///mnt/xvdf/stellar-core-archive/node_001/ 確認修復 stellar-archivist scan file:///mnt/xvdf/stellar-core-archive/node_001 在這就要重新啟動 systemctl stellar-core start