一、A-Ops服务介绍
A-Ops是用于提升主机整体安全性的服务,通过用户管理、资产管理、漏洞管理、配置溯源等功能,识别并管理主机中的信息资产,监测主机中的软件漏洞、排查主机中遇到的系统故障,使得目标主机能够更加稳定和安全的运行。
下表是A-Ops服务涉及服务和RPM包的说明:
| 模块 | 说明 |
|---|---|
| aops-ceres | A-Ops服务的客户端。 提供采集主机数据与管理其他数据采集器(如gala-gopher)的功能。 响应管理中心下发的命令,处理管理中心的需求与操作。 |
| aops-zeus | A-Ops基础应用,主要提供aops-cli命令行工具。 实现微服务的启停、数据库初始化、配置更新热加载、微服务应用一键化部署等。 |
| aops-hermes | A-Ops可视化操作界面,展示数据信息,提升服务易用性。 |
| aops-apollo | A-Ops漏洞管理模块相关功能依赖此服务实现,默认端口:11116。 识别客户机周期性获取openEuler社区发布的安全公告,并更新到漏洞库中。 通过与漏洞库比对,检测出系统和软件存在的漏洞。 |
| aops-vulcanus | A-Ops工具库,除aops-ceres与aops-hermes模块外,其余模块须与此模块共同安装使用。 |
| zeus-user-access | A-Ops用户微服务,提供用户权限管控、集群分层纳管,默认对外端口:11119。 |
| zeus-host-information | A-Ops主机微服务,主机资产基于集群或主机组维度的管理,默认对外端口:11115。 |
| async-task | A-Ops异步任务,后台执行耗时较长的任务、定时任务的触发。 |
| zeus-distribute | A-Ops分发服务,总控端调用集群服务时,需分发服务做中转,实现服务互通,默认端口:11113。 |
二、部署环境要求
服务器资源充足的前提下,可以按照多机器部署,各个服务间主备搭配,实现高可用。同时也支持在单台机器中完成一键化部署应用,具体请参考**[一键化部署安装](#3.6 一键化快速部署)**。
建议采用4台openEuler 20.03-LTS-SP4 机器部署,其中3台用于配置服务端,1台用于纳管(aops服务纳管的主机),且repo中需要配置update源([FAQ:配置update源](#Q6 配置update源)),具体用途以及部署方案如下:
- 机器A:部署mysql、redis、elasticsearch、zookeeper等,主要提供数据服务支持,建议内存8G+。
- 机器B:部署A-Ops的微服务模块(漏洞管理、主机服务、用户服务、分发服务),提供完整的业务功能支持,建议内存8G+。
- 机器C:部署A-Ops的前端服务+异步任务服务,提供可视化操作及后台执行耗时任务,建议内存4G+。
- 机器D:部署A-Ops的客户端,用作一个被AOps服务纳管监控的主机(需要监管的机器中都可以安装aops-ceres)。
| 机器编号 | 配置IP | 部署模块 |
|---|---|---|
| 机器A | 192.168.1.1 | mysql、elasticsearch、 redis、zookeeper |
| 机器B | 192.168.1.2 | aops-apollo、zeus-user-access、zeus-host-information、zeus-distribute、aops-zeus |
| 机器C | 192.168.1.3 | aops-hermes、async-task、canal(选装) |
| 机器D | 192.168.1.4 | aops-ceres、dnf-hotpatch-plugin |
注意:每台机器在部署前,请先关闭防火墙[FAQ:关闭防火墙](#Q8 关闭防火墙))和SELinux([FAQ:禁用SELinux](#Q7 禁用SELinux))。
三、服务端部署
3.1 资产管理
使用资产管理功能需部署aops-host-information、aops-hermes、mysql、redis服务。
3.1.1 节点信息
| 机器编号 | 配置IP | 部署模块 |
|---|---|---|
| 机器A | 192.168.1.1 | mysql、redis、zookeeper |
| 机器B | 192.168.1.2 | zeus-host-information |
| 机器C | 192.168.1.3 | aops-hermes、async-task |
3.1.2 部署步骤
3.1.2.1 部署mysql
- 安装mysql
yum install mysql-server -y
- 修改mysql配置文件
vim /etc/my.cnf
- 在mysqld配置节下新增bind-address,值为本机ip
[mysqld]
bind-address=192.168.1.1
log-bin=mysql-bin
server-id=1
default-storage-engine=INNODB
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
- 重启mysql服务
systemctl restart mysqld
- 设置mysql数据库的root用户访问权限
[root@localhost ~] mysql
mysql> show databases;
mysql> use mysql;
mysql> select user,host from user; -- 此处出现host为localhost时,说明mysql只允许本机连接,外网和本地软件客户端则无法连接。
+---------------+-----------+
| user | host |
+---------------+-----------+
| root | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
+---------------+-----------+
3 rows in set (0.00 sec)
mysql> update user set host = '%' where user='root'; -- 设置允许root用户任意IP访问。
mysql> GRANT system_user on *.* to 'root';
mysql> DELETE FROM mysql.user WHERE user='canal';
mysql> CREATE USER canal IDENTIFIED BY 'canal';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'canal'@'%';
mysql> flush privileges; -- 刷新权限
mysql> exit
3.1.2.2 部署redis
- 安装redis
yum install redis -y
- 修改配置文件
vim /etc/redis.conf
- 绑定IP
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only into
# the IPv4 lookback interface address (this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running).
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 127.0.0.1 192.168.1.1 # 此处添加机器A的真实IP
- 启动redis服务
systemctl start redis
3.1.2.3 部署zookeeper
- 安装zookeeper
yum install zookeeper -y
- 修改配置文件
vim /opt/zookeeper/conf/zoo.cfg
- 允许任意ip连接
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataDir=/var/lib/zookeeper/data
# the port at which the clients will connect
clientPort=2181
# Enable/disable the ability to accept session-less connections (true/false)
quorumListenOnAllIPs=true
- 启动zookeeper服务
systemctl start zookeeper
3.1.2.4 部署zeus-host-information
- 安装zeus-host-information
yum install zeus-host-information -y
- 修改配置文件
vim /etc/aops/conf.d/zeus-host-information.yml
- 默认文件内容如下
uwsgi:
port: 11115
daemonize: /var/log/aops/uwsgi/host-information.log
http_timeout: 60
processes: 1
gevent: 100
默认数据库等连接配置同全局配置保持一致,即**/etc/aops/aops-config.yml中的配置项,如果需要为此服务单独配置连接,可在/etc/aops/conf.d/zeus-host-information.yml**增加与全局格式一致的配置项,示例如下:
uwsgi: port: 11115 daemonize: /var/log/aops/uwsgi/host-information.log http_timeout: 60 processes: 1 gevent: 100 mysql: host: 192.168.1.1 port: 3306 username: root pool_size: 100 pool_recycle: 7200 database: aops username: root
注意:/etc/aops/aops-config.yml配置项中的domain选项需要与hermes机器C的ip保持一致
infrastructure:
mysql:
host: 192.168.1.1
port: 3306
username: root
pool_size: 100
pool_recycle: 7200
database: aops
username: root
redis:
host: 192.168.1.1
port: 6379
zookeeper:
host: 192.168.1.1
port: 2181
include: "/etc/aops/conf.d"
domain: "http://192.168.1.3"
services:
log:
log_level: "INFO"
log_dir: "/var/log/aops"
max_bytes: 31457280
backup_count: 40
- 启动aops-zeus服务
systemctl start zeus-host-information
注意:服务启动前请确保已 [初始化zeus-host-information数据库](#3.1.2.5 初始化zeus-host-information数据库)
3.1.2.5 初始化zeus-host-information数据库
- 执行数据库初始化
aops-cli database --init zeus-host-information
3.1.2.6 部署aops-hermes
- 安装aops-hermes
yum install aops-hermes -y
3.1.2.7 调整zeus-host-information服务upstream和代理
- 修改配置文件
vim /etc/nginx/nginx.conf
注意: 在安装aops-hermes应用的机器上操作(机器C)
- 服务配置展示,开放与主机服务相关的配置
user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
client_max_body_size 25M;
include /etc/nginx/conf.d/*.conf;
upstream host {
server 192.168.1.2:11115;
}
#upstream accounts {
# server @accounts;
#}
#upstream distribute {
# server @distribute;
#}
#upstream apollo {
# server @apollo;
#}
underscores_in_headers on;
server {
listen 80;
listen [::]:80 default_server;
server_name localhost;
# gzip config
gzip on;
gzip_min_length 1k;
gzip_comp_level 6;
gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
location ~ .*\.(js|css|ico|png|jpg|eot|svg|ttf|woff|html|txt|pdf|) {
root /opt/aops/web/dist;
expires 30d;
}
location / {
try_files $uri $uri/ /index.html;
if (!-e $request_filename){
rewrite ^(.*)$ /index.html last;
}
}
location /hosts {
proxy_pass http://host;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Request-Header $http_request_header;
}
#location /accounts {
# proxy_pass http://accounts;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Request-Header $http_request_header;
#}
#location /distribute {
# rewrite ^/distribute(.*)$ /distribute break;
# proxy_pass http://distribute;
# proxy_set_header X-Real-URL $request_uri;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Request-Header $http_request_header;
#}
#location /vulnerabilities {
# proxy_pass http://apollo;
# proxy_set_header X-Real-URL $request_uri;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Request-Header $http_request_header;
#}
}
}
stream {
upstream mysql_prod {
server 192.168.1.1:3306;
}
server {
listen 3306;
proxy_responses 1;
proxy_timeout 20s;
proxy_pass mysql_prod;
}
}
注意:由于主机服务在机器B上部署,因此需要调整upstream host中的server指向机器B的地址,mysql服务部署在机器A中,因此调整upstream mysql_prod中的server指向机器A的地址
- 开启aops-hermes服务
systemctl start aops-hermes
systemctl restart nginx
3.2 用户服务
使用用户服务功能需部署zeus-user-access服务。
3.2.1 节点信息
| 机器编号 | 配置IP | 部署模块 |
|---|---|---|
| 机器A | 192.168.1.1 | mysql、redis、zookeeper |
| 机器B | 192.168.1.2 | zeus-user-access |
| 机器C | 192.168.1.3 | aops-hermes |
3.2.2 部署步骤
3.2.2.1 部署zeus-user-access
- 安装zeus-user-access
yum install zeus-user-access -y
- 修改配置文件
vim /etc/aops/conf.d/zeus-user-access.yml
- 默认文件内容如下
uwsgi:
port: 11119
daemonize: /var/log/aops/uwsgi/user-access.log
http_timeout: 60
processes: 1
threads: 2
默认数据库连接配置同全局配置保持一致,即**/etc/aops/aops-config.yml中的配置项,如果需要为该服务单独配置连接,可在/etc/aops/conf.d/zeus-user-access.yml**增加与全局格式一致的配置项,示例如下:
uwsgi: port: 11119 daemonize: /var/log/aops/uwsgi/user-access.log http_timeout: 60 processes: 1 threads: 2 mysql: host: 192.168.1.1 port: 3306 username: root pool_size: 100 pool_recycle: 7200 database: aops username: root
注意:/etc/aops/aops-config.yml配置项中的domain选项需要与hermes机器C的ip保持一致
infrastructure:
mysql:
host: 192.168.1.1
port: 3306
username: root
pool_size: 100
pool_recycle: 7200
database: aops
username: root
redis:
host: 192.168.1.1
port: 6379
zookeeper:
host: 192.168.1.1
port: 2181
individuation:
gitee_client_id: 7420ebbb10f7f196de479bd3fe30f120691321143fdae882bc8b3320b3dbb71c
gitee_client_secret: c6466348389db3a2da3a86ec3b544c19c15f50de513da4dc3edbadaa2e5df792
redirect_url: http://127.0.0.1:8000/user/account
exempt_authentication: ?Ohdc,&S*2O].f%-Y1Z~f%~9^U5uD]AQ
private_key: sfwsfs{)sdf_+$%{$^%$NI07&*()@$&^*(*(^&%(
include: "/etc/aops/conf.d"
domain: 192.168.1.3
services:
log:
log_level: "INFO"
log_dir: "/var/log/aops"
max_bytes: 31457280
backup_count: 40
email:
server: smtp.163.com
port: 25
sender: xxx@163.com
authorization_code: xxx
smtp_ssl: false
enabled: false
- 启动aops-zeus服务
systemctl start zeus-user-access
注意:服务启动前请确保已 [初始化zeus-user-access数据库](#3.2.2.2 初始化zeus-user-access数据库)
3.2.2.2 初始化zeus-user-access数据库
- 执行数据库初始化
aops-cli database --init zeus-user-access
注意:若要使用可视化服务,请参考[部署aops-hermes](#3.1.2.6 部署aops-hermes)应用部署
3.2.2.3 调整zeus-user-access服务upstream和代理
- 修改aops-hermes关联的nginx配置文件
vim /etc/nginx/nginx.conf
注意: 在安装aops-hermes应用的机器上操作(机器C)
- 服务配置展示,放开与用户服务关联的配置块
user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
client_max_body_size 25M;
include /etc/nginx/conf.d/*.conf;
#upstream host {
# server @hosts;
#}
upstream accounts {
server 192.168.1.2:11119;
}
#upstream distribute {
# server @distribute;
#}
#upstream apollo {
# server @apollo;
#}
underscores_in_headers on;
server {
listen 80;
listen [::]:80 default_server;
server_name localhost;
# gzip config
gzip on;
gzip_min_length 1k;
gzip_comp_level 6;
gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
location ~ .*\.(js|css|ico|png|jpg|eot|svg|ttf|woff|html|txt|pdf|) {
root /opt/aops/web/dist;
expires 30d;
}
location / {
try_files $uri $uri/ /index.html;
if (!-e $request_filename){
rewrite ^(.*)$ /index.html last;
}
}
#location /hosts {
# proxy_pass http://host;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Request-Header $http_request_header;
#}
location /accounts {
proxy_pass http://accounts;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Request-Header $http_request_header;
}
#location /distribute {
# rewrite ^/distribute(.*)$ /distribute break;
# proxy_pass http://distribute;
# proxy_set_header X-Real-URL $request_uri;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Request-Header $http_request_header;
#}
#location /vulnerabilities {
# proxy_pass http://apollo;
# proxy_set_header X-Real-URL $request_uri;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Request-Header $http_request_header;
#}
}
}
stream {
upstream mysql_prod {
server 192.168.1.1:3306;
}
server {
listen 3306;
proxy_responses 1;
proxy_timeout 20s;
proxy_pass mysql_prod;
}
}
注意:由于用户服务在机器B上部署,因此需要调整upstream accounts中的server指向机器B的地址,mysql服务部署在机器A中,因此调整upstream mysql_prod中的server指向机器A的地址。
- 重启nginx服务
systemctl restart nginx
3.2.2.4 异步任务async-task
- 安装异步任务服务
yum install async-task -y
注意:异步任务中同时包含了定时任务模块,其中有一项定时任务为动态更新nginx的upstream块,在启用了该定时任务前提下,建议异步任务和nginx在同一台机器上部署,保证定时动态更新nginx配置任务正常执行,在该部署方案中,异步任务需安装在机器C上。
- 启用定时任务
vim /etc/aops/crontab.yml
- 设置enable为true/false
# Timed task configuration file specification (YAML):
# Name of a scheduled task, name should be unique, only 'upstream', 'download-sa' and 'cve-scan' and 'correct-data' e.g
# task: upstream
# Whether scheduled tasks are allowed to run
# enable: true
# meta info for the task, it's customised for user
# meta:
# cvrf_url: https://repo.openeuler.org/security/data/cvrf
# Timed config, set the scheduled time and polling policy
# timed:
# value between 0-6, for example, 0 means Monday, 0-6 means everyday
# day_of_week: 0-6
# value between 0-23, for example, 2 means 2:00 in a day
# hour: 3
# Polling strategy, The value can only be 'cron' 'date' 'interval', default value is 'cron'
# trigger: cron
- task: upstream
enable: true
timed:
day_of_week: 0-6
hour: 3
trigger: cron
- task: download-sa
enable: true
meta:
cvrf_url: https://repo.openeuler.org/security/data/cvrf
timed:
day_of_week: 0-6
hour: 3
trigger: cron
- task: cve-scan
enable: true
timed:
day_of_week: 0-6
hour: 3
trigger: cron
- task: correct-data
enable: true
timed:
minutes: 20
trigger: interval
- task: send-notification
enable: true
timed:
day_of_week: 0-6
hour: 4
trigger: cron
- 启用异步任务
systemctl start async-task
3.3 分发服务
使用分发服务功能需部署zeus-distribute服务。
3.3.1 节点信息
| 机器编号 | 配置IP | 部署模块 |
|---|---|---|
| 机器A | 192.168.1.1 | redis、zookeeper |
| 机器B | 192.168.1.2 | zeus-distribute |
3.3.2 部署步骤
3.3.2.1 部署zeus-distribute
- 安装zeus-distribute
yum install zeus-distribute -y
- 修改配置文件
vim /etc/aops/conf.d/zeus-distribute.yml
- 默认文件内容如下
uwsgi:
port: 11113
daemonize: /var/log/aops/uwsgi/distribute.log
http_timeout: 60
processes: 1
gevent: 100
默认数据库连接配置同全局配置保持一致,即**/etc/aops/aops-config.yml中的配置项,如果需要为该服务单独配置连接,可在/etc/aops/conf.d/zeus-distribute.yml**增加与全局格式一致的配置项,示例如下:
uwsgi: port: 11113 daemonize: /var/log/aops/uwsgi/distribute.log http_timeout: 60 processes: 1 gevent: 100 redis: host: 192.168.1.1 port: 6379
注意:/etc/aops/aops-config.yml配置项中的domain选项需要与hermes机器C的ip保持一致
infrastructure:
redis:
host: 192.168.1.1
port: 6379
zookeeper:
host: 192.168.1.1
port: 2181
include: "/etc/aops/conf.d"
domain: "http://192.168.1.3"
services:
log:
log_level: "INFO"
log_dir: "/var/log/aops"
max_bytes: 31457280
backup_count: 40
- 启动aops-zeus服务
systemctl start zeus-distribute
注意:若要使用可视化服务,请参考[部署aops-hermes](#3.1.2.6 部署aops-hermes)应用部署
3.3.2.3 调整zeus-distribute服务upstream和代理
- 修改aops-hermes关联的nginx配置文件
vim /etc/nginx/nginx.conf
注意: 在安装aops-hermes应用的机器上操作(机器C)
- 服务配置展示,放开与分发服务关联的配置块
user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
client_max_body_size 25M;
include /etc/nginx/conf.d/*.conf;
#upstream host {
# server @hosts;
#}
#upstream accounts {
# server 192.168.1.2:11119;
#}
upstream distribute {
server 192.168.1.2:11113;
}
#upstream apollo {
# server @apollo;
#}
underscores_in_headers on;
server {
listen 80;
listen [::]:80 default_server;
server_name localhost;
# gzip config
gzip on;
gzip_min_length 1k;
gzip_comp_level 6;
gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
location ~ .*\.(js|css|ico|png|jpg|eot|svg|ttf|woff|html|txt|pdf|) {
root /opt/aops/web/dist;
expires 30d;
}
location / {
try_files $uri $uri/ /index.html;
if (!-e $request_filename){
rewrite ^(.*)$ /index.html last;
}
}
#location /hosts {
# proxy_pass http://host;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Request-Header $http_request_header;
#}
#location /accounts {
# proxy_pass http://accounts;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Request-Header $http_request_header;
#}
location /distribute {
rewrite ^/distribute(.*)$ /distribute break;
proxy_pass http://distribute;
proxy_set_header X-Real-URL $request_uri;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Request-Header $http_request_header;
}
#location /vulnerabilities {
# proxy_pass http://apollo;
# proxy_set_header X-Real-URL $request_uri;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Request-Header $http_request_header;
#}
}
}
stream {
upstream mysql_prod {
server 192.168.1.1:3306;
}
server {
listen 3306;
proxy_responses 1;
proxy_timeout 20s;
proxy_pass mysql_prod;
}
}
注意:由于用户服务在机器B上部署,因此需要调整upstream distribute中的server指向机器B的地址,mysql服务部署在机器A中,因此调整upstream mysql_prod中的server指向机器A的地址
- 重启nginx服务
systemctl restart nginx
3.4 漏洞管理
CVE管理模块在[资产管理](#3.1.2 部署步骤)、[用户服务](#3.2.2 部署步骤)模块的基础上实现,在部署CVE管理模块前须完成[资产管理](#3.1.2 部署步骤)、[用户服务](#3.2.2 部署步骤)、[分发服务](#3.3.2 部署步骤)模块的部署,然后再部署aops-apollo。
数据服务部分aops-apollo服务的运行需要mysql、elasticsearch、redis数据库的支持。
3.4.1 节点信息
| 机器编号 | 配置IP | 部署模块 |
|---|---|---|
| 机器A | 192.168.1.1 | elasticsearch、redis、mysql、zookeeper |
| 机器C | 192.168.1.2 | aops-apollo |
3.4.2 部署步骤
[资产管理](#3.1.2 部署步骤)
[用户服务](#3.2.2 部署步骤)
[分发服务](#3.3.2 部署步骤)
3.4.2.1 部署elasticsearch
- 生成elasticsearch的repo源:
echo "[aops_elasticsearch]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md" > "/etc/yum.repos.d/aops_elascticsearch.repo"
- 安装elasticsearch:
yum install elasticsearch-7.14.0-1 -y
- 修改elasticsearch配置文件:
vim /etc/elasticsearch/elasticsearch.yml
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
# 此处修改为机器A真实ip
network.host: 192.168.1.1
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["node-1"]
# 跨域配置
http.cors.enabled: true
http.cors.allow-origin: "*"
**注意:如果服务器内存较小时,需手动限制elasticsearch运行内存,具体请参考([FAQ:elasticsearch内存调整](#Q6 elasticsearch内存占用高,系统级kill))
- 重启elasticsearch服务
systemctl restart elasticsearch
3.4.2.2 部署aops-apollo
- 安装aops-apollo
yum install aops-apollo -y
- 修改配置文件
vim /etc/aops/conf.d/aops-apollo.yml
- 默认文件内容如下
cve:
cve_fix_function: yum
# value between 0-23, for example, 2 means 2:00 in a day.
cve_scan_time: 2
uwsgi:
daemonize: /var/log/aops/uwsgi/apollo.log
http_timeout: 600
harakiri: 600
processes: 1
gevent: 100
port: 11116
file:
classname: ""
path: /opt/aops/scripts/file_manage_support/download.py
extra: ""
默认数据库连接配置同全局配置保持一致,即**/etc/aops/aops-config.yml中的配置项,如果需要为该服务单独配置连接,可在/etc/aops/conf.d/aops-apollo.yml**增加与全局格式一致的配置项,示例如下:
uwsgi: port: 11119 daemonize: /var/log/aops/uwsgi/user-access.log http_timeout: 60 processes: 1 threads: 2 mysql: host: 192.168.1.1 port: 3306 username: root pool_size: 100 pool_recycle: 7200 database: aops username: root elasticsearch: host: 192.168.1.1 port: 9200 max_es_query_num: 10000000
注意:/etc/aops/aops-config.yml配置项中的domain选项需要与hermes机器C的ip保持一致
infrastructure:
mysql:
host: 192.168.1.1
port: 3306
username: root
pool_size: 100
pool_recycle: 7200
database: aops
username: root
redis:
host: 192.168.1.1
port: 6379
zookeeper:
host: 192.168.1.1
port: 2181
elasticsearch:
host: 192.168.1.1
port: 9200
max_es_query_num: 10000000
include: "/etc/aops/conf.d"
domain: "http://192.168.1.3"
services:
log:
log_level: "INFO"
log_dir: "/var/log/aops"
max_bytes: 31457280
backup_count: 40
- 启动aops-apollo服务
systemctl start aops-apollo
注意:服务启动前请确保已 [初始化aops-apollo数据库](#3.4.2.3 初始化aops-apollo数据库)
3.4.2.3 初始化aops-apollo数据库
- apollo数据库初始化
aops-cli database --init aops-apollo
注意:如果提示未发现aops-cli命令时,需要安装aops-zeus包
3.5 客户端安装
aops-ceres作为A-Ops模块的客户端,通过ssh协议与AOps管理中心进行数据交互,提供采集主机信息、响应并处理中心命令等功能。
3.5.1 节点信息
| 机器编号 | 配置IP | 部署模块 |
|---|---|---|
| 机器D | 192.168.1.4 | aops-ceres |
3.5.2 部署客户端
yum install aops-ceres dnf-hotpatch-plugin -y
3.6 一键化快速部署
A-Ops为了简化用户的安装部署流程,在aops-zeus包中提供了aops-cli命令行工具,可以通过cli工具一键化快速安装部署服务。
在使用一键化部署时,由于服务和基础环境都同时安装在一台机器上,建议服务器最小配置内存在16G+。
3.6.1 节点信息
| 机器编号 | 配置IP | 部署模块 |
|---|---|---|
| 机器A | 192.168.1.1 | aops-apollo、zeus-host-information、zeus-user-access、zeus-distribute、async-task、redis、mysql、elasticsearch、zookeeper、aops-zeus |
| 机器D | 192.168.1.4 | aops-ceres |
3.6.2 部署步骤
在执行一键化部署前,请先手动关闭防火墙和禁用SELinux,具体请参考([FAQ:禁用SELinux](#Q7 禁用SELinux))。
3.6.2.1 部署aops-zeus
- 安装aops-zeus
yum install aops-zeus -y
- 使用aops-cli一键化部署
aops-cli deploy --ip 192.168.1.1
温馨提示:等待执行成功后,可打开浏览器访问http://192.168.1.1使用A-Ops
FAQ
Q1 最大连接数(MaxStartups)
批量添加主机接口服务执行过程中会受到aops-zeus安装所在主机sshd服务配置中最大连接数(MaxStartups)的限制,会出现部分主机不能连接的情况,如有大量添加主机的需求,可考虑临时调增该数值。关于该配置项的修改可参考ssh文档。
Q2 504网关超时
部分http访问接口执行时间较长,web端可能返回504错误,可向nginx配置中添加proxy_read_timeout配置项,并适当调大该数值,可降低504问题出现概率。
Q3 防火墙
若防火墙不方便关闭,请设置放行服务部署过程涉及的所有接口,否则会造成服务不可访问,影响A-Ops的正常使用。
Q4 elasticasearch访问拒绝
elasticsearch分布式部署多节点时,需调整配置跨域部分,允许各节点访问。
Q5 配置update源
echo "[update]
name=update
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS-SP4/update/$basearch/
enabled=1
gpgcheck=0
[update-epol]
name=update-epol
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS-SP4/EPOL/update/main/$basearch/
enabled=1
gpgcheck=0" > /etc/yum.repos.d/openEuler-update.repo
注意: 其中openEuler-20.03-LTS-SP4 根据部署的系统版本具体调整,或可直接参与openeuler官网中针对repo源配置介绍
Q6 elasticsearch内存占用高,系统级kill
elasticsearch在运行过程中,默认会占用系统一半的内存,当系统内存较小时,该默认配置会导致系统频繁的杀掉该进程,为确保系统正常稳定运行,需调整elasticsearch默认内存占用策略。
- 修改elasticsearch jvm配置
vim /etc/elasticsearch/jvm.options
- 调整内存策略(可根据服务器内存大小自行调整,但不能少于2G)
################################################################
## IMPORTANT: JVM heap size
################################################################
##
## The heap size is automatically configured by Elasticsearch
## based on the available memory in your system and the roles
## each node is configured to fulfill. If specifying heap is
## required, it should be done through a file in jvm.options.d,
## and the min and max should be set to the same value. For
## example, to set the heap to 4 GB, create a new file in the
## jvm.options.d directory containing these lines:
##
-Xms4g
- 重启elasitcsearch
systemctl restart elasticsearch
Q7 禁用SELinux
- 禁用SELinux
# 修改/etc/selinux/config文件中SELINUX状态为disabled
vi /etc/selinux/config
SELINUX=disabled
注:此SELINUX状态配置在系统重启后生效。
Q8 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld
setenforce 0




