|
| 1 | +# Standalone noobaa-core |
| 2 | + |
| 3 | +Running noobaa-core standalone is useful for development, testing, or deploying in linux without depending on kubernetes, but requires some steps which are described next. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## BUILD |
| 8 | + |
| 9 | +### 1. Build Prerequisites |
| 10 | + |
| 11 | +In general, the build prereqs for Linux are maintained in the builder container image - see [builder.Dockerfile](https://github.com/noobaa/noobaa-core/blob/master/src/deploy/NVA_build/builder.Dockerfile) |
| 12 | + |
| 13 | +- [nodejs](https://nodejs.org) |
| 14 | + - `node --version` should match the version in [cat .nvmrc](https://github.com/noobaa/noobaa-core/blob/master/.nvmrc) |
| 15 | + - consider using `src/deploy/NVA_build/install_nodejs.sh $(cat .nvmrc)` [see](https://github.com/noobaa/noobaa-core/blob/master/src/deploy/NVA_build/install_nodejs.sh) |
| 16 | +- [node-gyp](https://github.com/nodejs/node-gyp) prereqs |
| 17 | + - On [Linux](https://github.com/nodejs/node-gyp#on-unix) - python3, make, gcc (e.g `dnf group install "Development Tools"`) |
| 18 | + - On [MacOS](https://github.com/nodejs/node-gyp#on-macos) - python3, make, clang (from `XCode Command Line Tools`) |
| 19 | +- assembler |
| 20 | + - nasm on Linux - build from source [nasm-2.15.05.tar.gz](https://github.com/netwide-assembler/nasm/archive/nasm-2.15.05.tar.gz) (match the version and steps in latest `builder.Dockerfile`). |
| 21 | + - yasm on MacOS - `brew install yasm` |
| 22 | + |
| 23 | +### 2. Build from source |
| 24 | + |
| 25 | +```sh |
| 26 | +git clone https://github.com/noobaa/noobaa-core |
| 27 | +cd noobaa-core |
| 28 | +npm install |
| 29 | +npm run build |
| 30 | +npm run pkg # optional create a single-executable build/noobaa-core |
| 31 | +``` |
| 32 | + |
| 33 | +### 3. Quick test |
| 34 | + |
| 35 | +This tool invokes key functions (e.g erasure coding), and should be able to run to completion without failures: |
| 36 | + |
| 37 | +```sh |
| 38 | +node src/tools/coding_speed.js --ec --md5 --encode --erase --decode --size 2000 |
| 39 | +``` |
| 40 | + |
| 41 | +--- |
| 42 | + |
| 43 | +## DATABASE |
| 44 | + |
| 45 | +Currently noobaa uses postgres 12 from the docker image `centos/postgresql-12-centos7`. |
| 46 | +- On Linux - `dnf install postgresql12 postgresql12-server` (might require yum repos) |
| 47 | +- On MacOS - `brew install postgresql@12` |
| 48 | + |
| 49 | +### 1. Init database directory |
| 50 | + |
| 51 | +```sh |
| 52 | +npm run db:init |
| 53 | +``` |
| 54 | + |
| 55 | +### 2. Run foreground database |
| 56 | + |
| 57 | +```sh |
| 58 | +npm run db |
| 59 | +``` |
| 60 | + |
| 61 | +### 3. Create database, user, and permissions |
| 62 | + |
| 63 | +```sh |
| 64 | +npm run db:create |
| 65 | +``` |
| 66 | + |
| 67 | +### 4. Test connection |
| 68 | + |
| 69 | +```sh |
| 70 | +echo '\l+ nbcore' | npm run db:connect |
| 71 | +``` |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## SERVICES |
| 76 | + |
| 77 | +### 1. Environment |
| 78 | + |
| 79 | +```sh |
| 80 | +cat >.env <<EOF |
| 81 | +CREATE_SYS_NAME=noobaa |
| 82 | + |
| 83 | +CREATE_SYS_PASSWD=123456789 |
| 84 | +JWT_SECRET=123456789 |
| 85 | +NOOBAA_ROOT_SECRET='AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=' |
| 86 | +LOCAL_MD_SERVER=true |
| 87 | +EOF |
| 88 | +``` |
| 89 | + |
| 90 | +```sh |
| 91 | +cat >config-local.js <<EOF |
| 92 | +/* Copyright (C) 2023 NooBaa */ |
| 93 | +'use strict'; |
| 94 | +
|
| 95 | +/** @type {import('./config')} */ |
| 96 | +const config = exports; |
| 97 | +
|
| 98 | +config.AGENT_RPC_PORT = '9999'; |
| 99 | +config.AGENT_RPC_PROTOCOL = 'tcp'; |
| 100 | +
|
| 101 | +config.BLOCK_STORE_FS_TIER2_ENABLED = true; |
| 102 | +config.BLOCK_STORE_FS_MAPPING_INFO_ENABLED = true; |
| 103 | +
|
| 104 | +config.DEDUP_ENABLED = false; |
| 105 | +config.IO_CALC_MD5_ENABLED = false; |
| 106 | +config.IO_CALC_SHA256_ENABLED = false; |
| 107 | +
|
| 108 | +config.MAX_OBJECT_PART_SIZE = 1024 * 1024 * 1024; |
| 109 | +config.IO_CHUNK_READ_CACHE_SIZE = 4 * 1024 * 1024 * 1024; |
| 110 | +config.CHUNK_SPLIT_AVG_CHUNK = 256 * 1024 * 1024; |
| 111 | +config.CHUNK_SPLIT_DELTA_CHUNK = 0; |
| 112 | +
|
| 113 | +config.CHUNK_CODER_DIGEST_TYPE = 'none'; |
| 114 | +config.CHUNK_CODER_FRAG_DIGEST_TYPE = 'none'; |
| 115 | +config.CHUNK_CODER_COMPRESS_TYPE = 'none'; |
| 116 | +config.CHUNK_CODER_CIPHER_TYPE = 'none'; |
| 117 | +
|
| 118 | +config.CHUNK_CODER_REPLICAS = 1; |
| 119 | +config.CHUNK_CODER_EC_DATA_FRAGS = 2; |
| 120 | +config.CHUNK_CODER_EC_PARITY_FRAGS = 2; |
| 121 | +config.CHUNK_CODER_EC_PARITY_TYPE = 'isa-c1'; |
| 122 | +config.CHUNK_CODER_EC_TOLERANCE_THRESHOLD = 2; |
| 123 | +config.CHUNK_CODER_EC_IS_DEFAULT = true; |
| 124 | +
|
| 125 | +// bg workers |
| 126 | +config.SCRUBBER_ENABLED = false; |
| 127 | +config.REBUILD_NODE_ENABLED = false; |
| 128 | +config.AWS_METERING_ENABLED = false; |
| 129 | +config.AGENT_BLOCKS_VERIFIER_ENABLED = false; |
| 130 | +EOF |
| 131 | +``` |
| 132 | + |
| 133 | +### 2. Run core services |
| 134 | + |
| 135 | +These services should run once alongside the database: |
| 136 | + |
| 137 | +```sh |
| 138 | +npm run web |
| 139 | +npm run bg |
| 140 | +``` |
| 141 | + |
| 142 | +Hosted agents is a special service needed only for cloud pools: |
| 143 | + |
| 144 | +```sh |
| 145 | +npm run hosted_agents |
| 146 | +``` |
| 147 | + |
| 148 | +### 2. Run endpoints |
| 149 | + |
| 150 | +Running a local endpoint alongside the database and other services is simple: |
| 151 | + |
| 152 | +```sh |
| 153 | +npm run s3 |
| 154 | +``` |
| 155 | + |
| 156 | +In order to enable multiple forks of the endpoint serving on the same port use: |
| 157 | + |
| 158 | +```sh |
| 159 | +ENDPOINT_FORKS=4 npm run s3 |
| 160 | +``` |
| 161 | + |
| 162 | +For remote hosts, need to specify the addresses: |
| 163 | + |
| 164 | +```sh |
| 165 | +POSTGRES_HOST=ip \ |
| 166 | + MGMT_ADDR=wss://ip:5443 \ |
| 167 | + BG_ADDR=wss://ip:5445 \ |
| 168 | + HOSTED_AGENTS_ADDR=wss://ip:5446 \ |
| 169 | + npm run s3 |
| 170 | +``` |
| 171 | + |
| 172 | +--- |
| 173 | + |
| 174 | +## STORAGE |
| 175 | + |
| 176 | +### Start backingstores |
| 177 | + |
| 178 | +```sh |
| 179 | +for i in 1 2 3 4; do mkdir -p storage/backingstores/drive${i}; done |
| 180 | +npm run backingstore -- storage/backingstores/drive1 --port 9991 |
| 181 | +npm run backingstore -- storage/backingstores/drive2 --port 9992 |
| 182 | +npm run backingstore -- storage/backingstores/drive3 --port 9993 |
| 183 | +npm run backingstore -- storage/backingstores/drive4 --port 9994 |
| 184 | +``` |
| 185 | + |
| 186 | +### Check storage status |
| 187 | + |
| 188 | +```sh |
| 189 | +npm run api -- node sync_monitor_to_store |
| 190 | +npm run api -- node aggregate_nodes '{}' |
| 191 | +``` |
| 192 | + |
| 193 | +### Check local storage |
| 194 | + |
| 195 | +```sh |
| 196 | +du -sh storage/backingstores |
| 197 | +find storage/backingstores -name '*.data' -type f -ls |
| 198 | +``` |
| 199 | + |
| 200 | +--- |
| 201 | + |
| 202 | +## S3 API |
| 203 | + |
| 204 | +### Get access and secret keys |
| 205 | + |
| 206 | +```sh |
| 207 | +export AWS_ACCESS_KEY_ID=$(npm run api -- account read_account '{}' --json | jq -r '.access_keys[0].access_key') |
| 208 | +export AWS_SECRET_ACCESS_KEY=$(npm run api -- account read_account '{}' --json | jq -r '.access_keys[0].secret_key') |
| 209 | +``` |
| 210 | + |
| 211 | +### Listing |
| 212 | + |
| 213 | +```sh |
| 214 | +node src/tools/s3cat --endpoint http://localhost:6001 |
| 215 | +node src/tools/s3cat --endpoint http://localhost:6001 --bucket first.bucket --ls |
| 216 | +aws --endpoint http://localhost:6001 s3 ls |
| 217 | +aws --endpoint http://localhost:6001 s3 ls s3://first.bucket |
| 218 | +``` |
| 219 | + |
| 220 | +### Create bucket |
| 221 | + |
| 222 | +```sh |
| 223 | +aws --endpoint http://localhost:6001 s3 mb s3://lala |
| 224 | +``` |
| 225 | + |
| 226 | +### Read/Write |
| 227 | + |
| 228 | +```sh |
| 229 | +node src/tools/s3cat --endpoint http://localhost:6001 --sig s3 --bucket first.bucket --put ggg --size 4096 |
| 230 | +node src/tools/s3cat --endpoint http://localhost:6001 --sig s3 --bucket first.bucket --get ggg |
| 231 | +dd if=/dev/zero bs=1M count=1024 | aws --endpoint http://localhost:6001 s3 cp - s3://first.bucket/ggg |
| 232 | +aws --endpoint http://localhost:6001 s3 cp s3://first.bucket/ggg - | xxd -a |
| 233 | +aws --endpoint http://localhost:6001 s3 rm s3://first.bucket/ggg |
| 234 | +``` |
| 235 | + |
| 236 | +## Multipart uploads |
| 237 | + |
| 238 | +```sh |
| 239 | +node src/tools/s3cat --endpoint http://localhost:6001 --sig s3 --bucket first.bucket --upload ggg --size 4096 --part_size 1024 --concur 4 |
| 240 | +``` |
| 241 | + |
| 242 | +### Perf tools |
| 243 | + |
| 244 | +```sh |
| 245 | +node src/tools/s3perf --endpoint http://localhost:6001 --sig s3 --bucket first.bucket --put s3perf/ --concur 4 --size 128 --size_units MB --time 5 |
| 246 | +node src/tools/s3perf --endpoint http://localhost:6001 --sig s3 --bucket first.bucket --get s3perf/ --concur 4 --size 128 --size_units MB --time 5 |
| 247 | +``` |
| 248 | + |
| 249 | +### Using sigv4 for streaming requires https endpoint 6443 (selfsigned) |
| 250 | + |
| 251 | +```sh |
| 252 | +node src/tools/s3cat --endpoint https://localhost:6443 --selfsigned --bucket first.bucket --put ggg --size 4096 |
| 253 | +node src/tools/s3cat --endpoint https://localhost:6443 --selfsigned --bucket first.bucket --upload ggg --size 4096 --part_size 1024 --concur 4 |
| 254 | +``` |
0 commit comments