puppetdb的搭建
依赖软件:
*nix server with JDK 1.7+ (Debian) or JDK 1.8+ (RHEL-derived)
Puppet 4.0.0
PostgreSQL 9.4
puppetserver安装:
1、所有节点时间同步
2、准备yum源(CentOS7)
rpm -Uvh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
3、安装puppet sever
yum install puppetserver
4、启动puppet server
systemctl start puppetserver
5、分配内存:
*编辑配置文,添加:vim /etc/sysconfig/puppetserver
# Modify this if you'd like to change the memory allocation, enable JMX, etc
JAVA_ARGS="-Xms2g -Xmx2g"
*重新启动puppet server
systemctl restart puppetserver
puppetdb安装:
1、安装PostgreSQL(9.4)
yum install postgresql postgresql-contrib postgresql-server postgresql-devel
2、初始化postgresql
postgresql-setup initdb
3、启动postgresql
systemctl start postgresql
systemctl enable postgresql
4、配置PostgreSQL
4.1创建用户,此用户是用于运行postgresql
useradd postgres
4.2创建postgresql数据库用户 和puppet库
sudo -u postgres sh
createuser -DRSP puppetdb
createdb -E UTF8 -O puppetdb puppetdb(-O 指定用户)
4.3修改postgresql配置文件:pg_hba.conf
# TYPE DATABASE USER CIDR-ADDRESS METHOD
local all all md5
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
4.4 重启postgresql
service postgresql restart
psql -h localhost puppetdb puppetdb
5、按puppetdb
yum install puppetdb puppetdb-termini -y
6、配置puppet: vim /etc/puppetlabs/puppetdb/conf.d/database.ini
[database]
#classname = org.postgresql.Driver
#subprotocol = postgresql
# The database address, i.e. //HOST:PORT/DATABASE_NAME
# subname = //localhost:5432/puppetdb
subname = //localhost:5432/puppetdb
# Connect as a specific user
# username = foobar
username = puppetdb
# Use a specific password
# password = foobar
password = puppetdb
# How often (in minutes) to compact the database
# gc-interval = 60
# Number of seconds before any SQL query is considered 'slow'; offending
# queries will not be interrupted, but will be logged at the WARN log level.
log-slow-statements = 10
7、启动puppetdb:puppetdb监听在8081、8080端口
systemctl start puppetdb
systemctl enable puppetdb
ss -tpnl | grep 8081
8、配置puppetdb与puppetserver链接
8.1 编辑puppetdb配置文件,添加以下信息,路径/etc/puppetlabs/puppet/puppetdb.conf,此文件默认不存在,需要手动创建
[main]
server_urls = https://node1.linux.com:8081
8.2 编辑puppetserver配置文件,路径/etc/puppetlabs/puppet/puppet.conf,添加以下信息:
[master]
storeconfigs = true
storeconfigs_backend = puppetdb
reports = store,puppetdb
8.3 配置routes.yaml
puppet master --configprint route_file ;查找配置文件存储位置,此文件默认不存在,需要创建
添加以下信息:
---
master:
facts:
terminus: puppetdb
cache: yaml
8.4更改routers.yaml权限,需要属组属主为puppet
chown puppet.puppet routes.yaml
8.5 如果puppetdb与puppetserver部署在不通的设备上,需要放行8081端口
firewall-cmd --add --zone=public --port=8081/tcp --permanent
8.6 重新启动puppetserver
systemctl restart puppetserver
8.7 测试puppetserver连接puppetdb是否成功
在任何一个agent节点运行以下命令:
puppet agent --test
查看/var/log/puppetlabs/puppetdb/puppetdb.log日志,含有“replace facts”, “replace catalog”, and “store report” commands:即可
2017-03-19 11:07:31,306 INFO [p.p.command] [0-1489936043279] replace facts command processed for node2.linux.com
2017-03-19 11:07:33,932 INFO [p.p.command] [1-1489936053441] replace catalog command processed for node2.linux.com
2017-03-19 11:07:35,065 INFO [p.p.command] [2-1489936054944] store report puppet v4.9.4 command processed for node2.linux.com
转载于:https://blog.51cto.com/maxingkong/1908326