פרק 6: הקמת נוד מלא
מבוא
בפרק זה נלמד כיצד להקים ולהגדיר נוד מלא ברשת הבלוקצ'יין שלך. נשתמש ב-Go-Ethereum (Geth) כדי להריץ נוד מלא, ונגדיר אותו כך שיפעל על שרת חי עם שם דומיין.
שלב 1: התקנת Go-Ethereum (Geth)
Go-Ethereum (Geth) הוא אחד ממימושי ה-Ethereum Client הפופולריים ביותר.
התקנה על שרת לינוקס (Ubuntu)
-
פתח את הטרמינל שלך והוסף את מאגר ה-Geth:
sudo add-apt-repository -y ppa:ethereum/ethereum sudo apt update
התקן את Geth:
sudo apt install ethereum
התקנה על מערכת Windows או macOS
ניתן להוריד את גרסאות Windows ו-macOS מהאתר הרשמי של Go-Ethereum:
שלב 2: הגדרת בלוק הג'נסיס והפעלת נוד מלא
יצירת קובץ בלוק ג'נסיס
-
צור קובץ בשם
genesis.json
בתיקיית השרת שלך והוסף את התוכן הבא:
{ "config": { "chainId": 1234, "homesteadBlock": 0, "eip155Block": 0, "eip158Block": 0, "byzantiumBlock": 0 }, "difficulty": "0x20000", "gasLimit": "0x2fefd8", "alloc": {} }
אתחל את הבלוקצ'יין שלך עם בלוק הג'נסיס:
geth init path/to/genesis.json
הפעלת הנוד המלא
- הפעל את Geth כשרת חי עם הגדרות RPC ו-WSP כדי לאפשר גישה מרחוק:
geth --networkid 1234 --http --http.addr "0.0.0.0" --http.port 8545 --http.api "eth,web3,personal,net" --ws --ws.addr "0.0.0.0" --ws.port 8546 --ws.api "eth,web3,personal,net" --ws.origins "*" --syncmode "fast"
שלב 3: הגדרת שם דומיין
כדי לגשת לנוד שלך באמצעות שם דומיין, נשתמש בשירות ניהול DNS ובתעודת SSL להצפנת התקשורת.
רכישת דומיין והגדרת DNS
- רכוש דומיין מספק שירותי דומיינים (כמו GoDaddy, Namecheap).
- הגדר רשומת A שתפנה את שם הדומיין שלך לכתובת ה-IP של השרת שלך.
התקנת Nginx והגדרת SSL
-
התקן את Nginx:
sudo apt install nginx
התקן את Certbot (להגדרת תעודות SSL חינמיות מ-Let's Encrypt):
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com
הגדר את קובץ התצורה של Nginx להפניה ל-Geth:
server { listen 80; server_name yourdomain.com; return 301 https://$host$request_uri; } server { listen 443 ssl; server_name yourdomain.com; ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem; location / { proxy_pass http://localhost:8545; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } location /ws { proxy_pass http://localhost:8546; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } }
אתחל את Nginx מחדש:
sudo systemctl restart nginx
סיכום
בפרק זה למדנו כיצד להקים ולהגדיר נוד מלא על שרת חי עם שם דומיין ותעודת SSL. התקנו את Go-Ethereum (Geth), אתחלנו את בלוק הג'נסיס, הפעלנו את הנוד והגדרנו את Nginx כדי לפנות לנוד שלנו דרך שם דומיין מוצפן.