ELK安装 GrokDebuger 脚本和Web环境

来源:本站原创 elk 超过418 views围观 0条评论

 

 https://www.cnblogs.com/liuning8023/p/5310541.html

 
第一部分,脚本解析形式
内容
安装 RVM
安装 Ruby 和 Gems
安装 Rails
安装 jls-grok
Ruby grok 解析
调试 grok

————————安装rvm
rvm(Ruby Version Manager),是一个非常好用的ruby版本管理以及安装工具。
[root@mysql01 grokbug]# gem install rvm
YAML safe loading is not available. Please upgrade psych to a version that supports safe loading (>= 2.0).
Fetching: rvm-1.11.3.9.gem (100%)
Successfully installed rvm-1.11.3.9
Parsing documentation for rvm-1.11.3.9
Installing ri documentation for rvm-1.11.3.9
1 gem installed
[root@mysql01 grokbug]# rvm
-bash: rvm: command not found
[root@mysql01 grokbug]# curl -sSL https://get.rvm.io | sudo bash -s stable
Downloading https://github.com/rvm/rvm/archive/1.29.3.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc
gpg: directory `/root/.gnupg’ created

安装rvm失败,转用脚本安装

https://github.com/huacnlee/init.d/blob/master/install_rvm

YAML safe loading is not available. Please upgrade psych to a version that supports safe loading (>= 2.0).
Fetching: bundler-1.16.1.gem (100%)
Successfully installed bundler-1.16.1
Parsing documentation for bundler-1.16.1
Installing ri documentation for bundler-1.16.1
1 gem installed
Bundler version 1.16.1
————————— Install Successed —————————–

[root@mysql01 grokbug]# rvm
-bash: rvm: command not found ———报错

[root@mysql01 grokbug]# find / -name rvm
/usr/local/rvm/scripts/rvm

[root@mysql01 grokbug]# source /usr/local/rvm/scripts/rvm ——-解决

永久解决
将 source /usr/local/rvm/scripts/rvm 加入~/.bash_profile文件
[root@mysql01 grokbug]# rvm
Ruby enVironment Manager 1.29.3 (latest) (c) 2009-2017 Michal Papis, Piotr Kuczynski, Wayne E. Seguin

[root@mysql01 grokbug]#

  [root@mysql01 grokbug]# /usr/local/rvm/bin/rvm list known
[root@mysql01 grokbug]# /usr/local/rvm/bin/rvm list known
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.7]
[ruby-]2.3[.4]
[ruby-]2.4[.1]
ruby-head

————–安装指定版本ruby

[root@mysql01 grokbug]# /usr/local/rvm/bin/rvm install 2.2.0 –disable-binary
Checking requirements for centos.
Installing requirements for centos.
Installing required packages: patch, autoconf, automake, bzip2, libffi-devel, libtool, patch, readline-devel, sqlite-devel, libyaml-devel………..
Requirements installation successful.
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-2.2.0, this may take a while depending on your cpu(s)…
ruby-2.2.0 – #downloading ruby-2.2.0, this may take a while depending on your connection…
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 12.6M  100 12.6M    0     0   274k      0  0:00:47  0:00:47 –:–:–  249k
ruby-2.2.0 – #extracting ruby-2.2.0 to /usr/local/rvm/src/ruby-2.2.0….
ruby-2.2.0 – #applying patch /usr/local/rvm/patches/ruby/2.2.0/fix_installing_bundled_gems.patch.
ruby-2.2.0 – #applying patch /usr/local/rvm/patches/ruby/2.2.0/openssl3.patch.
ruby-2.2.0 – #configuring…………………………………………………
ruby-2.2.0 – #post-configuration..
ruby-2.2.0 – #compiling…………………………………………………………………….
ruby-2.2.0 – #installing……………………….
ruby-2.2.0 – #making binaries executable..
ruby-2.2.0 – #downloading rubygems-2.6.14
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  751k  100  751k    0     0   135k      0  0:00:05  0:00:05 –:–:–  178k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.2.0 – #extracting rubygems-2.6.14….
ruby-2.2.0 – #removing old rubygems………
ruby-2.2.0 – #installing rubygems-2.6.14………………………
ruby-2.2.0 – #gemset created /usr/local/rvm/gems/ruby-2.2.0@global
ruby-2.2.0 – #importing gemset /usr/local/rvm/gemsets/global.gems………………………………………..
ruby-2.2.0 – #generating global wrappers……..
ruby-2.2.0 – #gemset created /usr/local/rvm/gems/ruby-2.2.0
ruby-2.2.0 – #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.2.0 – #generating default wrappers……..
ruby-2.2.0 – #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.2.0 – #complete
Please be aware that you just installed a ruby that requires 2 patches just to be compiled on an up to date linux system.
This may have known and unaccounted for security vulnerabilities.
Please consider upgrading to ruby-2.4.1 which will have all of the latest security patches.
Ruby was built without documentation, to build it run: rvm docs generate-ri
[root@mysql01 grokbug]#

———切换ruby 版本
[root@mysql01 grokbug]# ruby -v
ruby 2.0.0p648 (2015-12-16) [x86_64-linux]

[root@mysql01 grokbug]# /usr/local/rvm/bin/rvm use 2.2.0

RVM is not a function, selecting rubies with ‘rvm use …’ will not work.  —报错

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash –login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for an example.

[root@mysql01 grokbug]# source /usr/local/rvm/scripts/rvm ——-解决

切换ruby
root@mysql01 grokbug]# rvm use 2.2.0
Using /usr/local/rvm/gems/ruby-2.2.0

[root@mysql01 grokbug]# ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux] ———成功
[root@mysql01 grokbug]#

———安装rails
 
  [root@mysql01 grokbug]# gem install rails
Fetching: concurrent-ruby-1.0.5.gem (100%)
Successfully installed concurrent-ruby-1.0.5
Fetching: i18n-0.9.1.gem (100%)
Successfully installed i18n-0.9.1
Fetching: thread_safe-0.3.6.gem (100%)
Successfully installed thread_safe-0.3.6
Fetching: tzinfo-1.2.4.gem (100%)
Successfully installed tzinfo-1.2.4
Fetching: activesupport-5.1.4.gem (100%)
ERROR:  Error installing rails:
    activesupport requires Ruby version >= 2.2.2.
[root@mysql01 grokbug]#

版本还是低。。继续安装

[root@mysql01 grokbug]# /usr/local/rvm/bin/rvm install 2.2.2 –disable-binary
Install of ruby-2.2.2 – #complete —完装完成
[root@mysql01 grokbug]# rvm use 2.2.2
Using /usr/local/rvm/gems/ruby-2.2.2   —进行切换

继续安装rails
[root@mysql01 grokbug]# gem install rails
Fetching: concurrent-ruby-1.0.5.gem (100%)
Successfully installed concurrent-ruby-1.0.5
Fetching: i18n-0.9.1.gem (100%)
Successfully installed i18n-0.9.1
Fetching: thread_safe-0.3.6.gem (100%)
Successfully installed thread_safe-0.3.6
Fetching: tzinfo-1.2.4.gem (100%)
Successfully installed tzinfo-1.2.4
Fetching: activesupport-5.1.4.gem (100%)
Successfully installed activesupport-5.1.4
Fetching: rack-2.0.3.gem (100%)
Successfully installed rack-2.0.3
Fetching: rack-test-0.8.2.gem (100%)
Successfully installed rack-test-0.8.2
Fetching: mini_portile2-2.3.0.gem (100%)
Successfully installed mini_portile2-2.3.0
Fetching: nokogiri-1.8.1.gem (100%)
Building native extensions.  This could take a while…
Successfully installed nokogiri-1.8.1
Fetching: crass-1.0.3.gem (100%)
Successfully installed crass-1.0.3
Fetching: loofah-2.1.1.gem (100%)
Successfully installed loofah-2.1.1
Fetching: rails-html-sanitizer-1.0.3.gem (100%)
Successfully installed rails-html-sanitizer-1.0.3
Fetching: rails-dom-testing-2.0.3.gem (100%)
Successfully installed rails-dom-testing-2.0.3
Fetching: builder-3.2.3.gem (100%)
Successfully installed builder-3.2.3
Fetching: erubi-1.7.0.gem (100%)
Successfully installed erubi-1.7.0
Fetching: actionview-5.1.4.gem (100%)
Successfully installed actionview-5.1.4
Fetching: actionpack-5.1.4.gem (100%)
Successfully installed actionpack-5.1.4
Fetching: activemodel-5.1.4.gem (100%)
Successfully installed activemodel-5.1.4
Fetching: arel-8.0.0.gem (100%)
Successfully installed arel-8.0.0
Fetching: activerecord-5.1.4.gem (100%)
Successfully installed activerecord-5.1.4
Fetching: globalid-0.4.1.gem (100%)
Successfully installed globalid-0.4.1
Fetching: activejob-5.1.4.gem (100%)
Successfully installed activejob-5.1.4
Fetching: mini_mime-1.0.0.gem (100%)
Successfully installed mini_mime-1.0.0
Fetching: mail-2.7.0.gem (100%)
Successfully installed mail-2.7.0
Fetching: actionmailer-5.1.4.gem (100%)
Successfully installed actionmailer-5.1.4
Fetching: nio4r-2.2.0.gem (100%)
Building native extensions.  This could take a while…
Successfully installed nio4r-2.2.0
Fetching: websocket-extensions-0.1.3.gem (100%)
Successfully installed websocket-extensions-0.1.3
Fetching: websocket-driver-0.6.5.gem (100%)
Building native extensions.  This could take a while…
Successfully installed websocket-driver-0.6.5
Fetching: actioncable-5.1.4.gem (100%)
Successfully installed actioncable-5.1.4
Fetching: thor-0.20.0.gem (100%)
Successfully installed thor-0.20.0
Fetching: method_source-0.9.0.gem (100%)
Successfully installed method_source-0.9.0
Fetching: railties-5.1.4.gem (100%)
Successfully installed railties-5.1.4
Fetching: bundler-1.16.1.gem (100%)
Successfully installed bundler-1.16.1
Fetching: sprockets-3.7.1.gem (100%)
Successfully installed sprockets-3.7.1
Fetching: sprockets-rails-3.2.1.gem (100%)
Successfully installed sprockets-rails-3.2.1
Fetching: rails-5.1.4.gem (100%)
Successfully installed rails-5.1.4
Parsing documentation for concurrent-ruby-1.0.5
Installing ri documentation for concurrent-ruby-1.0.5
Parsing documentation for i18n-0.9.1
Installing ri documentation for i18n-0.9.1
Parsing documentation for thread_safe-0.3.6
Installing ri documentation for thread_safe-0.3.6
Parsing documentation for tzinfo-1.2.4
Installing ri documentation for tzinfo-1.2.4
Parsing documentation for activesupport-5.1.4
Installing ri documentation for activesupport-5.1.4
Parsing documentation for rack-2.0.3
Installing ri documentation for rack-2.0.3
Parsing documentation for rack-test-0.8.2
Installing ri documentation for rack-test-0.8.2
Parsing documentation for mini_portile2-2.3.0
Installing ri documentation for mini_portile2-2.3.0
Parsing documentation for nokogiri-1.8.1
Installing ri documentation for nokogiri-1.8.1
Parsing documentation for crass-1.0.3
Installing ri documentation for crass-1.0.3
Parsing documentation for loofah-2.1.1
Installing ri documentation for loofah-2.1.1
Parsing documentation for rails-html-sanitizer-1.0.3
Installing ri documentation for rails-html-sanitizer-1.0.3
Parsing documentation for rails-dom-testing-2.0.3
Installing ri documentation for rails-dom-testing-2.0.3
Parsing documentation for builder-3.2.3
Installing ri documentation for builder-3.2.3
Parsing documentation for erubi-1.7.0
Installing ri documentation for erubi-1.7.0
Parsing documentation for actionview-5.1.4
Installing ri documentation for actionview-5.1.4
Parsing documentation for actionpack-5.1.4
Installing ri documentation for actionpack-5.1.4
Parsing documentation for activemodel-5.1.4
Installing ri documentation for activemodel-5.1.4
Parsing documentation for arel-8.0.0
Installing ri documentation for arel-8.0.0
Parsing documentation for activerecord-5.1.4
Installing ri documentation for activerecord-5.1.4
Parsing documentation for globalid-0.4.1
Installing ri documentation for globalid-0.4.1
Parsing documentation for activejob-5.1.4
Installing ri documentation for activejob-5.1.4
Parsing documentation for mini_mime-1.0.0
Installing ri documentation for mini_mime-1.0.0
Parsing documentation for mail-2.7.0
Installing ri documentation for mail-2.7.0
Parsing documentation for actionmailer-5.1.4
Installing ri documentation for actionmailer-5.1.4
Parsing documentation for nio4r-2.2.0
Installing ri documentation for nio4r-2.2.0
Parsing documentation for websocket-extensions-0.1.3
Installing ri documentation for websocket-extensions-0.1.3
Parsing documentation for websocket-driver-0.6.5
Installing ri documentation for websocket-driver-0.6.5
Parsing documentation for actioncable-5.1.4
Installing ri documentation for actioncable-5.1.4
Parsing documentation for thor-0.20.0
Installing ri documentation for thor-0.20.0
Parsing documentation for method_source-0.9.0
Installing ri documentation for method_source-0.9.0
Parsing documentation for railties-5.1.4
Installing ri documentation for railties-5.1.4
Parsing documentation for bundler-1.16.1
Installing ri documentation for bundler-1.16.1
Parsing documentation for sprockets-3.7.1
Installing ri documentation for sprockets-3.7.1
Parsing documentation for sprockets-rails-3.2.1
Installing ri documentation for sprockets-rails-3.2.1
Parsing documentation for rails-5.1.4
Installing ri documentation for rails-5.1.4
Done installing documentation for concurrent-ruby, i18n, thread_safe, tzinfo, activesupport, rack, rack-test, mini_portile2, nokogiri, crass, loofah, rails-html-sanitizer, rails-dom-testing, builder, erubi, actionview, actionpack, activemodel, arel, activerecord, globalid, activejob, mini_mime, mail, actionmailer, nio4r, websocket-extensions, websocket-driver, actioncable, thor, method_source, railties, bundler, sprockets, sprockets-rails, rails after 80 seconds
36 gems installed
[root@mysql01 grokbug]#
——————-安装 jls-grok

[root@mysql01 grokbug]# gem install jls-grok
Fetching: cabin-0.9.0.gem (100%)
Successfully installed cabin-0.9.0
Fetching: jls-grok-0.11.4.gem (100%)
Successfully installed jls-grok-0.11.4
Parsing documentation for cabin-0.9.0
Installing ri documentation for cabin-0.9.0
Parsing documentation for jls-grok-0.11.4
Installing ri documentation for jls-grok-0.11.4
Done installing documentation for cabin, jls-grok after 0 seconds
2 gems installed
[root@mysql01 grokbug]#

———-以上安装安成后

Ruby grok 解析
编写一个 Ruby 脚本,用来调试 Grok 表达式。

require ‘rubygems’
 
gem ‘jls-grok’, ‘=0.11.2’
 
require ‘grok-pure’
 
require ‘optparse’
 
require ‘json’
 
options = {}
 
ARGV.push(‘-h’) if ARGV.size === 0
 
OptionParser.new do |opts|
 
  opts.banner = ‘Run grokdebug at your terminal.’
 
  options[:dirs] = %w(patterns)
 
  options[:named] = false
 
  opts.on(‘-d DIR1,DIR2’, ‘–dirs DIR1,DIR2’, Array, ‘Set grok patterns directories. Default: "./patterns"’) do |value|
 
    options[:dirs] = value
 
  end
 
  opts.on(‘-m MESSAGE’, ‘–msg MESSAGE’, ‘Your raw message to be matched’) do |value|
 
    options[:message] = value
 
  end
 
  opts.on(‘-p PATTERN’, ‘–pattern PATTERN’, ‘Your grok pattern to be compiled’) do |value|
 
    options[:pattern] = value
 
  end
 
  opts.on(‘-n’, ‘–named’, ‘Named captures only’) do
 
  end
 
end.parse!
 
grok = Grok.new
 
options[:dirs].each do |dir|
 
  if File.directory?(dir)
 
    dir = File.join(dir, "*")
 
  end
 
  Dir.glob(dir).each do |file|
 
    grok.add_patterns_from_file(file)
 
  end
 
end
 
grok.compile(options[:pattern], options[:named])
 
puts JSON.pretty_generate(grok.match(options[:message]).captures())
 
调试 grok
[ln@vcyber myruby]$ ruby grokdebug.rb -m ‘10.1.1.1’ -p ‘%{IP:client}’
{
  "client": [
    "10.1.1.1"
  ],
  "IPV6": [
    null
  ],
  "IPV4": [
    "10.1.1.1"
  ]
}
 
[ln@vcyber myruby]$ ruby  grokdebug.rb -m ‘10.1.8.166:8000’ -p ‘%{HOSTPORT:test}’
{
  "test": [
    "10.1.8.166:8000"
  ],
  "IPORHOST": [
    "10.1.8.166"
  ],
  "IP": [
    "10.1.8.166"
  ],
  "IPV6": [
    null
  ],
  "IPV4": [
    "10.1.8.166"
  ],
  "HOSTNAME": [
    null
  ],
  "POSINT": [
    "8000"
  ]
}
[ln@vcyber myruby]$
若提示找不到“pattern”,你可以将 logstash 目录底下的复制过来拿来用~

———–来个IIS的复杂解析———
[root@mysql01 grokdebug]# ruby grokdebug.rb -m ‘2010-07-30 01:06:43 192.168.0.102 – 192.168.0.102 80 GET /css/rss.xslt – 304 0 140 358 0 HTTP/1.1 www.mvpboss1004.com Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+Trident/4.0;+InfoPath.2;+360SE) -‘ -p ‘%{TIMESTAMP_ISO8601:@timestamp} %{IP:c_ip} %{NOTSPACE:cs_username} %{IP:s_ip} %{NUMBER:s_port} %{WORD:cs_method} %{URIPATH:cs_uri_stem} %{NOTSPACE:cs_uri_query} %{NUMBER:sc_status} %{NUMBER:sc_winstatus} %{NUMBER:sc_bytes} %{NUMBER:cs_bytes} %{NUMBER:time_taken} %{NOTSPACE:cs_version} %{NOTSPACE:cs_host} %{NOTSPACE:cs_useragent} %{NOTSPACE:cs_referer}’
{
  "@timestamp": [
    "2010-07-30 01:06:43"
  ],
  "YEAR": [
    "2010"
  ],
  "MONTHNUM": [
    "07"
  ],
  "MONTHDAY": [
    "30"
  ],
  "HOUR": [
    "01",
    null
  ],
  "MINUTE": [
    "06",
    null
  ],
  "SECOND": [
    "43"
  ],
  "ISO8601_TIMEZONE": [
    null
  ],
  "c_ip": [
    "192.168.0.102"
  ],
  "IPV6": [
    null,
    null
  ],
  "IPV4": [
    "192.168.0.102",
    "192.168.0.102"
  ],
  "cs_username": [
    "-"
  ],
  "s_ip": [
    "192.168.0.102"
  ],
  "s_port": [
    "80"
  ],
  "BASE10NUM": [
    "80",
    "304",
    "0",
    "140",
    "358",
    "0"
  ],
  "cs_method": [
    "GET"
  ],
  "cs_uri_stem": [
    "/css/rss.xslt"
  ],
  "cs_uri_query": [
    "-"
  ],
  "sc_status": [
    "304"
  ],
  "sc_winstatus": [
    "0"
  ],
  "sc_bytes": [
    "140"
  ],
  "cs_bytes": [
    "358"
  ],
  "time_taken": [
    "0"
  ],
  "cs_version": [
    "HTTP/1.1"
  ],
  "cs_host": [
    "www.mvpboss1004.com"
  ],
  "cs_useragent": [
    "Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+Trident/4.0;+InfoPath.2;+360SE)"
  ],
  "cs_referer": [
    "-"
  ]
}

———————grokdebug 本地化安装完成————————–

第二部分 web访问形式
最近在使用ELK对日志进行集中管理,因为涉及到日志的规则经常要用到http://grokdebug.herokuapp.com/进行调试,
但是因为国内网络的特殊原因网站用到的js文件无法访问,所以经常要使用科学上网才能进行调试,
幸好程序已经在github上开源出来了,使得在本地搭建调试环境得以实现

1.Ruby的安装

yum -y install  openssl-devel gcc
wget https://ruby.taobao.org/mirrors/ruby/2.1/ruby-2.1.7.tar.gz
tar zxf ruby-2.1.7.tar.gz
cd ruby-2.1.7
./configure –prefix=/usr/local/ruby2.1.7
make && make install
echo ‘export PATH=/usr/local/ruby2.1.7/bin:$PATH’>>/etc/profile
source /etc/profile
说明:别使用ruby最新的2.2或者2.3的版本,可能出现部分组件无法安装

2.RubyGems工具安装

wget http://rubygems.global.ssl.fastly.net/rubygems/rubygems-2.6.2.tgz
tar zxf rubygems-2.6.2.tgz
cd rubygems-2.6.2
ruby setup.rb
3.替换gem源,又是由于网络环境的问题,访问官方源非常慢
gem sources –add https://ruby.taobao.org/ –remove https://rubygems.org/
gem sources -l

Grokbug的安装
[root@mysql01 grokbug]# pwd
/usr/local/grokbug

mkdir /usr/local/grokbug
cd /usr/local/grokbug
wget https://codeload.github.com/nickethier/grokdebug/zip/master
unzip master
mv grokdebug-master/* .
rm -rf grokdebug-master/

完整安装
gem install bundler
gem install cabin -v=0.5.0
gem install haml -v=3.1.7
gem install jls-grok -v=0.10.10
gem install json -v=1.7.5
gem install kgio -v=2.8.0
gem install rack -v=1.4.1
gem install rack-protection -v=1.2.0
gem install raindrops -v=0.11.0 
gem install shotgun -v=0.9
gem install tilt -v=1.3.3
gem install sinatra -v=1.3.3
gem install unicorn -v=4.6.3

[root@mysql01 grokbug]# gem install haml -v=3.1.7
3.3
gem install sinatra -v=1.3.3
Fetching: haml-3.1.7.gem (100%)ching: haml-3.1.7.gem
Successfully installed haml-3.1.7
Parsing documentation for haml-3.1.7
Installing ri documentation for haml-3.1.7
Done installing documentation for haml after 1 seconds
1 gem installed
[root@mysql01 grokbug]# gem install jls-grok -v=0.10.10
Fetching: jls-grok-0.10.10.gem (100%)
Successfully installed jls-grok-0.10.10
Parsing documentation for jls-grok-0.10.10
Installing ri documentation for jls-grok-0.10.10
Done installing documentation for jls-grok after 0 seconds
1 gem installed
[root@mysql01 grokbug]# gem install json -v=1.7.5
Fetching: json-1.7.5.gem (100%)
Building native extensions.  This could take a while…
Successfully installed json-1.7.5
Parsing documentation for json-1.7.5
Installing ri documentation for json-1.7.5
Done installing documentation for json after 0 seconds
1 gem installed
[root@mysql01 grokbug]# gem install kgio -v=2.8.0
Fetching: kgio-2.8.0.gem (100%)
Building native extensions.  This could take a while…
Successfully installed kgio-2.8.0
Parsing documentation for kgio-2.8.0
Installing ri documentation for kgio-2.8.0
Done installing documentation for kgio after 0 seconds
1 gem installed
[root@mysql01 grokbug]# gem install rack -v=1.4.1
Fetching: rack-1.4.1.gem (100%)
Successfully installed rack-1.4.1
Parsing documentation for rack-1.4.1
Installing ri documentation for rack-1.4.1
Done installing documentation for rack after 1 seconds
1 gem installed
[root@mysql01 grokbug]# gem install rack-protection -v=1.2.0
Fetching: rack-protection-1.2.0.gem (100%)
Successfully installed rack-protection-1.2.0
Parsing documentation for rack-protection-1.2.0
Installing ri documentation for rack-protection-1.2.0
Done installing documentation for rack-protection after 0 seconds
1 gem installed
[root@mysql01 grokbug]# gem install raindrops -v=0.11.0 
Fetching: raindrops-0.11.0.gem (100%)
Building native extensions.  This could take a while…
Successfully installed raindrops-0.11.0
Parsing documentation for raindrops-0.11.0
Installing ri documentation for raindrops-0.11.0
Done installing documentation for raindrops after 0 seconds
1 gem installed
[root@mysql01 grokbug]# gem install shotgun -v=0.9
Fetching: shotgun-0.9.gem (100%)
Successfully installed shotgun-0.9
Parsing documentation for shotgun-0.9
Installing ri documentation for shotgun-0.9
Done installing documentation for shotgun after 0 seconds
1 gem installed
[root@mysql01 grokbug]# gem install tilt -v=1.3.3
Fetching: tilt-1.3.3.gem (100%)
Successfully installed tilt-1.3.3
Parsing documentation for tilt-1.3.3
Installing ri documentation for tilt-1.3.3
Done installing documentation for tilt after 0 seconds
1 gem installed
[root@mysql01 grokbug]# gem install sinatra -v=1.3.3
Fetching: sinatra-1.3.3.gem (100%)
Successfully installed sinatra-1.3.3
Parsing documentation for sinatra-1.3.3
Installing ri documentation for sinatra-1.3.3
Done installing documentation for sinatra after 3 seconds
1 gem installed
[root@mysql01 grokbug]# gem install unicorn -v=4.6.3
Fetching: unicorn-4.6.3.gem (100%)
Building native extensions.  This could take a while…
GemWrappers: Can not wrap not executable file: unicorn
Successfully installed unicorn-4.6.3
Parsing documentation for unicorn-4.6.3
Installing ri documentation for unicorn-4.6.3
Done installing documentation for unicorn after 0 seconds
1 gem installed
[root@mysql01 grokbug]#

———–启动—
[root@mysql01 grokdebug]# nohup: ignoring input and appending output to ‘nohup.out’

[1]+  Exit 10                 nohup bundle exec unicorn -p 8089 -c ./unicorn
[root@mysql01 grokdebug]#

[root@mysql01 grokdebug]# !net
netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:8089 —启动正常           0.0.0.0:*               LISTEN      48016/unicorn maste
       
[root@mysql01 grokdebug]#

访问页面
http://192.168.142.138:8089/

 

替换jqurey页面
7.替换Google的jquery源
cd views
sed -i ‘s#//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js#//lib.sinaapp.com/js/jquery/1.8.1/jquery.min.js#g’ index.haml
sed -i ‘s#//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js#//lib.sinaapp.com/js/jquery-ui/1.9.2/jquery-ui.min.js#g’ index.haml
sed -i ‘s#//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js#//lib.sinaapp.com/js/jquery/1.7.2/jquery.min.js#g’ patterns.haml
sed -i ‘s#//ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/themes/ui-lightness/jquery-ui.css#//lib.sinaapp.com/js/jquery-ui/1.9.0/themes/ui-lightness/jquery-ui.css#g’ layout.haml
sed -i ‘s#//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js#//lib.sinaapp.com/js/jquery/1.7.2/jquery.min.js#g’ discover.haml

———-unicorn
[root@mysql01 ~]# unicorn
-bash: unicorn: command not found

参考 http://gems.ruby-china.org/
[root@mysql01 grokbug]# gem install rails

^CERROR:  Interrupted
[root@mysql01 grokbug]# gem sources –add https://gems.ruby-china.org/ –remove https://ruby.taobao.org/
source https://gems.ruby-china.org/ already present in the cache
https://ruby.taobao.org/ removed from sources
[root@mysql01 grokbug]#
[root@mysql01 grokbug]#
[root@mysql01 grokbug]#
[root@mysql01 grokbug]# gem install rails
Fetching: concurrent-ruby-1.0.5.gem (100%)
Successfully installed concurrent-ruby-1.0.5
Fetching: i18n-0.9.0.gem (100%)
Successfully installed i18n-0.9.0
Fetching: thread_safe-0.3.6.gem (100%)
Successfully installed thread_safe-0.3.6
Fetching: tzinfo-1.2.3.gem (100%)

 

[root@mysql01 grokbug]# gem update ruby
YAML safe loading is not available. Please upgrade psych to a version that supports safe loading (>= 2.0).
Updating installed gems
Nothing to update
[root@mysql01 grokbug]# psych -v
-bash: psych: command not found
[root@mysql01 grokbug]# yaml -v
-bash: yaml: command not found
[root@mysql01 grokbug]# gem list psych
YAML safe loading is not available. Please upgrade psych to a version that supports safe loading (>= 2.0).

*** LOCAL GEMS ***

Error: Nothing to do

 

[root@mysql01 grokbug]# curl -sSL https://get.rvm.io | bash -s stable
Downloading https://github.com/rvm/rvm/archive/1.29.3.tar.gz

 

Downloading https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc
gpg: Signature made Mon 11 Sep 2017 04:59:21 AM CST using RSA key ID BF04FF17
gpg: Good signature from "Michal Papis (RVM signing) <mpapis@gmail.com>"
gpg:                 aka "Michal Papis <michal.papis@toptal.com>"
gpg:                 aka "[jpeg image of size 5015]"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 409B 6B17 96C2 7546 2A17  0311 3804 BB82 D39D C0E3
     Subkey fingerprint: 62C9 E5F4 DA30 0D94 AC36  166B E206 C29F BF04 FF17
GPG verified ‘/usr/local/rvm/archives/rvm-1.29.3.tgz’

Upgrading the RVM installation in /usr/local/rvm/
Upgrade of RVM in /usr/local/rvm/ is complete.

Upgrade Notes:

  * No new notes to display.
————-bash: rvm: command not found

[root@mysql01 grokbug]# rvm
-bash: rvm: command not found

[root@mysql01 grokbug]# find / -name rvm
/usr/local/rvm/scripts/rvm

[root@mysql01 grokbug]# source /usr/local/rvm/scripts/rvm ——-解决

永久解决
将 source /usr/local/rvm/scripts/rvm 加入~/.bash_profile文件
[root@mysql01 grokbug]# rvm
Ruby enVironment Manager 1.29.3 (latest) (c) 2009-2017 Michal Papis, Piotr Kuczynski, Wayne E. Seguin

Usage:
 

 
 
 
  执行命令
 

 

 
  —————rvm ruby 安装标准方法-
 
  https://ruby-china.org/wiki/rvm-guide

文章出自:CCIE那点事 http://www.jdccie.com/ 版权所有。本站文章除注明出处外,皆为作者原创文章,可自由引用,但请注明来源。 禁止全文转载。
本文链接:http://www.jdccie.com/?p=3663转载请注明转自CCIE那点事
如果喜欢:点此订阅本站
  • 相关文章
  • 为您推荐
  • 各种观点

暂时还木有人评论,坐等沙发!
发表评论

快捷键:Ctrl+Enter