1. Environmental preparedness
Os:centos 6.4
Turn off SELinux and iptables
Deployment Puppet: 1.0 Puppet 3.7 Department
Install puppet Source: http://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm
Complete Puppetmaster/agent deployment, certificate signing ...
PUPPETDB is a data warehouse that can query nodes, facter, report, catalog, resources and other information through restful HTTP.
2. Installing PUPPETDB
The following operations are performed on puppet master
The Yum install Puppetdb Puppetdb-terminus-y/etc/init.d/puppetdb start# is added in the puppet master configuration./etc/puppet/puppet.conf[ Master] Storeconfigs = True storeconfigs_backend = Puppetdb cat >/etc/puppet/puppetdb.conf <<eof[main] Serv ER = master.dbsa.cn Port = 8081 Soft_write_failure = falseeofcat >/etc/puppet/routes.yaml <<eof---Master: Facts:terminus:puppetdb cache:yamleof
View log:, Puppetdb start is slow, you have to wait patiently ...
[Email protected] puppet]# tail-f/var/log/puppetdb/puppetdb.log2014-12-03 23:46:50,620 INFO [C.p.p.command] [ 5145B424-A8A2-45C9-8859-19A6B8AFBD9F] [Replace facts] agent1.dbsa.cn2014-12-03 23:46:50,857 INFO [C.p.p.command] [ B95DBBCE-0D08-45F1-9DB6-ED1E19AAC8E7] [Replace catalog] agent1.dbsa.cn
The production database recommends increasing the PUPPETDB memory usage to around 1G.
Cat/etc/sysconfig/puppetdb |grep-e ' (java_args| XMX) '--color
3. Replace the database with PostgreSQL.
The default kahadb is suitable for 100 or so node connections
yum install postgresql-server -ysed -i '/^classname/ s/org.hsqldb.jdbcdriver/ org.postgresql.driver/' /etc/puppetdb/conf.d/database.inised -i '/^subprotocol/ s/hsqldb/ postgresql/' /etc/puppetdb/conf.d/database.ini sed -i '/^subname/ [email Protected]= .*@= //localhost:5432/[email protected] ' /etc/puppetdb/conf.d/ database.inised -i ' s/# username =.*/username = puppetdb/' /etc/puppetdb/ conf.d/database.inised -i ' s/# password =.*/password = #你的密码 #/' /etc/ puppetdb/conf.d/database.iniservice postgresql initdb/etc/init.d/postgresql start# Create user, enter password < is the password above. A. Then create a library Sudo -u postgres shcreateuser -drsp puppetdbcreatedb -e utf8 -o puppetdb puppetdbexit# If you use Postgresql 9.3sudo -u postgres shpsql puppetdb -c ' create Extension pg_trgm ' exit# changed to allow network connections using MD5 authentication sed -i '/^local/ s/ident/md5/' /var/lib/pgsql /data/pg_hba.confsed -i '/^host/ s/ident/md5/' /var/lib/pgsql/data/pg_hba.confservice postgresql restartpsql -h localhost puppetdb puppetdbservice puppetdb restart
4. Query Puppetdb
Query by https:
#通过facter接口: Query all factscurl-x get-k--key/var/lib/puppet/ssl/private_keys/$HOSTNAME. Pem--cert/var/lib/puppet/ssl/ certs/$HOSTE. Pem ' https://master.dbsa.cn:8081/v4/facts ' #通过facter接口: Queries the specified facterscurl-x GET--key/var/lib/for the specified host puppet/ssl/private_keys/$HOSTNAME. Pem--cert/var/lib/puppet/ssl/certs/$HOSTNAMem-K ' https://master.dbsa.cn:8081/ V4/facts/architecture '--data-urlencode ' query=["=", "CertName", "agent1.dbsa.cn"] ' #通过nodes接口: Query all hosts Curl-x GET--key /var/lib/puppet/ssl/private_keys/$HOSTNAME. Pem--cert/var/lib/puppet/ssl/certs/$HOSTNAMem-K ' https:// Master.dbsa.cn:8081/v4/nodes ' #更多API信息请查看: https://docs.puppetlabs.com/puppetdb/2.2/api/
This article is from the "Xiaofeng Moon" blog, make sure to keep this source http://kinda22.blog.51cto.com/2969503/1586143
"Learn Puppet with Me" 1.3 Puppet 3.7 using PUPPETDB to do the Data Warehouse