puppet连载四:服务端安装dashboard

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS PostgreSQL,集群系列 2核4GB
简介: curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -curl -L get.rvm.io | bash -s stablesource /etc/profile.

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
<VirtualHost *: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
<Location /usr/share/puppet-dashboard/public/>
Options None
AllowOverride None
Order allow,deny
allow from all
</Location>
</VirtualHost>

关闭刚才的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 &'

相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
关系型数据库 网络安全 PostgreSQL
puppet连载14:安装puppetdb
yum install puppetdb puppetdb-terminus -y service puppetdb start vi /etc/puppet/puppet.
1061 0
|
网络协议 应用服务中间件 Shell
puppet连载12:linux安装nginx、openresty
服务端在/puppet/soft 里建nginx1102setup.sh,内容: !/bin/bash yum -y install wget libtool expat-devel gcc gcc-c++ glibc automake autocon...
928 0
|
Java 应用服务中间件 Linux
puppet连载九:linux安装jdk、tomcat模块
安装jdk1.8.0_91和tomcat8.0.36 mkdir -p /etc/puppet/modules/linuxjdktomcat/{manifests,templates,files} vi /etc/puppet/modules/linuxjdktomcat/manifests/init.
1077 0
|
MySQL 关系型数据库 Linux
puppet连载10:linux安装percona57/56/55、sysbench、tpcc模块
在服务端/puppet/soft下建my.cnf,内容为https://www.jianshu.com/p/c63fc6c71279 在服务端/puppet/soft下建changemysql57pass.
1072 0
|
Linux 开发工具 git
puppet连载七:linux基础组件安装模块
linux基础组件安装模块linuxbaseinstall 更换源,安装gcc gcc-c++ glibc-devel make ncurses-devel openssl-devel autoconf git mkdir -p /etc/puppet...
1072 0
|
网络安全 Apache Ruby
puppet连载三:服务端安装http、passenger
服务端安装插件: yum install -y ruby-devel ruby-libs rubygems libcurl-devel httpd httpd-devel apr-util-devel apr-devel mod_ssl gcc-c++...
1066 0
|
消息中间件
puppet 连载二:服务端和客户端安装(ActiveMQ、MCollective)
-------------------------------------服务端----------------------------------- 1、jdk安装 vi /etc/profile export JAVA_HOME=/usr/loca...
1143 0
|
网络协议 Apache
puppet 连载一:服务端和客户端安装(puppet、svn)
1、mkdir /puppet mkdir /puppet/soft 2、服务端安装dnsmasq:yum install -y dnsmasq cp /etc/dnsmasq.
1418 0
|
15天前
|
运维 Linux Apache
Puppet 作为一款强大的自动化运维工具,被广泛应用于配置管理领域。通过定义资源的状态和关系,Puppet 能够确保系统始终处于期望的配置状态。
Puppet 作为一款强大的自动化运维工具,被广泛应用于配置管理领域。通过定义资源的状态和关系,Puppet 能够确保系统始终处于期望的配置状态。
37 3
|
安全 Linux 网络协议
puppet yum模块、配置仓储、mount模块
转载:http://blog.51cto.com/ywzhou/1577335 作用:自动为客户端配置YUM源,为使用yum安装软件包提供便捷。 1、服务端配置yum模块 (1)模块清单 [root@puppet ~]# tree /etc/puppe...
1112 0