设置主机名
hostnamectl set-hostname prome-master01采用公有云服务器172.16.58.78 prome-master01172.16.58.79 prome-node01
设置时区
timedatectl[root@prometheus_master01 ~]# timedatectl Local time: 六 2021-03-27 22:39:41 CST Universal time: 六 2021-03-27 14:39:41 UTC RTC time: 六 2021-03-27 14:39:41 Time zone: Asia/Shanghai (CST, +0800) NTP enabled: yesNTP synchronized: yes RTC in local TZ: no DST active: n/atimedatectl set-timezone Asia/Shanghai
关闭防火墙 Selinux
systemctl stop firewalldsystemctl disable firewalldsystemctl status firewalldsetenforce 0sed -i '/^SELINUX/s/enforcing/disabled/' /etc/selinux/configgetenforce
关闭sshd dns反解
sed -i 's/^#UseDNS yes/UseDNS no/' /etc/ssh/sshd_configsystemctl restart sshd
设置国内yum源
mkdir /tmp/yum_repo_bk/bin/mv -f /etc/yum.repos.d/* /tmp/yum_repo_bk# 阿里云源wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo# epel源wget -O /etc/yum.repos.d/epel-7.repo https://mirrors.aliyun.com/repo/epel-7.repoyum makecache
安装常用命令
yum -y install lrzsz yum-utils
创建数据目录
# 安装包目录mkdir -pv /opt/tgzs# 程序目录mkdir -pv /opt/app
设置history文件ulimint
cat <<EOF >> /etc/profileexport HISTFILESIZE=export HISTSIZE=EOFsource /etc/profile
设置pip
# windows %APPDATA%\pip\pip.conf 先在 windows “文件资源管理器” 地址栏 输入 %APPDATA% 按回车,打开程序自定义设置文件夹然后,创建名为 pip 的文件夹,用于存放 pip 配置文件[global]index-url=http://mirrors.aliyun.com/pypi/simple/[install]trusted-host=mirrors.aliyun.com# linux mkdir -pv ~/.pipcat<< EOF > ~/.pip/pip.conf [global]index-url=http://mirrors.aliyun.com/pypi/simple/[install]trusted-host=mirrors.aliyun.comEOF
下载prometheus最新版本包
# 地址# https://github.com/prometheus/prometheus/releases/tag/v2.25.2# prometheus wget -O /opt/tgzs/prometheus-2.25.2.linux-amd64.tar.gz https://github.com/prometheus/prometheus/releases/download/v2.25.2/prometheus-2.25.2.linux-amd64.tar.gz# node_exporterwget -O /opt/tgzs/node_exporter-1.1.2.linux-amd64.tar.gz https://github.com/prometheus/node_exporter/releases/download/v1.1.2/node_exporter-1.1.2.linux-amd64.tar.gz# alertmanagerwget -O /opt/tgzs/alertmanager-0.21.0.linux-amd64.tar.gz https://github.com/prometheus/alertmanager/releases/download/v0.21.0/alertmanager-0.21.0.linux-amd64.tar.gz# pushgatewaywget -O /opt/tgzs/pushgateway-1.4.0.linux-amd64.tar.gz https://github.com/prometheus/pushgateway/releases/download/v1.4.0/pushgateway-1.4.0.linux-amd64.tar.gz# process-exporterwget -O /opt/tgzs/process-exporter-0.7.5.linux-amd64.tar.gz https://github.com/ncabatoff/process-exporter/releases/download/v0.7.5/process-exporter-0.7.5.linux-amd64.tar.gz# blackbox_exporterwget -O /opt/tgzs/blackbox_exporter-0.18.0.linux-amd64.tar.gz https://github.com/prometheus/blackbox_exporter/releases/download/v0.18.0/blackbox_exporter-0.18.0.linux-amd64.tar.gz# redis_exporterwget -O /opt/tgzs/redis_exporter-v1.20.0.linux-amd64.tar.gz https://github.com/oliver006/redis_exporter/releases/download/v1.20.0/redis_exporter-v1.20.0.linux-amd64.tar.gz# mysql_exporterwget -O /opt/tgzs/mysqld_exporter-0.12.1.linux-amd64.tar.gz https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz