Centos7 部署PGWatch2监控环境

1.修改网络配置,并重启网络服务:

vi /etc/sysconfig/network-scropts
onboot = yes

systemctl restart network

#关闭防火墙
systemctl status firewalld
systemctl stop firewalld
systemctl disable firewalld

2.修改yum下载源:

cd   /etc/yum.repos.d
yum -y install wget
yum install bash-completion 
yum -y install lrzsz    
rm -rf    /etc/yum.repos.d/*.repo
wget  http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
yum update

3.下载安装python 3

yum -y groupinstall "Development tools"

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
yum install libffi-devel -y

wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar -xvJf  Python-3.7.0.tar.xz
mkdir /usr/local/python3
cd Python-3.7.0
yum install -y gcc
./configure --prefix=/usr/local/python3
make && make install   
ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3
python3 -V     
pip3 -V    

4.安装postgresql11.8

# Install the repository RPM:
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

yum install postgresql11
yum install postgresql-server
yum install postgresql11-libs
yum install postgresql11-contrib
yum install postgresql11-devel

/usr/pgsql-11/bin/postgresql-11-setup initdb

systemctl start postgresql-11

修改配置文件让远程计算机访问
vim /var/lib/pgsql/11/data/postgresql.conf
shared_preload_libraries = 'pg_stat_statements'
track_io_timing = on
listen_addresses = '*' 

vi  /var/lib/pgsql/10/data/pg_hba.conf
local   all             all                                     peer
host    all             all             127.0.0.1/32            trust
host    all             all             ::1/128                 trust

systemctl restart postgresql-11

安装扩展模块
yum install -y postgresql11-plpython3

6、安装docker

yum install -y yum-utils device-mapper-persistent-data lvm2

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

yum makecache fast
yum -y install docker-ce

service docker start
docker -v

配置docker源
sudo vi /etc/docker/daemon.json
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
sudo systemctl daemon-reload
sudo systemctl restart docker

7、安装并运行pgwatch2

docker run -d --name pw2 -v pg:/var/lib/postgresql -v influx:/var/lib/influxdb -v grafana:/var/lib/grafana -v pw2:/pgwatch2/persistent-config -p 8080:8080 -p 3000:3000 -e PW2_TESTDB=true cybertec/pgwatch2

8、Docker之WARNING: IPv4 forwarding is disabled. Networking will not work.(远程不了docker的服务,但是宿主机虚拟机可以访问)

vim /etc/sysctl.conf

#配置转发
net.ipv4.ip_forward=1

#重启服务,让配置生效
systemctl restart network

#查看是否成功,如果返回为“net.ipv4.ip_forward = 1”则表示成功

sysctl net.ipv4.ip_forward

重启docker服务
systemctl restart docker

你可能感兴趣的:(Centos7 部署PGWatch2监控环境)