部署PaaS应用(Part1)WordPress & Jenkins Server "部署PaaS应用(Part1)WordPress & Jenkins Server" 下周开始练习PaaS应用部署,这是第一部分。 先电的云计算开发服务平台用户手册-Cloud-paas-v1.2.pdf先后逻辑顺序混乱、错误很多,只看他的文字介绍就可以了。操作步骤需要看我写的文档。 1、基础环境准备 (1)首先应搭建好IaaS基本系统,启动两台云主机,并按照“PaaS基础平台配置.docx”在云主机上安装PaaS基础平台。 (2)编辑安全组default的规则,确保已放行到云主机的所有数据流量。 (3)编辑Windows的DNS服务器配置,删除所有公网DNS服务器,只使用paas节点的DNS服务器192.168.200.101。 (4)使用域名paas.example.com能够访问到Openshift平台。 (5)在控制节点使用与Dashboard中相同的用户新建Git Server云主机,云主机使用固定的IP地址192.168.200.200。 [iyunv@controller ~]# . user1-openrc.sh [iyunv@controller ~]# nova flavor-list +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+ | ID | Name | Memory_MB | Disk | Ephemeral | Swap |VCPUs | RXTX_Factor | Is_Public | +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+ | 1 | m1.tiny | 512 | 1 | 0 | | 1 | 1.0 | True | | 2 | m1.small | 2048 | 20 | 0 | | 1 | 1.0 | True | | 3 | m1.medium | 4096 | 40 | 0 | | 2 | 1.0 | True | | 4 | m1.large | 8192 | 80 | 0 | | 4 | 1.0 | True | | 5 | m1.xlarge | 16384 | 160 | 0 | | 8 | 1.0 | True | | 6 | paas | 2048 | 50 | 0 | | 1 | 1.0 | True | +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+ [iyunv@controller ~]# nova image-list +--------------------------------------+-------------------+--------+--------+ | ID | Name | Status | Server | +--------------------------------------+-------------------+--------+--------+ | 1014d11f-a36b-49f4-b90f-d56ca21d380b| CentOS-6.5-x86_64 | ACTIVE | | +--------------------------------------+-------------------+--------+--------+ [iyunv@controller ~]# neutron net-list +--------------------------------------+----------+-------------------------------------------------------+ | id | name | subnets | +--------------------------------------+----------+-------------------------------------------------------+ | 02055209-408d-4ecb-a5b6-635138ace958| flat-net | 4cbd55d6-6ca1-491c-ade0-f6bd8526218e 192.168.200.0/24 | +--------------------------------------+----------+-------------------------------------------------------+ [iyunv@controller ~]# nova help boot usage: nova boot[--flavor <flavor>] [--image <image>] [--image-with<key=value>] [--boot-volume <volume_id>] [--snapshot<snapshot_id>] [--num-instances <number>] [--meta <key=value>][--file <dst-path=src-path>] [--key-name <key-name>][--user-data <user-data>] [--availability-zone<availability-zone>] [--security-groups<security-groups>] [--block-device-mapping<dev-name=mapping>] [--block-device key1=value1[,key2=value2...]] [--swap <swap_size>] [--ephemeralsize=<size>[,format=<format>]] [--hint <key=value>] [--nic<net-id=net-uuid,v4-fixed-ip=ip-addr,port-id=port-uuid>] [--config-drive <value>][--poll] <name> Boot a new server. Positional arguments: <name> Namefor the new server Optional arguments: --flavor <flavor> Name or ID of flavor (see 'nova flavor-list'). --image <image> Name or ID of image (see 'novaimage-list'). --nic <net-id=net-uuid,v4-fixed-ip=ip-addr,port-id=port-uuid> Create a NIC on theserver. Specify option multiple times to create multipleNICs. net-id: attach NIC to network with this UUID(required if no port-id), v4 -fixed-ip: IPv4 fixedaddress for NIC (optional), port-id: attach NIC toport with this UUID (required if no net-id) [iyunv@controller~]# nova boot --flavor paas --imageCentOS-6.5-x86_64 --nicnet-id=02055209-408d-4ecb-a5b6-635138ace958,v4-fixed-ip=192.168.200.200codeserver [iyunv@controller ~]# nova list +--------------------------------------+------------+--------+------------+-------------+--------------------------+ | ID | Name | Status | Task State | Power State |Networks | +--------------------------------------+------------+--------+------------+-------------+--------------------------+ | 6c86a8e3-3741-45e6-bcf3-e7b850031880 |codeserver | ACTIVE | - |Running | flat-net=192.168.200.200 | | c3790eb6-73ee-4f62-bd54-c47a9163844b |node | ACTIVE | - | Running | flat-net=192.168.200.102 | | f9f24048-8c00-4a40-ae02-47a51be804fc |paas | ACTIVE | - | Running | flat-net=192.168.200.101 | +--------------------------------------+------------+--------+------------+-------------+--------------------------+ 2、搭建本地Git Server 新创建的codeserver云主机有多种作用:Git Server、HTTP Server、RHC Client等。 (1)配置主机名,重启生效。 [iyunv@host-192-168-200-200 ~]# vi/etc/sysconfig/network NETWORKING=yes HOSTNAME=codeserver NOZEROCONF=yes [iyunv@host-192-168-200-200 ~]# shutdown -rnow (2)配置YUM 这里预先在控制节点通过编辑/etc/fstab,将先电PaaS v1.2的光盘ISO挂载到了/var/ftp/openshift中。 [iyunv@codeserver ~]# cd /etc/yum.repos.d/ [iyunv@codeserver yum.repos.d]# rm -f * [iyunv@codeserver yum.repos.d]# vi ftp.repo [openshift-base] name=openshift-base baseurl=ftp://192.168.200.10/openshift/openshift-base gpgcheck=0 [openshift-epel] name=Extra Packages for Enterprise Linux 6- $basearch baseurl=ftp://192.168.200.10/openshift/openshift-epel exclude=*passenger* nodejs* failovermethod=priority gpgcheck=0 [openshift-origin] name=openshift-origin baseurl=ftp://192.168.200.10/openshift/openshift-origin/ gpgcheck=0 [openshift-origin-deps] name=openshift-origin-deps baseurl=ftp://192.168.200.10/openshift/openshift-origin-dependencies/ gpgcheck=0 [iyunv@codeserver yum.repos.d]# yum cleanall [iyunv@codeserver yum.repos.d]# yummakecache (3)安装Git Server [iyunv@codeserver ~]# yum install git (4)在Node节点上产生RSA密钥对,不使用密码保护密钥对 [iyunv@node ~]# ssh-keygen (5)在Node节点上将自己的公钥传到Git Server,添加到信任SSH站点 [iyunv@node ~]# cd /root/.ssh The authenticity of host '192.168.200.200(192.168.200.200)' can't be established. RSA key fingerprint is90:b6:9e:d0:3e:76:27:ce:34:3b:d6:b4:41:5d:e7:31. Are you sure you want to continueconnecting (yes/no)? yes Warning: Permanently added'192.168.200.200' (RSA) to the list of known hosts. root@192.168.200.200's password: # 输入云主机Git Server的密码000000 id_rsa.pub 100% 391 0.4KB/s 00:00 (6)验证SSH公钥登录 Last login: Sun May 24 02:50:04 2015 from192.168.200.1 [iyunv@codeserver ~]# exit logout Connection to 192.168.200.200 closed. [iyunv@node .ssh]# 3、搭建WordPress博客系统 (1)在Git Server上配置WordPress本地代码源 [iyunv@codeserver ~]# cd [iyunv@codeserver ~]# mkdir gitlocal 使用SFTP将PaaS光盘中paas-xiandan目录中的wordpress-example.tar.gz传到Git Server的/root/gitlocal目录中。 [iyunv@codeserver ~]# cd gitlocal/ [iyunv@codeserver gitlocal]# ls wordpress-example.tar.gz [iyunv@codeserver gitlocal]# tar -zxfwordpress-example.tar.gz [iyunv@codeserver gitlocal]# ls wordpress-example wordpress-example.tar.gz [iyunv@codeserver gitlocal]# git clone--bare wordpress-example wordpress-example.git Initialized empty Git repository in/root/gitlocal/wordpress-example.git/ [iyunv@codeserver gitlocal]# ls wordpress-example wordpress-example.git wordpress-example.tar.gz (2)在Node节点上git clone wordpress-example.git Initialized empty Git repository in/root/wordpress-example/.git/ remote: Counting objects: 4373, done. remote: Compressing objects: 100%(2528/2528), done. remote: Total 4373 (delta 1756), reused4373 (delta 1756) Receiving objects: 100% (4373/4373), 13.12MiB | 21.62 MiB/s, done. Resolving deltas: 100% (1756/1756), done. [iyunv@node ~]# ls anaconda-ks.cfg install.log install.log.syslog wordpress-example (3)在Git Server上安装Web服务器 [iyunv@codeserver gitlocal]# yum installhttpd [iyunv@codeserver gitlocal]# service httpdstart [iyunv@codeserver gitlocal]# chkconfig httpdon (4)使用SFTP将PaaS光盘中paas-xiandan目录中的wordpress-3.9.1.tar.gz 和wordpress-3.9.1.tar.gz.md5复制到Git Server的/var/www/html目录中。在通过Openshift部署WordPress时,需要到这里下载安装文件。 [iyunv@codeserver gitlocal]# cd/var/www/html/ [iyunv@codeserver html]# ls wordpress-3.9.1.tar.gz wordpress-3.9.1.tar.gz.md5 (5)在Node节点上修改wordpress-example.git 源的安装脚本 [iyunv@node ~]# cd [iyunv@node ~]# cd wordpress-example/ [iyunv@node wordpress-example]# ls -a . .. .git .gitignore libs misc .openshift php README README.md [iyunv@node wordpress-example]# cd.openshift/action_hooks/ [iyunv@node action_hooks]# vi build 将以下两处下载地址“http://wordpress.org/”修改为Git Server的IP地址192.168.200.200。 (6)使用git commit -a提交更新,在自动弹出的vi编辑器中输入本次修改的注释信息,保存,git才会提交更新。 [iyunv@node action_hooks]# git commit -a Modified HTTP ServerAddress # Please enter the commit message for yourchanges. Lines starting # with '#' will be ignored, and an emptymessage aborts the commit. # # # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: build # ".git/COMMIT_EDITMSG"12L, 328C written [master 017528f] Modified HTTP ServerAddress Your name and email address were configuredautomatically based on your username and hostname. Please checkthat they are accurate. You can suppress this message by settingthem explicitly: git config --global user.name "Your Name" If the identity used for this commit iswrong, you can fix it with: 1 files changed, 2 insertions(+), 2deletions(-) (7)使用git push推送修改到Git Server [iyunv@node action_hooks]# git push Counting objects: 9, done. Compressing objects: 100% (5/5), done. Writing objects: 100% (5/5), 537 bytes,done. Total 5 (delta 3), reused 0 (delta 0) Toroot@192.168.200.200:/root/gitlocal/wordpress-example.git dc16552..017528f master ->master (8)使用浏览器打开paas.example.com,在设置标签填写Namespace,点击Save保存。 以下为创建好的域名sdcet。 (9)在应用标签创建新应用,点击WordPress。 (10)随意填写公共URL,在源代码处填写GitServer的本地源root@192.168.200.200:/root/gitlocal/wordpress-example.git,点击CreateApplication。 (11)点击“现在不用,继续”。 (12)显示相关数据库的账号和密码。 (13)在新的标签页打开wordpress-sdcet.example.com,出现WordPress安装向导。 (14)填写站点名称、用户名、密码和邮箱地址,点击Install WordPress。 (15)安装完成,点击Log In。 (16)提示证书问题,选择继续访问。输入刚创建的用户名和密码,点击Log In。 (17)以下为WordPress的Dashboard。可以点击中间的“Write your first blog post”发布第一篇博客。 (18)编辑博客内容,编辑完后点击右侧的Publish发布博客。 (19)点击上方的View post查看发布的博客。 (20)以下为普通用户查看到的博客内容。 4、在Git Server上部署RHC工具 RHC是OpenShift 的应用管理工具,可以用于查看在Openshift上部署的应用列表等功能。 (1)在Git Server上编辑/etc/hosts,将paas.example.com解析为paas节点的IP地址。 [iyunv@codeserver ~]# vi /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.200.101 paas.example.com (2)在Git Server上安装Gem 工具 [iyunv@codeserver ~]# yum install rubygems (3)使用SFTP将PaaS光盘中的rhc目录复制到Git Server的/root目录中。 [iyunv@codeserver ~]# cd rhc [iyunv@codeserver rhc]# ls archive-tar-minitar-0.5.2.gem highline-1.6.21.gem net-scp-1.2.1.gem net-ssh-gateway-1.2.0.gem open4-1.3.4.gem commander-4.2.1.gem httpclient-2.5.3.3.gem net-ssh-2.9.1.gem net-ssh-multi-1.2.0.gem rhc-1.32.2.gem (4)安装RHC 工具 [iyunv@codeserver rhc]# gem install --local rhc-1.32.2.gem =========================================================================== If this is your firsttime installing the RHC tools, please run 'rhc setup' =========================================================================== Successfully installed net-ssh-2.9.1 Successfully installed net-scp-1.2.1 Successfully installednet-ssh-gateway-1.2.0 Successfully installed net-ssh-multi-1.2.0 Successfully installedarchive-tar-minitar-0.5.2 Successfully installed highline-1.6.21 Successfully installed commander-4.2.1 Successfully installed httpclient-2.5.3.3 Successfully installed open4-1.3.4 Successfully installed rhc-1.32.2 10 gems installed Installing ri documentation fornet-ssh-2.9.1... Installing ri documentation fornet-scp-1.2.1... Installing ri documentation fornet-ssh-gateway-1.2.0... Installing ri documentation fornet-ssh-multi-1.2.0... Installing ri documentation forarchive-tar-minitar-0.5.2... Installing ri documentation forhighline-1.6.21... Installing ri documentation forcommander-4.2.1... Installing ri documentation forhttpclient-2.5.3.3... RDoc failure in lib/httpclient.rb at oraround line 432 column 16 Before reporting this, could you check thatthe file you're documenting compiles cleanly--RDocis not a full Ruby parser, and gets confused easilyif fed invalid programs. The internal error was: ERROR: While executing gem ... (NoMethodError) undefined method`name' for #<RubyToken::TkLPAREN:0x7f63177bbf98> (5)配置RHC [iyunv@codeserver rhc]# rhc setup --server=paas.example.com OpenShift Client Tools (RHC) Setup Wizard This wizard will help you upload your SSHkeys, set your application namespace, and check that other programs like Gitare properly installed. The server's certificate is self-signed,which means that a secure connection can't be established to'paas.example.com'. You may bypass this check, but any data yousend to the server could be intercepted by others. Connect without checkingthe certificate? (yes|no): yes Login to paas.example.com: admin Password: ****** OpenShift can create and store a token ondisk which allows to you to access the server without using your password. Thekey is stored in your home directory and should bekept secret. You can delete the key atany time by running 'rhc logout'. Generate a token now? (yes|no) yes Generating an authorization token for this client... lasts about 1 day Saving configuration to/root/.openshift/express.conf ... done No SSH keys were found. We will generate apair of keys for you. Created: /root/.ssh/id_rsa.pub Your public SSH key mustbe uploaded to the OpenShift server to access code. Upload now? (yes|no) yes Since you do not have any keys associatedwith your OpenShift account, your new key will be uploaded as the 'default'key. Uploading key 'default' ... done Checking for git ... found git version1.7.1 Checking common problems . An SSH connection could not be establishedto wordpress-sdcet.example.com. Your SSH configuration may not be correct, orthe application may not be responding.getaddrinfo: Name or service not known (SocketError) Checking for a domain ...sdcet Checking for applications... found 1 Youare using 1 of 100 total gears Thefollowing gear sizes are available to you: small Your client tools are nowconfigured. (6)继续安装RHC 工具 [iyunv@codeserver rhc]# gem install --local rhc-1.32.2.gem =========================================================================== If this is your first time installing theRHC tools, please run 'rhc setup' =========================================================================== Successfully installed rhc-1.32.2 1 gem installed Installing ri documentation forrhc-1.32.2... Installing RDoc documentation forrhc-1.32.2... (7)查看已经在Openshift上部署的应用列表。 [iyunv@codeserver rhc]# rhc apps -------------------------------------------------------------------------------- Domain: sdcet Created: 3:59 AM Gears: 1 (defaults tosmall) GitURL: ssh://556184d513db8c8ab2000002@wordpress-sdcet.example.com/~/git/wordpress.git/ Initial Git URL:root@192.168.200.200:/root/gitlocal/wordpress-example.git Deployment: auto (on gitpush) php-5.3 (PHP 5.3) ----------------- Gears: Located with mysql-5.1 mysql-5.1 (MySQL 5.1) --------------------- Gears: Located withphp-5.3 Connection URL: mysql://$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/ Database Name: wordpress Password: CEvH7NpRWwD7 Username: admins71v8Us You have access to 1 application. 5、增加Jenkins Server应用 (1)在应用标签创建新应用,点击Jenkins Server。不需要配置Git源代码服务器,直接点击Create Application。 (2)添加完成后,选择“现在不用,继续”,记下登录用户名和密码。 (3)点击jenkins-sdcet.example.com,输入用户名和密码。 (4)登陆成功。 (5)现在使用rhc可以看到两个Openshift应用了。 [iyunv@codeserver rhc]# rhc apps jenkins @http://jenkins-sdcet.example.com/ (uuid: 55618d7613db8cd39c000008) ---------------------------------------------------------------------------- Domain: sdcet Created: 4:36 AM Gears: 1 (defaults to small) GitURL: ssh://55618d7613db8cd39c000008@jenkins-sdcet.example.com/~/git/jenkins.git/ Deployment: auto (on git push) jenkins-1 (Jenkins Server) -------------------------- Gears: 1 small wordpress @http://wordpress-sdcet.example.com/ (uuid: 556184d513db8c8ab2000002) -------------------------------------------------------------------------------- Domain: sdcet Created: 3:59 AM Gears: 1 (defaults tosmall) GitURL: ssh://556184d513db8c8ab2000002@wordpress-sdcet.example.com/~/git/wordpress.git/ Initial Git URL:root@192.168.200.200:/root/gitlocal/wordpress-example.git Deployment: auto (on gitpush) php-5.3 (PHP 5.3) ----------------- Gears: Located with mysql-5.1 mysql-5.1 (MySQL 5.1) --------------------- Gears: Located withphp-5.3 Connection URL:mysql://$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/ Database Name: wordpress Password: CEvH7NpRWwD7 Username: admins71v8Us You have access to 2 applications. 图文详情,请查看附件。
|