设为首页 加入收藏

TOP

InfluxDB服务器启动流程(二)
2018-01-17 13:05:27 】 浏览:216
Tags:InfluxDB 服务器 启动 流程
nvironment variables on top of the parsed config
    if err := config.ApplyEnvOverrides(); err != nil {
        return fmt.Errorf("apply env config: %v", err)
    }


    // Validate the configuration.
    if err := config.Validate(); err != nil {
        return fmt.Errorf("%s. To generate a valid configuration file run `influxd config > influxdb.generated.conf`", err)
    }


    if config.HTTPD.PprofEnabled {
        // Turn on block profiling to debug stuck databases
        runtime.SetBlockProfileRate(int(1 * time.Second))
    }


    // Create server from config and start it.
    buildInfo := &BuildInfo{
        Version: cmd.Version,
        Commit:  cmd.Commit,
        Branch:  cmd.Branch,
        Time:    cmd.BuildTime,
    }
    s, err := NewServer(config, buildInfo)
    if err != nil {
        return fmt.Errorf("create server: %s", err)
    }
    s.CPUProfile = options.CPUProfile
    s.MemProfile = options.MemProfile
    if err := s.Open(); err != nil {
        return fmt.Errorf("open server: %s", err)
    }
    cmd.Server = s


    // Begin monitoring the server's error channel.
    go cmd.monitorServerErrors()


    return nil
}


解释如下:


1、解析命令行参数并放入options变量中


2、打印InfluxDB字符串logo


3、设置日志前缀


4、设置程序最大使用cpu的数量


默认使用服务器上的所有cpu,最坏情况下会导致cpu占用100%的场景出现。


5、添加启动日志


6、记录pid文件


该功能需要在命令行参数中指定pid文件路径才可以。


7、加载配置文件


解析并校验配置文件,如果没有问题则配置文件生效。


8、设置profile信息并启动服务器


9、启动各项服务


执行Server.Open函数(run/server.go)启动各项服务,具体内容可以在Server.Open函数中查看。


10、执行monitorServerErrors用于监控服务器出错情况


 


如果命令行参数为"backup",则执行如下流程:


数据备份流程。


 


如果命令行参数为"restore",则执行如下流程:


数据恢复流程。


 


如果命令行参数为"config",则执行如下流程:


输出默认的配置信息。


 


如果命令行参数为"help",则执行如下流程:


输出帮助信息。


好,就这些了,希望对你有帮助。


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇MySQL binlog日志存放位置的修改 下一篇关于Oracle开启自动收集统计信息..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目