diff --git a/.gitignore b/.gitignore index 8513695b..9b826609 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,6 @@ rustfs/static/* vendor cli/rustfs-gui/embedded-rustfs/rustfs -config/obs.toml +deploy/config/obs.toml *.log -config/certs/* +deploy/certs/* diff --git a/deploy/README.md b/deploy/README.md new file mode 100644 index 00000000..4d3d4476 --- /dev/null +++ b/deploy/README.md @@ -0,0 +1,35 @@ +# RustFS Deploy + +This directory contains the deployment scripts and configurations for the project. +The deployment process is divided into two main parts: the RustFS binary and the RustFS console. The RustFS binary is +responsible for the core functionality of the system, while the RustFS console provides a web-based interface for +managing and monitoring the system. + +# Directory Structure + +```text +|--data // data directory +| |--vol1 // volume 1 not created +| |--vol2 // volume 2 not created +| |--vol3 // volume 3 not created +| |--vol4 // volume 4 not created +| |--README.md // data directory readme +|--logs // log directory +| |--rustfs.log // RustFS log +| |--README.md // logs directory readme +|--build +| |--rustfs.run.md // deployment script for RustFS +| |--rustfs.run-zh.md // deployment script for RustFS in Chinese +| |--rustfs.service // systemd service file +| |--rustfs-zh.service.md // systemd service file in Chinese +|--certs +| |--README.md // certs readme +| |--rustfs_tls_cert.pem // API cert.pem +| |--rustfs_tls_key.pem // API key.pem +| |--rustfs_console_tls_cert.pem // console cert.pem +| |--rustfs_console_tls_key.pem // console key.pem +|--config +| |--obs.example.yaml // example config +| |--rustfs.env // env config +| |--rustfs-zh.env // env config in Chinese +``` \ No newline at end of file diff --git a/rustfs-zh.service b/deploy/build/rustfs-zh.service similarity index 95% rename from rustfs-zh.service rename to deploy/build/rustfs-zh.service index 2541ec77..a2bc1a41 100644 --- a/rustfs-zh.service +++ b/deploy/build/rustfs-zh.service @@ -24,20 +24,15 @@ User=rustfs Group=rustfs # 以 rustfs 组身份运行服务,与 User 配合使用。 -# environment variable configuration -# 定义环境变量配置,用于传递给服务程序。 -Environment=RUST_LOG=info -# 设置日志级别为 info,控制服务日志输出(需服务支持此变量)。 -Environment=RUSTFS_ACCESS_KEY=rustfsadmin -# 设置访问密钥为 rustfsadmin,用于 RustFS 的认证。 -Environment=RUSTFS_SECRET_KEY=rustfsadmin -# 设置秘密密钥为 rustfsadmin,与访问密钥配套使用。 - # working directory WorkingDirectory=/opt/rustfs # 设置服务的工作目录为 /opt/rustfs,影响相对路径的解析。 -# main program +# 定义环境变量配置,用于传递给服务程序。 +Environment=RUSTFS_ACCESS_KEY=rustfsadmin +# 设置访问密钥为 rustfsadmin,用于 RustFS 的认证。 +Environment=RUSTFS_SECRET_KEY=rustfsadmin +# 设置秘密密钥为 rustfsadmin,与访问密钥配套使用。 ExecStart=/usr/local/bin/rustfs \ --address 0.0.0.0:9000 \ --volumes /data/rustfs/vol1,/data/rustfs/vol2 \ @@ -51,6 +46,10 @@ ExecStart=/usr/local/bin/rustfs \ # --console-enable:启用控制台功能。 # --console-address 0.0.0.0:9002:控制台监听所有接口的 9002 端口。 +# 定义环境变量配置,用于传递给服务程序,推荐使用且简洁 +EnvironmentFile=-/etc/default/rustfs +ExecStart=/usr/local/bin/rustfs $RUSTFS_VOLUMES $RUSTFS_OPTS + # resource constraints LimitNOFILE=1048576 # 设置文件描述符上限为 1048576,支持高并发连接。 diff --git a/rustfs.run-zh.md b/deploy/build/rustfs.run-zh.md similarity index 100% rename from rustfs.run-zh.md rename to deploy/build/rustfs.run-zh.md diff --git a/rustfs.run.md b/deploy/build/rustfs.run.md similarity index 100% rename from rustfs.run.md rename to deploy/build/rustfs.run.md diff --git a/rustfs.service b/deploy/build/rustfs.service similarity index 80% rename from rustfs.service rename to deploy/build/rustfs.service index 53db8a64..e8c82de4 100644 --- a/rustfs.service +++ b/deploy/build/rustfs.service @@ -13,15 +13,12 @@ NotifyAccess=main User=rustfs Group=rustfs -# environment variable configuration -Environment=RUST_LOG=info -Environment=RUSTFS_ACCESS_KEY=rustfsadmin -Environment=RUSTFS_SECRET_KEY=rustfsadmin - # working directory WorkingDirectory=/opt/rustfs -# main program +# environment variable configuration and main program (Option 1: Directly specify arguments) +Environment=RUSTFS_ACCESS_KEY=rustfsadmin +Environment=RUSTFS_SECRET_KEY=rustfsadmin ExecStart=/usr/local/bin/rustfs \ --address 0.0.0.0:9000 \ --volumes /data/rustfs/vol1,/data/rustfs/vol2 \ @@ -29,6 +26,10 @@ ExecStart=/usr/local/bin/rustfs \ --console-enable \ --console-address 0.0.0.0:9002 +# environment variable configuration (Option 2: Use environment variables) +EnvironmentFile=-/etc/default/rustfs +ExecStart=/usr/local/bin/rustfs $RUSTFS_VOLUMES $RUSTFS_OPTS + # resource constraints LimitNOFILE=1048576 LimitNPROC=32768 diff --git a/config/certs/README.md b/deploy/certs/README.md similarity index 100% rename from config/certs/README.md rename to deploy/certs/README.md diff --git a/deploy/config/obs-zh.example.toml b/deploy/config/obs-zh.example.toml new file mode 100644 index 00000000..c3cbe8f6 --- /dev/null +++ b/deploy/config/obs-zh.example.toml @@ -0,0 +1,33 @@ +[observability] +endpoint = "http://localhost:4317" # 可观测性数据上报的终端地址,默认为"http://localhost:4317" +use_stdout = true # 是否将日志输出到标准输出 +sample_ratio = 2.0 # 采样率,表示每 2 条数据采样 1 条 +meter_interval = 30 # 指标收集间隔,单位为秒 +service_name = "rustfs" # 服务名称,用于标识当前服务 +service_version = "0.1.0" # 服务版本号 +environments = "develop" # 运行环境,如开发环境 (develop) +logger_level = "debug" # 日志级别,可选 debug/info/warn/error 等 + +[sinks] +[sinks.kafka] # Kafka 接收器配置 +enabled = false # 是否启用 Kafka 接收器,默认禁用 +bootstrap_servers = "localhost:9092" # Kafka 服务器地址 +topic = "logs" # Kafka 主题名称 +batch_size = 100 # 批处理大小,每次发送的消息数量 +batch_timeout_ms = 1000 # 批处理超时时间,单位为毫秒 + +[sinks.webhook] # Webhook 接收器配置 +enabled = false # 是否启用 Webhook 接收器 +endpoint = "http://localhost:8080/webhook" # Webhook 接收地址 +auth_token = "" # 认证令牌 +batch_size = 100 # 批处理大小 +batch_timeout_ms = 1000 # 批处理超时时间,单位为毫秒 + +[sinks.file] # 文件接收器配置 +enabled = true # 是否启用文件接收器 +path = "/Users/qun/Documents/rust/rustfs/s3-rustfs/logs/app.log" # 日志文件路径 +batch_size = 10 # 批处理大小 +batch_timeout_ms = 1000 # 批处理超时时间,单位为毫秒 + +[logger] # 日志器配置 +queue_capacity = 10 # 日志队列容量,表示可以缓存的日志条数 \ No newline at end of file diff --git a/config/obs.example.toml b/deploy/config/obs.example.toml similarity index 100% rename from config/obs.example.toml rename to deploy/config/obs.example.toml diff --git a/deploy/config/rustfs-zh.env b/deploy/config/rustfs-zh.env new file mode 100644 index 00000000..b9700adb --- /dev/null +++ b/deploy/config/rustfs-zh.env @@ -0,0 +1,26 @@ +# RustFS 管理员用户名 +RUSTFS_ROOT_USER=rustfsadmin +# RustFS 管理员密码 +RUSTFS_ROOT_PASSWORD=rustfsadmin + +# 数据卷配置示例路径:deploy/data/rustfs.env +# RustFS 数据卷存储路径,支持多卷配置,vol1 到 vol4 +RUSTFS_VOLUMES="./deploy/deploy/vol{1...4}" +# RustFS 服务启动参数,指定监听地址和端口 +RUSTFS_OPTS="--address 0.0.0.0:9000" +# RustFS 服务监听地址和端口 +RUSTFS_ADDRESS="0.0.0.0:9000" +# 是否启用 RustFS 控制台功能 +RUSTFS_CONSOLE_ENABLE=true +# RustFS 控制台监听地址和端口 +RUSTFS_CONSOLE_ADDRESS="0.0.0.0:9002" +# RustFS 服务端点地址,用于客户端访问 +RUSTFS_SERVER_ENDPOINT="http://127.0.0.1:9000" +# RustFS 服务域名配置 +RUSTFS_SERVER_DOMAINS=127.0.0.1:9002 +# RustFS 许可证内容 +RUSTFS_LICENSE="license content" +# 可观测性配置文件路径:deploy/config/obs.example.toml +RUSTFS_OBS_CONFIG=/etc/default/obs.toml +# TLS 证书目录路径:deploy/certs +RUSTFS_TLS_PATH=/etc/default/tls \ No newline at end of file diff --git a/deploy/config/rustfs.env b/deploy/config/rustfs.env new file mode 100644 index 00000000..ec7d31b4 --- /dev/null +++ b/deploy/config/rustfs.env @@ -0,0 +1,26 @@ +# RustFS administrator username +RUSTFS_ROOT_USER=rustfsadmin +# RustFS administrator password +RUSTFS_ROOT_PASSWORD=rustfsadmin + +# Data volume configuration example path: deploy/data/rustfs.env +# RustFS data volume storage paths, supports multiple volumes from vol1 to vol4 +RUSTFS_VOLUMES="./deploy/deploy/vol{1...4}" +# RustFS service startup parameters, specifying listen address and port +RUSTFS_OPTS="--address 0.0.0.0:9000" +# RustFS service listen address and port +RUSTFS_ADDRESS="0.0.0.0:9000" +# Enable RustFS console functionality +RUSTFS_CONSOLE_ENABLE=true +# RustFS console listen address and port +RUSTFS_CONSOLE_ADDRESS="0.0.0.0:9002" +# RustFS service endpoint for client access +RUSTFS_SERVER_ENDPOINT="http://127.0.0.1:9000" +# RustFS service domain configuration +RUSTFS_SERVER_DOMAINS=127.0.0.1:9002 +# RustFS license content +RUSTFS_LICENSE="license content" +# Observability configuration file path: deploy/config/obs.example.toml +RUSTFS_OBS_CONFIG=/etc/default/obs.toml +# TLS certificates directory path: deploy/certs +RUSTFS_TLS_PATH=/etc/default/tls \ No newline at end of file diff --git a/deploy/data/README.md b/deploy/data/README.md new file mode 100644 index 00000000..ac7023e5 --- /dev/null +++ b/deploy/data/README.md @@ -0,0 +1 @@ +# Data Volumes \ No newline at end of file diff --git a/deploy/logs/README.md b/deploy/logs/README.md new file mode 100644 index 00000000..b2c0294c --- /dev/null +++ b/deploy/logs/README.md @@ -0,0 +1 @@ +# RustFS Logs \ No newline at end of file diff --git a/rustfs/README.md b/rustfs/README.md new file mode 100644 index 00000000..86b2ab76 --- /dev/null +++ b/rustfs/README.md @@ -0,0 +1,30 @@ +rustfs/ +├── Cargo.toml +├── src/ +│ ├── main.rs # 主入口 +│ ├── admin/ +│ │ └── mod.rs # 管理接口 +│ ├── auth/ +│ │ └── mod.rs # 认证模块 +│ ├── config/ +│ │ ├── mod.rs # 配置模块 +│ │ └── options.rs # 命令行参数 +│ ├── console/ +│ │ ├── mod.rs # 控制台模块 +│ │ └── server.rs # 控制台服务器 +│ ├── grpc/ +│ │ └── mod.rs # gRPC 服务 +│ ├── license/ +│ │ └── mod.rs # 许可证管理 +│ ├── logging/ +│ │ └── mod.rs # 日志管理 +│ ├── server/ +│ │ ├── mod.rs # 服务器实现 +│ │ ├── connection.rs # 连接处理 +│ │ ├── service.rs # 服务实现 +│ │ └── state.rs # 状态管理 +│ ├── storage/ +│ │ ├── mod.rs # 存储模块 +│ │ └── fs.rs # 文件系统实现 +│ └── utils/ +│ └── mod.rs # 工具函数 \ No newline at end of file diff --git a/rustfs/src/utils.rs b/rustfs/src/utils/mod.rs similarity index 100% rename from rustfs/src/utils.rs rename to rustfs/src/utils/mod.rs