安装foreman

来源:互联网 发布:pdm导入oracle数据库 编辑:程序博客网 时间:2024/06/05 05:03
CentOS 6.4
foreman概述
Foreman是一个集成的数据中心生命周期管理工具,提供了服务开通,配置管理以及报告 功能,和Puppet Dahboard一样,Foreman也是一个Ruby on Rails程序.Foreman和 Dashboard不同的地方是在于,Foreman更多的关注服务开通和管理数据中心的能力,例如和引导工具,PXE启动服务器,DHCP服务器及服务 器开通工具进行集成.

第一步:在Rhel/Centos上添加SCL的软件仓库。
# cd /etc/yum.repos.d/
wget http://people.redhat.com/bkabrda/scl_ruby193.repo
[scl_ruby193]
name=Ruby 1.9.3 Dynamic Software Collection
baseurl=http://people.redhat.com/bkabrda/ruby193-rhel-6/
failovermethod=priority
enabled=1
gpgcheck=0

第二步:添加在epel上有可用的源。
# yum localinstall -y http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm


第二步:然后安装Development tools
yum groupinstall "Development Tools" "Development Libraries"
yum -y install gcc-c++ git ruby193 ruby193-devel ruby193gems \
    libvirt-devel mysql-devel postgresql-devel mysql mysql-server\
    libxml2-devel sqlite-devel libxslt-devel zlib-devel \
    readline-devel tar openssl-devel
验证:
yum-config-manager --enable rhel-6-server-optional-rpms rhel-server-rhscl-6-rpms



第七步:在 .bashrc 添加如下内容,设置ruby193的PATH,以确保我们登陆的时候scl环境加载好了。
# vim .bashrc
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
LD_LIBRARY_PATH=/opt/rh/ruby193/root/usr/lib64:
PATH=/opt/rh/ruby193/root/usr/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/git/bin
export PATH
export LD_LIBRARY_PATH
//设置环境变量。
#source .bashrc

验证一下,确认ruby193路径和版本是不是对的。
[git@gitlab ~]$ which ruby
/opt/rh/ruby193/root/usr/bin/ruby
[git@gitlab ~]$ ruby --version
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]


第五步:添加git用户。
# adduser git

:将rubygems源改成淘宝源,用taobao的源更快,而且不会因为防火墙不能安装。
$ gem sources --remove https://rubygems.org/
$ gem sources -a https://ruby.taobao.org/
$ gem sources -l
*** CURRENT SOURCES ***
https://ruby.taobao.org
// 请确保只有 ruby.taobao.org
$ gem install rails

第三步:下载安装foreman    
foreman 要求运行在下面的软件之上
    Ruby 1.8.7 or 1.9
    rubygems
    Puppet >= 0.24.4
$ git clone https://github.com/theforeman/foreman.git -b 1.5-stable
$ cd foreman
$ cp config/settings.yaml.example config/settings.yaml
$ cp config/database.yml.example config/database.yml
安装最近的开发代码:foreman己经用rails 3和bundler来启运和运行,如果你想用最新的版本,使用最新的功能,这是最优先的办法来获取foreman.用git仓库,你也可以更新得更轻松,你将需要手动安装bundler。
Foreman will run with the following requirements (aside from rubygem dependencies):
$ gem install bundler
$ gem install rake
$ gem install mysql2
//添加下面内容到Gemfile
gem ‘mysql2′” to my Gemfile
$ bundle update

//修改config/database.yaml,添加如下模块。
production:
  adapter: mysql2     ---注意是mysql2
  database: foreman_db
  username: foreman
  password: 1234
  host: localhost
  socket: "/var/run/mysqld/mysqld.sock"

 
 : 创建foreman_db数据库,foreman用户。
# su - root
# service mysql start
//登录MYSQL
@>mysql -u root -p
@>密码
//创建用户
mysql> insert into mysql.user(Host,User,Password) values("localhost","foreman",password("1234"));
//刷新系统权限表
mysql>flush privileges;
//这样就创建了一个名为:foreman  密码为:1234  的用户。
mysql>exit;
//然后登录一下。
@>mysql -u foreman -p
@>输入密码
mysql>登录成功
//为用户授权。
登录MYSQL(有ROOT权限)。我里我以ROOT身份登录.
@>mysql -u root -p
@>密码
//首先为用户创建一个数据库(foreman_db)
mysql>create database foreman_db;
//授权phplamp用户拥有foreman_db数据库的所有权限。
>grant all privileges on foreman_db.* to foreman@localhost identified by '1234';
//刷新系统权限表
mysql>flush privileges;
mysql>其它操作

# su - git
// 尝试用mysql数据库来配制
bundle install --path vendor #
//  建立数据库模试,预编译资产和地区。
RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=production bundle exec rake db:seed assets:precompile locale:pack

You can run Foreman with the command "./script/rails s -e production"

This manual will recommend foreman-rake <task> to run rake tasks, however when installed from source, replace this with bundle exec rake <task> RAILS_ENV=production
CLI (Hammer)


config/settings.yaml file

To install hammer from git checkouts, you will just need rake installed on your system. Clone and install CLI core
第四步:下截安装hammer cli
$ git clone https://github.com/theforeman/hammer-cli.git
$ cd hammer-cli
$ rake install
$ cd ..

and clone plugin with foreman commands

$ git clone https://github.com/theforeman/hammer-cli-foreman.git
$ cd hammer-cli-foreman
$ rake install
$ cd ..
gem install bundler



初始化数据库模式和内容,运行:
rake db:migrate
rake db:seed
RAILS_ENV=production rails server

./script/rails s -e production
http://foreman:3000
0 0
原创粉丝点击