{"id":17909921,"url":"https://github.com/mvines/sosh","last_synced_at":"2025-03-23T20:31:55.382Z","repository":{"id":62166877,"uuid":"529628871","full_name":"mvines/sosh","owner":"mvines","description":"Solana validator operations shell scripts","archived":false,"fork":false,"pushed_at":"2025-02-04T04:56:50.000Z","size":63,"stargazers_count":28,"open_issues_count":0,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T23:52:02.410Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mvines.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-27T15:49:28.000Z","updated_at":"2025-03-18T07:54:31.000Z","dependencies_parsed_at":"2024-04-27T01:36:30.681Z","dependency_job_id":"a81c7b4f-49a1-424d-90cd-d8c0d03a123f","html_url":"https://github.com/mvines/sosh","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvines%2Fsosh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvines%2Fsosh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvines%2Fsosh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvines%2Fsosh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mvines","download_url":"https://codeload.github.com/mvines/sosh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245165146,"owners_count":20571251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-28T19:28:37.415Z","updated_at":"2025-03-23T20:31:55.090Z","avatar_url":"https://github.com/mvines.png","language":"Shell","funding_links":[],"categories":["Validator Tools and Resources"],"sub_categories":["Notes"],"readme":"# Solana Validator Shell Scripts\n\nThis project contains useful scripts for easily running a Solana validator on a fresh Ubuntu 20.04 machine. It uses my ([mvines](https://github.com/mvines)) preferred Solana mainnet settings and best practices. The command names are slightly quirky, and currently not too well documented\n\n## Approximate Clean Machine Setup\n\n### Rust\n```\ncurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\n```\n\n### Solana Cli\n```\nsh -c \"$(curl -sSfL https://release.anza.xyz/beta/install)\"\n```\n\nthen restart shell to apply new PATH\n\n### Tuning\nView all `journalctl -f` with:\n```\nsudo adduser sol adm\nsudo adduser sol sudo\n```\n\n```\nsudo bash -c \"cat \u003e/etc/sysctl.d/20-solana.conf \u003c\u003cEOF\n# Increase UDP buffer size\nnet.core.rmem_default = 134217728\nnet.core.rmem_max = 134217728\nnet.core.wmem_default = 134217728\nnet.core.wmem_max = 134217728\n\n# Increase memory mapped files limit\nvm.max_map_count = 2000000\nEOF\" \u0026\u0026 \\\nsudo sysctl -p /etc/sysctl.d/20-solana.conf\n```\n\n```\nsudo bash -c \"cat \u003e/etc/security/limits.d/90-solana-nofiles.conf \u003c\u003cEOF\n# Increase process file descriptor count limit\n* - nofile 2000000\nEOF\"\n```\n\n```\nsudo bash -c \"cat \u003e/etc/logrotate.d/sol \u003c\u003cEOF\n$HOME/solana-validator.log {\n  rotate 3\n  daily\n  missingok\n  postrotate\n    systemctl kill -s USR1 sol.service\n  endscript\n}\nEOF\"\n```\n\n### Packages\n```\nsudo apt-get update\nsudo apt-get install -y git htop silversearcher-ag iotop \\\n  libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang \\\n  cmake make libprotobuf-dev protobuf-compiler nvme-cli\n```\n\n### SSH keygen\n```\nssh-keygen -t ed25519 \u0026\u0026 cat .ssh/id_ed25519.pub\n```\n\n### Solana Git Setup\n```\nfor ch in edge beta stable; do \\\n  git clone https://github.com/solana-labs/solana.git ~/$ch; \\\ndone; \\\n(cd ~/beta; git checkout v1.14); \\\n(cd ~/stable; git checkout v1.13); \\\nln -sf beta ~/solana\n```\n\n### Sosh\n```\ngit clone https://github.com/mvines/sosh ~/sosh\n```\n\nthen add to your bash config:\n```\necho '[ -f $HOME/sosh/sosh.bashrc ] \u0026\u0026 source $HOME/sosh/sosh.bashrc' \u003e\u003e ~/.bashrc\necho '[ -f $HOME/sosh/sosh.profile ] \u0026\u0026 source $HOME/sosh/sosh.profile' \u003e\u003e ~/.profile\n```\n\nthen restart shell\n\n### Sosh Configuration\n\nIf you wish to customize the Sosh configuration\n```\ncat \u003e ~/sosh-config.sh \u003c\u003cEOF\n# Start with upstream defaults\nsource ~/sosh/sosh-config-default.sh\n\n# Local config overrides go here\nEOF\n```\nand adjust as desired\n\n### Build your validator binaries\n\nPick the \"beta\" tree with:\n```\np beta\n```\nor perhaps \"stable\":\n```\np stable\n```\nor even \"edge\":\n```\np edge\n```\n\n### Validator keypairs\n\n#### Primary\nThe primary keypair is what your staked node uses by default.\n\n```\nmkdir -p ~/keys/primary\n```\nthen either copy your existing `validator-identity.json` and\n`validator-vote-account.json` into that directory or create new ones with\n```\nsolana-keygen new -o ~/keys/primary/validator-identity.json --no-bip39-passphrase -s \u0026\u0026 \\\n  solana-keygen new -o ~/keys/primary/validator-vote-account.json --no-bip39-passphrase -s\n```\n\nIf you wish to activate the primary keypair,\n```\nsosh-set-config primary\n```\n\n#### Secondary\nSecondary keypairs are host-specific and used by hot spare machines that can be switched over to\nprimary at runtime. Once your primary keypair is configured, run\n\n```\nmkdir -p ~/keys/secondary \u0026\u0026 \\\n  solana-keygen new -o ~/keys/secondary/validator-identity.json --no-bip39-passphrase -s\n```\n\nIf you wish to activate the secondary keypair,\n```\nsosh-set-config secondary\n```\n\nLater run `xferid \u003csecondary-host\u003e` from your primary to transfer voting to the\nsecondary.\n\n#### Other keypairs...\n\nAny string other than `primary` and `secondary` may be used to configure other keypairs for dev and testing.\nFor example to configure a `dev` keypair:\n\n```\nmkdir -p ~/keys/dev \u0026\u0026 \\\n  solana-keygen new -o ~/keys/dev/validator-identity.json --no-bip39-passphrase -s \u0026\u0026 \\\n  solana-keygen new -o ~/keys/dev/validator-vote-account.json --no-bip39-passphrase -s\n```\n\nIf you wish to activate the dev keypair,\n```\nsosh-set-config dev\n```\n\n#### Maybe Adjust FileSystem Usage\n\n##### rocksdb filesystem\n\nAssuming `/mnt/ledger-rocksdb` is the desired location for rocksdb, such as a\nseparate nvme:\n```\nmkdir -p ~/ledger/\nln -sf /mnt/ledger-rocksdb/level ~/ledger/rocksdb\nln -sf /mnt/ledger-rocksdb/fifo ~/ledger/rocksdb_fifo\n```\n\n##### accounts filesystem(s)\n\nIf present the `/mnt/accounts1`, `/mnt/accounts2`, and `/mnt/accounts3`\nlocations will be added as an `--account` arg to validator startup.\n\nIf none are present, accounts will be placed in the default location of\n`~/ledger/accounts`\n\nExample of accounts evenly disributed across two drives:\n```\nsudo ln -s /mnt/nvme1 /mnt/account1\nsudo ln -s /mnt/nvme2 /mnt/account2\n```\n\n##### snapshot filesystems\n\nIf not present, snapshots will be placed in the default location of `~/ledger`\n\nExample of putting all snapshots in a seperate drive:\n```\nsudo ln -s /mnt/nvme3 /mnt/snapshots\n```\n\nExample of putting incremental snapshots in a separate drive, full snapshots in default\nlocation:\n```\nsudo ln -s /mnt/nvme4 /mnt/incremental-snapshots\n```\n\n### Start the node manually to initialize the ledger\n```\nvalidator.sh init\n```\nthen monitor logs with `t`. This will prepare ~/ledger and download the correct\ngenesis config for the cluster.\n\n### Fetch a current snapshot\n\nUse `fetch_snapshot.sh` to get a snapshot from a specific node.\n\n* Mainnet NA-based nodes, try `fetch_snapshot.sh bv1` or `fetch_snapshot.sh bv2`.\n* Mainnet EU-based nodes, try `fetch_snapshot.sh bv3`\n* Mainnet Asia-based nodes, try `fetch_snapshot.sh bv4`\n* Testnet, try `fetch_snapshot.sh tv`\n\n\n### Start the sol service\n\n```\nsudo bash -c \"cat \u003e/etc/systemd/system/sol.service \u003c\u003cEOF\n[Unit]\nDescription=Solana Validator\nAfter=network.target\nStartLimitIntervalSec=0\nWants=sol-hc.service\n\n[Service]\nType=simple\nRestart=always\nRestartSec=1\nUser=$USER\nLimitNOFILE=2000000\nLogRateLimitIntervalSec=0\nExecStart=$HOME/sosh/bin/validator.sh\n\n[Install]\nWantedBy=multi-user.target\nEOF\" \u0026\u0026\n\nsudo bash -c \"cat \u003e/etc/systemd/system/sol-hc.service \u003c\u003cEOF\n[Unit]\nDescription=Solana Validator Healthcheck\nAfter=network.target\nStartLimitIntervalSec=0\n\n[Service]\nType=simple\nRestart=always\nRestartSec=1\nUser=$USER\nExecStart=$HOME/sosh/bin/hc-service.sh\n\n[Install]\nWantedBy=multi-user.target\nEOF\" \u0026\u0026 sudo systemctl daemon-reload\n```\n\nthen run:\n```\nsoshr          # Sosh alias for `sudo systemctl restart sol sol-hc`\n```\nand monitor with:\n```\njf            # Sosh alias for `journalctl -f`\n```\nand\n```\nt\n```\n\n### Stop the sol service\n\n```\nsoshs\n````\n\n### Clean sol service restart\n\n```\nsvem   # Alias for `solana-validator exit --monitor`\n```\n\n### Update validator binaries\n\nTo fetch the latest commits for your current source tree:\n```\np\n```\n\nthen use `svem` to restart the sol service\n\n\nSyncing to a specific tag, rather than HEAD of your current source tree, is a\nlittle clumsy currently with a \"p \u003ctreename\u003e \u003ctagname\u003e\":\n```\np beta v1.13.5\n```\n\n### Revert to previous validator binaries\nSo you updated your validator binaries and something bad happened. Quickly\nrevert to the previous binaries with:\n```\nlkg\n```\nthen use `svem` to restart the sol service\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvines%2Fsosh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmvines%2Fsosh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvines%2Fsosh/lists"}