暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

夜莺监控V5部署实践分享(NTP架构)

大侠之运维 2022-01-12
1256


前置准备工作

涉及中间件及版本:
  • nginx 1.16.1
  • mysql 5.7.25
  • redis 5.0.14
  • prometheus  2.32.1
  • n9e 5.3.0
  • telegraf  1.21.2
  • 软件安装目录 usr/local

部署架构

其中mysql redis 均为单点模式

 
机器列表

192.168.25.128
n9e-webapi、redis
192.168.25.129
n9e-webserver、redis
192.168.25.130
prometheus、mysql

redis部署

    yum install -y gcc


    软件包获取


      curl -OL https://download.redis.io/releases/redis-5.0.14.tar.gz

      解压

        tar -xvf redis-5.0.14.tar.gz -C usr/local


          #编译安装
          make PREFIX=/usr/local/redis/redis-single install
          #新建目录 在bin同级目录下
          cd /usr/local/redis/redis-single
          mkdir run data log conf


          vim  /usr/local/redis/redis-single/conf/redis.conf
            #bind 127.0.0.1
            protected-mode yes
            port 6379
            tcp-backlog 511
            timeout 0
            tcp-keepalive 300
            daemonize no
            supervised no
            pidfile var/run/redis_6379.pid
            loglevel notice
            logfile ""
            databases 16
            always-show-logo yes
            save 900 1
            save 300 10
            save 60 10000
            stop-writes-on-bgsave-error yes
            rdbcompression yes
            rdbchecksum yes
            dbfilename dump.rdb
            dir ./
            replica-serve-stale-data yes
            replica-read-only yes
            repl-diskless-sync no
            repl-diskless-sync-delay 5
            repl-disable-tcp-nodelay no
            replica-priority 100
            lazyfree-lazy-eviction no
            lazyfree-lazy-expire no
            lazyfree-lazy-server-del no
            replica-lazy-flush no
            appendonly no
            appendfilename "appendonly.aof"
            appendfsync everysec
            no-appendfsync-on-rewrite no
            auto-aof-rewrite-percentage 100
            auto-aof-rewrite-min-size 64mb
            aof-load-truncated yes
            aof-use-rdb-preamble yes
            lua-time-limit 5000
            slowlog-log-slower-than 10000
            slowlog-max-len 128
            latency-monitor-threshold 0
            notify-keyspace-events ""
            hash-max-ziplist-entries 512
            hash-max-ziplist-value 64
            list-max-ziplist-size -2
            list-compress-depth 0
            set-max-intset-entries 512
            zset-max-ziplist-entries 128
            zset-max-ziplist-value 64
            hll-sparse-max-bytes 3000
            stream-node-max-bytes 4096
            stream-node-max-entries 100
            activerehashing yes
            client-output-buffer-limit normal 0 0 0
            client-output-buffer-limit replica 256mb 64mb 60
            client-output-buffer-limit pubsub 32mb 8mb 60
            hz 10
            dynamic-hz yes
            aof-rewrite-incremental-fsync yes
            rdb-save-incremental-fsync yes
            daemonize yes
            requirepass password456

            启动

            ./redis-server ../conf/redis.conf

            后续需要加到开机自启动 统一采用systemd方式
             
             
            MySQL部署

            这里采用5.7.25版本,先去下包

            地址:https://downloads.mysql.com/archives/community/ 

            按照需求下载如下几个包


             
            服务器上先去确认是否有残余的包


              rpm -qa | grep mysql


              yum remove mysql-libs


              按照顺序安装对应的rpm包  依赖关系依次为common→libs→client→server


                rpm -ivh mysql-community-common-5.7.25-1.el7.x86_64.rpm
                rpm -ivh mysql-community-libs-5.7.25-1.el7.x86_64.rpm
                rpm -ivh mysql-community-client-5.7.25-1.el7.x86_64.rpm
                rpm -ivh mysql-community-server-5.7.25-1.el7.x86_64.rpm

                启动服务

                  systemctl start mysqld.service
                  systemctl enable mysqld.service

                  查看初始密码
                    grep 'temporary password' var/log/mysqld.log

                    登录 修改密码 刷新权限

                      mysql> set global validate_password_policy=1;
                      mysql> set password for root@localhost=password('password456');
                      mysql> grant all privileges on *.* to root@'%' identified by 'password456';
                      mysql> flush privileges;

                      prometheus部署

                      获取包 解压

                        curl -OL https://github.com/prometheus/prometheus/releases/download/v2.32.1/prometheus-2.32.1.linux-amd64.tar.gz 
                        tar -xvf prometheus-2.32.1.linux-amd64.tar.gz -C usr/local/
                        mv prometheus-2.32.1.linux-amd64/ prometheus
                         
                        修改配置文件
                         
                        启动
                        nohup ./prometheus &
                        后续可以设置开机启动 采用systemd方式

                        界面如下
                         
                        n9e部署

                        获取包
                          curl -OL https://github.com/didi/nightingale/releases/download/v5.3.0/n9e-5.3.0.tar.gz
                          mkdir /usr/local/n9e
                          tar -xvf n9e-5.3.0.tar.gz -C /usr/local/n9e
                           
                          修改对应的配置文件
                          /usr/local/n9e/etc/server.conf
                           
                            [Redis]
                            # address, ip:port
                            Address = "192.168.25.129:6379"
                            # requirepass
                            Password = "password456"

                            [MySQL]
                            # mysql address host:port
                            Address = "192.168.25.130:3306"
                            # mysql username
                            User = "root"
                            # mysql password
                            Password = "password456"

                            [Reader]
                            # prometheus base url
                            Url = "http://192.168.25.130:9090"
                            # Basic auth username

                            [[Writers]]
                            Url = "http://192.168.25.130:9090/api/v1/write"
                            # Basic auth username
                             webapi配置文件
                              /usr/local/n9e/etc/webapi.conf
                              redis mysql
                              [[Clusters]]
                              # Prometheus cluster name
                              Name = "Default"
                              # Prometheus APIs base url
                              Prom = "http://192.168.25.130:9090"
                               
                              数据库初始化
                                mysql -uroot -h192.168.25.130 -ppassword456 < a-n9e.sql
                                 
                                启动服务,后续可以加入开机自启 采用systemd方式
                                  nohup ./n9e server &
                                  nohup ./n9e webapi &
                                   
                                  访问页面


                                  后续更新实际使用情况


                                  文章转载自大侠之运维,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

                                  评论