centos7.6部署prometheus

1.安装前准备

Prometheus Server 192.168.2.79
node_exporter 192.168.2.70

2.下载所需的包下载所需的包

$ cd /usr/local/
prometheus-2.11.1.linux-amd64.tar
node_exporter-0.18.1.linux-amd64.tar
tar -zxvf  prometheus-2.11.1.linux-amd64.tar 
mv prometheus-2.11.1.linux-amd64 prometheus

3.创建prometheus用户。

$ groupadd prometheus
$ useradd -g prometheus -m -d /var/lib/prometheus -s /sbin/nologin prometheus

4.创建systemctl启动文件

[root@localhost ~]# cat /usr/lib/systemd/system/prometheus.service 
[Unit]
Description=prometheus
After=network.target
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus --storage.tsdb.retention=15d --log.level=info
Restart=on-failure
[Install]
WantedBy=multi-user.target

5.启动prometheus

systemctl daemon-reload
systemctl start prometheus
systemctl enable prometheus

6.浏览器访问:

192.168.2.79:9090即可打开Prometheus Server

7.安装agent端,创建prometheus用户。

$ groupadd prometheus
$ useradd -g prometheus -m -d /var/lib/prometheus -s /sbin/nologin prometheus

8.解压包

$ cd /usr/local/
tar -zxvf  node_exporter-0.18.1.linux-amd64.tar
mv node_exporter-0.18.1.linux-amd64 node_exporter

9.创建systemctl启动文件

[root@localhost local]# cat /usr/lib/systemd/system/node_exporter.service 
[Unit]
Description=node_export
Documentation=https://github.com/prometheus/node_exporter
After=network.target
 
[Service]
Type=simple
User=prometheus
ExecStart=/usr/local/node_exporter/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target

10启动node_export

systemctl daemon-reload
systemctl start node_exporter
systemctl enable node_exporter

11去Prometheus Server端修改配置文件,将agent端加入到主节点中

- job_name: 'jp-test'
    scrape_interval: 5s
    static_configs:
    - targets: ['192.168.2.70:9100','192.168.2.71:9100','192.168.2.72:9100','192.168.2.73:9100']
  - job_name: '50-mysql'
    scrape_interval: 5s
    static_configs:
    - targets: ['192.168.2.50:9104']

加入以上,保存配置文件

12重启prometheus

systemctl restart prometheus

13部署grafana

yum install https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.4.3-1.x86_64.rpm

14 启动grafana

systemctl start grafana-server
systemctl enable grafana-server

15 访问浏览器:

192.168.2.79:3000即可打开页面 重置密码 进入后选择data sources 设置prometheus 地址选择localhost:9090 导入自带的模板即可

学习更多教程

在这里插入图片描述

下载地址

下载地址

<think>嗯,用户想在CentOS 7.6部署Box服务或应用,我需要先理清步骤。首先,可能得确认Box的具体类型,比如是文件存储服务还是其他应用。假设是常见的文件共享服务,可能需要安装依赖、下载软件包、配置环境,然后启动服务。 接下来,我应该考虑系统准备,比如更新系统、安装必要的工具,如wget或yum-utils。用户之前提到过使用yum安装Docker,可能可以参考类似的方法。可能需要添加特定的软件源,或者直接从官网下载安装包。 然后,安装Box服务可能需要下载官方提供的RPM包或者源码编译。如果是通过yum安装,可能需要配置第三方仓库,比如添加Box的repo文件。如果官网没有提供,可能需要手动下载并安装。 配置部分可能需要编辑配置文件,设置端口、用户权限、存储路径等。防火墙设置也很重要,CentOS 7用的是firewalld,需要开放相应端口,比如80或443,或者自定义端口。SELinux可能会影响服务运行,可能需要调整策略或关闭。 启动服务后,确保开机自启,用systemctl enable。测试部署是否成功,可以通过curl访问本地端口,或者查看服务状态日志。 另外,用户提供的引用里有关于Docker安装的步骤,如果Box有Docker镜像的话,可能用Docker部署会更方便,比如拉取镜像、运行容器,挂载卷等。但用户可能更倾向于直接安装,所以需要两种方法都考虑。 最后,生成相关问题,比如优化性能、配置SSL,或者备份策略。需要确保每个步骤都清晰,用户容易跟随,避免遗漏关键步骤,比如依赖安装或防火墙设置。</think>### 在 CentOS 7.6部署 Box 服务的步骤指南 #### 1. 系统环境准备 - **更新系统** 确保系统组件为最新版本: ```bash sudo yum update -y ``` - **安装必要工具** 安装依赖工具(如`wget`、`curl`等): ```bash sudo yum install -y wget curl epel-release ``` #### 2. 安装 Box 服务 假设部署的是类似“FileCloud”或“Nextcloud”的类 Box 文件存储服务,以 **Nextcloud** 为例: - **安装 PHP 和数据库** Nextcloud 依赖 PHP 和数据库(如 MariaDB): ```bash sudo yum install -y httpd mariadb-server mariadb php php-mysqlnd php-gd php-json php-mbstring php-xml php-zip ``` - **启动服务并设置开机自启** ```bash sudo systemctl start httpd mariadb sudo systemctl enable httpd mariadb ``` - **配置数据库** 初始化 MariaDB 并创建数据库: ```bash sudo mysql_secure_installation mysql -u root -p # 执行 SQL 命令 CREATE DATABASE nextcloud; CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost'; FLUSH PRIVILEGES; ``` #### 3. 下载并配置 Nextcloud - **下载安装包** ```bash wget https://download.nextcloud.com/server/releases/latest.zip sudo unzip latest.zip -d /var/www/html/ sudo chown -R apache:apache /var/www/html/nextcloud ``` - **配置 Apache** 编辑配置文件 `/etc/httpd/conf.d/nextcloud.conf`: ```apache <VirtualHost *:80> DocumentRoot /var/www/html/nextcloud ServerName your_domain.com <Directory /var/www/html/nextcloud> Require all granted AllowOverride All </Directory> </VirtualHost> ``` - **重启 Apache** ```bash sudo systemctl restart httpd ``` #### 4. 防火墙与 SELinux 配置 - **开放 HTTP/HTTPS 端口** ```bash sudo firewall-cmd --permanent --add-service=http --add-service=https sudo firewall-cmd --reload ``` - **调整 SELinux 策略** 若遇到权限问题,临时关闭 SELinux 或设置规则: ```bash sudo setenforce 0 # 临时关闭 # 或永久修改 /etc/selinux/config 中 SELINUX=permissive ``` #### 5. 完成安装 通过浏览器访问 `http://your_server_ip`,按向导完成 Nextcloud 的初始化配置(填写数据库信息和管理员账户)[^2]。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值