curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
curl -L get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
rvm install ruby-1.8.7
rvm use 1.8.7
yum -y install make gcc-c++ cmake bison-devel ncurses-devel
mysql 5.0.95
wget http://ftp.kaist.ac.kr/mysql/Downloads/MySQL-5.0/mysql-5.0.95-linux-x86_64-glibc23.tar.gz
yum install -y perl-DBI
tar zxvf mysql-5.0.95-linux-x86_64-glibc23.tar.gz
mv mysql-5.0.95-linux-x86_64-glibc23 /usr/local/mysql
vi /etc/profile
export PATH=/usr/local/mysql/bin:$PATH
source /etc/profile
安装ruby-mysql-2.8.1
rpm -ivh http://ftp.kaist.ac.kr/mysql/Downloads/MySQL-5.0/MySQL-shared-5.0.95-1.glibc23.x86_64.rpm
rpm -ivh http://mirror.centos.org/centos/7/os/x86_64/Packages/compat-db-headers-4.7.25-28.el7.noarch.rpm
rpm -ivh http://mirror.centos.org/centos/7/os/x86_64/Packages/compat-db47-4.7.25-28.el7.x86_64.rpm
rpm -ivh http://mirror.centos.org/centos/6/os/x86_64/Packages/gdbm-1.8.0-39.el6.x86_64.rpm --force
rpm -ivh http://packages.psychotic.ninja/7/testing/x86_64/RPMS//compat-readline5-5.2-27.el7.psychotic.x86_64.rpm
rpm -ivh http://mirror.centos.org/centos/6/os/x86_64/Packages/ruby-libs-1.8.7.374-5.el6.x86_64.rpm --force
rpm -ivh ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/dibo2010:/buildservice/CentOS_CentOS-5/x86_64/ruby-mysql-2.8.1-9.1.x86_64.rpm
rpm -ivh http://mirror.centos.org/centos/6/os/i386/Packages/rubygem-rake-0.8.7-2.1.el6.noarch.rpm
cd /puppet/soft
wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.25.tgz
tar zxvf rubygems-1.8.25.tgz
ruby setup.rb
gem install ruby-mysql -v 2.8.1
gem install rake -v 0.8.7
gem install rails -v 3.2.15
gem install mysql
rpm -ivh ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/sttts:/puppet/CentOS_CentOS-6/noarch/puppet-dashboard-1.2.17-13.1.noarch.rpm
启动、设置mysql
vi /etc/my.cnf
[mysql]
CLIENT
port = 3306
socket = /data/mysql/mysql.sock
default-character-set=utf8
[mysqld]
server-id = 100
skip-name-resolve
GENERAL
user = mysql
default-storage-engine = InnoDB
socket = /data/mysql/mysql.sock
pid-file = /data/mysql/mysql.pid
character_set_server = utf8
表名不区分大小写
lower_case_table_names=1
不自动提交
init_connect='SET autocommit=0'
修改时区解决java写入少14小时问题
default-time-zone = '+8:00'
MyISAM
key-buffer-size = 32M
myisam-recover = FORCE,BACKUP
SAFETY
max-allowed-packet = 32M
max-connect-errors = 1000000
DATA STORAGE
datadir = /data/mysql/
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
BINARY LOGGING
log-bin = /data/mysql/mysql-bin
expire-logs-days = 14
sync-binlog = 1
CACHES AND LIMITS
tmp-table-size = 32M
max-heap-table-size = 32M
query-cache-type = 0
query-cache-size = 0
max-connections = 800
thread-cache-size = 80
open-files-limit = 1000
INNODB
innodb-flush-method = O_DIRECT
innodb-log-files-in-group = 2
innodb-log-file-size = 128M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table = 1
innodb-buffer-pool-size = 1G
LOGGING
log-error = /data/mysql/mysql-error.log
log-queries-not-using-indexes = 1
slow-query-log-file = /data/mysql/mysql-slow.log
max_prepared_stmt_count=100000
保存,退出
chown -R mysql.mysql /data/mysql
useradd mysql
mkdir -p /data/mysql
cd /usr/local/mysql/scripts
./mysql_install_db --datadir=/data/mysql --basedir=/usr/local/mysql
/usr/local/mysql/bin/mysqld_safe &
echo "/usr/local/mysql/bin/mysqld_safe &">>/etc/rc.local
修改root密码
use mysql;
UPDATE user SET Password = PASSWORD('yourpassword') WHERE user = 'root';
FLUSH PRIVILEGES;
mysql -p -e"CREATE DATABASE dashboard CHARACTER SET utf8;" &&
mysql -p -e"CREATE USER 'dashboard'@'localhost' IDENTIFIED BY 'yourpassword';" &&
mysql -p -e"GRANT ALL PRIVILEGES ON dashboard.* TO 'dashboard'@'localhost';"
修改database.yml中的db连接信息
cd /usr/share/puppet-dashboard/config
cp config/settings.yml.example config/settings.yml &&
cp config/database.yml.example config/database.yml &&
vim config/database.yml
production:
database: dashboard
username: dashboard
password: xmrbi3967968@
encoding: utf8
adapter: mysql
保存退出
ln -s /data/mysql/mysql.sock /tmp/mysql.sock
cd /usr/share/puppet-dashboard/
rake RAILS_ENV=production db:migrate
cd /usr/share/puppet-dashboard/script
./server -e production -d
------------------ruby版本不符合,先不要--------------------------------------
修改httpd
vi /etc/httpd/conf.d/passenger.conf
Listen 3000
DocumentRoot /usr/share/puppet-dashboard/public/
ErrorLog /var/log/httpd/dashboard_error.log
CustomLog /var/log/httpd/dashboard_access.log combined
AddDefaultCharset UTF-8
RailsEnv production
Options None
AllowOverride None
Order allow,deny
allow from all
关闭刚才的server
kill -9 xxx
chown apache.apache -R /usr/share/puppet-dashboard/
service httpd restart
---------------------------ruby版本不符合,先不要end--------------------------------------
修改puppet.conf
vi /etc/puppet/puppet.conf
[master]
reports = store, http
reporturl = http://172.16.54.209:3000/reports
设置时区
vi /usr/share/puppet-dashboard/config/settings.yml
time_zone: 'Asia/Shanghai'
保存,启动
cd /usr/share/puppet-dashboard/&&rake RAILS_ENV=production jobs:work &
chkconfig httpd on
service httpd restart
echo "cd /usr/share/puppet-dashboard/script&&./server -e production -d">>/etc/rc.local
echo "cd /usr/share/puppet-dashboard/&&rake RAILS_ENV=production jobs:work &">>/etc/rc.local
手工导入报告:
cd /var/www/html/puppet-dashboard-1.2.23/
rake RAILS_ENV=production reports:import #导入已经存在的报告
默认节点报告会在/var/lib/puppet/reports/ 产生,如果路径发生变化,导入报告时需要在后面加上“REPORT_DIR=report路径”,reports更改路径可在puppet.conf中设置参数“reportdir = 新路径”,这种方式不够实时。
另外:
puppet dashboard常用操作命令如下:
当puppet dashboard数据量过多的时候,需要优化数据库,可使用命令:
rake RAILS_ENV=production db:raw:optimize
清量dashborad一个月之前的数据。可以使用
rake RAILS_ENV=production reports:prune upto=1 unit=mon
备份puppet dashborad数据库,可以使用如下命令:
rake RAILS_ENV=production db:raw:dump
备份sql并输出到文件:
rake RAILS_ENV=production FILE=/my/backup/file.sql db:raw:dump
恢复puppet dashboard数据库,可以使用如下命令:
rake RAILS_ENV=production FILE=production.sql db:raw:restore
设置别名:
alias dashboardreport='cd /usr/share/puppet-dashboard/&&rake RAILS_ENV=production jobs:work &'