设置主机名
hostnamectl set-hostname prome-master01 采用公有云服务器 172.16.58.78 prome-master01 172.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: yes NTP synchronized: yes RTC in local TZ: no DST active: n/a timedatectl set-timezone Asia/Shanghai
关闭防火墙 Selinux
systemctl stop firewalld systemctl disable firewalld systemctl status firewalld setenforce 0 sed -i '/^SELINUX/s/enforcing/disabled/' /etc/selinux/config getenforce
关闭sshd dns反解
sed -i 's/^#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config systemctl 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.repo yum makecache
安装常用命令
yum -y install lrzsz yum-utils
创建数据目录
# 安装包目录 mkdir -pv /opt/tgzs # 程序目录 mkdir -pv /opt/app
设置history文件ulimint
cat <<EOF >> /etc/profile export HISTFILESIZE= export HISTSIZE= EOF source /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 ~/.pip cat<< EOF > ~/.pip/pip.conf [global] index-url=http://mirrors.aliyun.com/pypi/simple/ [install] trusted-host=mirrors.aliyun.com EOF
下载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_exporter wget -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 # alertmanager wget -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 # pushgateway wget -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-exporter wget -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_exporter wget -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_exporter wget -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_exporter wget -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