Categorygithub.com/project-nano/core
repositorypackage
1.4.0
Repository: https://github.com/project-nano/core.git
Documentation: pkg.go.dev

# README

Nano Core

[版本历史/ChangeLog]

English Version

简介

Core模块是Nano集群的主控节点,将Cell节点的计算资源组成虚拟化资源池,在节点之间调度管理云主机实例。

Core模块所有功能均可以通过API方式进行调用,便于用户集成到内部系统中。

由于涉及网络配置,建议使用专用Installer进行部署,项目最新版本请访问此地址

项目官网

项目全部源代码

编译

环境要求

  • CentOS 7 x86
  • Golang 1.20
准备依赖的framework
$git clone https://github.com/project-nano/framework.git

准备编译源代码
$git clone https://github.com/project-nano/core.git

编译
$cd core
$go build

编译成功在当前目录生成二进制文件core

使用

环境要求

  • CentOS 7 x86
执行以下指令,启动Core模块
$./core start

也可以使用绝对地址调用或者写入开机启动脚本,比如
$/opt/nano/core/core start

模块运行日志输出在log/core.log文件中,用于查错和调试

由于Cell节点依赖Core模块进行自动网络识别,所以集群工作时必须最先启动Core模块,再启动其他Cell节点。

此外,除了模块启动功能,Core还支持以下命令参数启动

命令名说明
start启动服务
stop停止服务
status检查当前服务状态
halt强行中止服务(用于服务异常时重启)

配置

Core模块配置信息存放在config路径文件中,修改后需要重启模块生效

域通讯配置

文件config/domain.cfg管理Core模块的域通讯信息

参数值类型默认值必填说明
domain字符串nano通讯域名称,用于节点间识别
group_address字符串224.0.0.226通讯域组播地址,用于服务发现
group_port整数5599通讯域组播端口,用于服务发现
listen_address字符串Core模块的主机监听地址,提供API等服务
timeout整数10交易处理超时时间,单位:秒

假设Core模块工作地址为192.168.1.31,示例配置文件如下

{
 "domain": "nano",
 "group_address": "224.0.0.226",
 "group_port": 5599,
 "listen_address": "192.168.1.31"
}

API配置

文件config/api.cfg管理Core模块的应用接口

参数值类型默认值必填说明
port整数5850API监听端口
credentials对象数组允许调用的API身份
credentials.id字符串身份校验的请求标识ID,对应FrontEnd的api_id
credentials.key字符串身份校验的秘钥内容,对应FrontEnd的api_key

示例配置文件如下

{
 "port": 5850,
 "credentials": [
  {
   "id": "dummyID",
   "key": "ThisIsAKeyPlaceHolder_ChangeToYourContent"
  }
 ]
}

镜像服务配置

文件config/image.cfg管理Core模块的镜像服务

参数值类型默认值必填说明
cert_file字符串镜像服务TLS传输证书文件
key_file字符串镜像服务TLS传输秘钥文件

示例配置文件如下

{
 "cert_file": "/opt/nano/core/cert/nano_image.crt.pem",
 "key_file": "/opt/nano/core/cert/nano_image.key.pem"
}

目录结构

模块主要目录和文件如下

目录/文件说明
core模块二进制执行文件
cert/TLS证书存储目录
config/配置文件存储目录
data/模块运行数据存储目录
log/运行日志存储目录

README

Introduce

Core is control center of Nano cluster, which groups the computing resources of Cell nodes into a virtualized resource pool, and schedules and manages instances among the nodes.

A application could call all functions of Core via API.

It is recommended to use a dedicated Installer for deployment. For the latest project version, please visit this address.

Official Project Website

Full Source Code of the Project

Compilation

Environment requirements

  • CentOS 7 x86
  • Golang 1.20
Prepare the framework dependencies
$git clone https://github.com/project-nano/framework.git

Prepare the source code for compilation
$git clone https://github.com/project-nano/core.git

Compile
$cd core
$go build
    

The binary file "core" will be generated in the current directory when success

Usage

Environment

  • CentOS 7 x86
start module
$./core start

Alternatively, you can use an absolute address or write it into a startup script, such as:
$/opt/nano/core/core start
    

The log file core.log is output on the log/core.log file.

Since the Cell nodes depend on the Core module for automatic network recognition, you must start the Core module first, and then start other Cell nodes.

Core also supports the following command

Command nameExplanation
startStart service
stopStop service
statusCheck current service status
haltForce abort service when exception occurs

Configuration

Core module configuration information is stored in files under the config path, and modifications require a restart of the module to take effect.

Domain Communication

The file config/domain.cfg manages the domain communication information for the Core module.

ParameterValue TypeDefault ValueRequiredExplanation
domainStringnanoYesThe name of the communication domain, used for cluster identification
group_addressString224.0.0.226YesMulticast address of the communication domain, used for service discovery
group_portInteger5599YesMulticast port of the communication domain, used for service discovery
listen_addressStringYesListening Address of the core service,string in the IPv4 format
timeoutInteger10Transaction timeout in seconds

Assuming the working address of the Core module is 192.168.1.31, an example configuration file is as follows:

{
 "domain": "nano",
 "group_address": "224.0.0.226",
 "group_port": 5599,
 "listen_address": "192.168.1.31"
}

API

The file config/api.cfg manages the API service

ParameterValue TypeDefault ValueRequiredExplanation
portInteger5850YesThe API listening port
credentialsArray ObjectYesAllowed API identities
credentials.idStringYesThe request ID for identity verification, corresponding to FrontEnd's api_id
credentials.keyStringYesThe secret key content for identity verification, corresponding to FrontEnd's api_key

An example configuration file is as follows:

{
 "port": 5850,
 "credentials": [
  {
   "id": "dummyID",
   "key": "ThisIsAKeyPlaceHolder_ChangeToYourContent"
  }
 ]
}

Image Service

The file config/image.cfg manages the image service of the Core module.

ParameterValue TypeDefault ValueRequiredExplanation
cert_fileStringYesTLS certificate file for the image service
key_fileStringYesTLS secret key file for the image service

An example configuration file is as follows:

{
 "cert_file": "/opt/nano/core/cert/nano_image.crt.pem",
 "key_file": "/opt/nano/core/cert/nano_image.key.pem"
}

Directory Structure

Directory/FileExplanation
coreThe binary execution file of the module
cert/The storage directory for TLS certificates
config/The storage directory for configurations
data/The storage directory for operation data
log/The storage directory for logs