puppet实现nginx反代tomcat+memcached

puppet实现nginx反代tomcat+memcached

 

1、准备六台主机,一台puppet,一台nginx反代,两台memcached,两台tomcat

192.168.1.33 puppet.test.com puppet

192.168.1.34 nginx.test.com nginx

192.168.1.35 tomcat1.test.com tomcat1

192.168.1.36 tomcat2.test.com tomcat2

192.168.1.40 memcached1.test.com memcached1

192.168.1.41 memcached2.test.com memcached2

2、puppet主机

vim /etc/hosts

hostname set-hostname puppet.test.com

vim /etc/ssh/ssh_config

//加入此条,为了在连接目标主机时不再提示“Are you sure you want to continue connecting”

ssh-keygen -t rsa -P ”

ssh-copy-id -i .ssh/id_rsa.pub root@192.168.1.33

在每台主机的root目录下创建.ssh目录

scp -p .ssh/authorized_keys .ssh/id_rsa{,.pub} nginx:/root/.ssh

scp -p .ssh/authorized_keys .ssh/id_rsa{,.pub} tomcat1:/root/.ssh

scp -p .ssh/authorized_keys .ssh/id_rsa{,.pub} tomcat2:/root/.ssh

scp -p .ssh/authorized_keys .ssh/id_rsa{,.pub} memcached1:/root/.ssh

scp -p .ssh/authorized_keys .ssh/id_rsa{,.pub} memcached2:/root/.ssh

scp -p /etc/ssh/ssh_config nginx:/etc/ssh/

scp -p /etc/ssh/ssh_config tomcat1:/etc/ssh/

scp -p /etc/ssh/ssh_config tomcat2:/etc/ssh/

scp -p /etc/ssh/ssh_config memcached1:/etc/ssh/

scp -p /etc/ssh/ssh_config memcached2:/etc/ssh/

scp /etc/hosts nginx:/etc/

scp /etc/hosts tomcat1:/etc/

scp /etc/hosts tomcat2:/etc/

scp /etc/hosts memcached1:/etc/

scp /etc/hosts memcached2:/etc/

下载facter-2.4.6-1.el7.x86_64.rpm puppet-3.8.7-1.el7.noarch.rpm puppet-server-3.8.7-1.el7.noarch.rpm

scp facter-2.4.6-1.el7.x86_64.rpm puppet-3.8.7-1.el7.noarch.rpm nginx:/root

scp facter-2.4.6-1.el7.x86_64.rpm puppet-3.8.7-1.el7.noarch.rpm tomcat1:/root

scp facter-2.4.6-1.el7.x86_64.rpm puppet-3.8.7-1.el7.noarch.rpm tomcat2:/root

scp facter-2.4.6-1.el7.x86_64.rpm puppet-3.8.7-1.el7.noarch.rpm memcached1:/root

scp facter-2.4.6-1.el7.x86_64.rpm puppet-3.8.7-1.el7.noarch.rpm memcached2:/root

yum install epel-release -y

yum install facter-2.4.6-1.el7.x86_64.rpm puppet-3.8.7-1.el7.noarch.rpm puppet-server-3.8.7-1.el7.noarch.rpm -y

vim /etc/puppet/puppet.conf

environmentpath = $confdir/environments

//服务器工作在哪个环境

puppet master –no-daemonize -v

//启动服务

ss -tln

//监听8140端口

mkdir -pv /etc/puppet/enviroments/{production,testing,development}/{manifests,modules}

mkdir -pv /etc/puppet/enviroments/{production,testing,development}/modules/{nginx,tomcat,httpd,memcached,jdk8}/{manifests,files,templates,lib,spec,tests}

  • memcached

cd /etc/puppet/enviroments/development/modules/memcached

vim manifests/init.pp

  • jdk8

cd /etc/puppet/enviroments/development/modules/jdk8

vim manifests/init.pp

vim files/java.sh

  • tomcat

/etc/puppet/environments/development

vim modules/tomcat/manifests/init.pp

vim files/server.xml

//allowLinking=”true”表示支持软链接,也就是前面的docBase中的test可以是软链接;path是定义访问路径的,docBase是在服务器上的相对路径。

vim files/tomcat-users.xml

mkdir files/test/WEB-INF/{class,lib}

vim files/test/index.jsp

下载memcached-session-manager相关包到development/modules/tomcat/files/jar中

  • httpd

cd /etc/puppet/enviroments/development/modules/httpd

vim manifests/init.pp

vim files/httpd-tomcat.conf

  • nginx

cd /etc/puppet/enviroments/development/modules/nginx

vim manifests/init.pp

vim files/ngin.conf

vim files/ilinux.conf

  • 主机清单 cd /etc/puppet/enviroments/development

vim manifests/site.pp

2、到其他主机

同步时间

hostnamectl set-hostname **.test.com

yum install facter-2.4.6-1.el7.x86_64.rpm puppet-3.8.7-1.el7.noarch.rpm

vim /etc/puppet/puppet.conf

vim /etc/puppet/auth.conf

puppet agent –no-daemonize -v -d

3、puppet主机

puppet cert list

puppet cert sign –all

//签证

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/96316

发表评论

登录后才能评论

联系我们

400-080-6560

在线咨询:点击这里给我发消息

邮件:1823388528@qq.com

工作时间:周一至周五,9:30-18:30,节假日同时也值班