yum install puppetdb puppetdb-terminus -y
service puppetdb start
vi /etc/puppet/puppet.conf
[master]
storeconfigs = true
storeconfigs_backend = puppetdb
cat > /etc/puppet/puppetdb.conf <<EOF
[main]
server = zhoulj-test
port = 8081
soft_write_failure = false
EOF
cat > /etc/puppet/routes.yaml <<EOF
master:
facts:
terminus: puppetdb
cache: yaml
EOF
cd /etc/puppetdb/conf.d
vi jetty.ini
port = 8888
保存退出
service puppetdb restart
将puppetdb的内存加大要1G
cat /etc/sysconfig/puppetdb |grep -E '(JAVA_ARGS|Xmx)' --color
安装postgrepsql
yum install postgresql-server -y
sed -i '/^classname/ s/org.hsqldb.jdbcDriver/org.postgresql.Driver/' /etc/puppetdb/conf.d/database.ini
sed -i '/^subprotocol/ s/hsqldb/postgresql/' /etc/puppetdb/conf.d/database.ini
sed -i '/^subname/ s@= .@= //localhost:5432/puppetdb@' /etc/puppetdb/conf.d/database.ini
sed -i 's/# username =./username = puppetdb/' /etc/puppetdb/conf.d/database.ini
sed -i 's/# password =.*/password = puppetdb/' /etc/puppetdb/conf.d/database.ini
service postgresql initdb
service postgresql start
创建用户,输入密码<就是上面的密码..>..然后创建一个库
sudo -u postgres sh
createuser -DRSP puppetdb
createdb -E UTF8 -O puppetdb puppetdb
exit
如果使用PostgreSQL 9.3
sudo -u postgres sh
psql puppetdb -c 'create extension pg_trgm'
exit
vi /var/lib/pgsql/data/postgresql.conf
listen_addresses = '*'
保存
vi /var/lib/pgsql/data/pg_hba.conf
local all all md5
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
保存
service puppetdb restart
psql -h localhost puppetdb puppetdb
查询
通过facter接口:查询所有的facts
curl -X GET -k --key /etc/puppetdb/ssl/private.pem --cert /etc/puppetdb/ssl/public.pem 'https://zhoulj-test:8081/v4/facts'
通过facter接口:查询指定主机的指定facters
curl -X GET -k --key /etc/puppetdb/ssl/private.pem --cert /etc/puppetdb/ssl/public.pem -k 'https://zhoulj-test:8081/v4/facts/architecture' --data-urlencode 'query=["=", "certname", "api2"]'
通过nodes接口:查询所有主机
curl -X GET -k --key /etc/puppetdb/ssl/private.pem --cert /etc/puppetdb/ssl/public.pem -k 'https://zhoulj-test:8081/v4/nodes'
http://172.16.54.209:8888/dashboard/index.html