msgbartop
世界上的一队小小的漂泊者呀,请留下你们的足印在我的文字里
msgbarbottom

31 十二 11 Gitorious on Ubuntu

Gitorious 是一个基于 Git 版本控制系统的Web项目托管平台。基于 Ruby on Rails 开发,本文简单描述下在Ubuntu(11.04)下配置的记录.

khan.chan {at} virest.org | seer.chen@gmail.com

默认Ubuntu我们安装的时候只安装了OpenSSH Server/Client. 你可以按照我的顺序往下操作.

Packages

#aptitude install build-essential zlib1g-dev tcl-dev libexpat-dev libxslt1-dev \
libcurl4-openssl-dev zip unzip memcached postfix apache2 mysql-server mysql-client \
apg geoip-bin libgeoip1 libgeoip-dev sqlite3 libsqlite3-dev \
imagemagick libpcre3 libpcre3-dev zlib1g zlib1g-dev libyaml-dev \
libmysqlclient15-dev apache2-dev libonig-dev ruby-dev rubygems \
libopenssl-ruby libdbd-mysql-ruby libmysql-ruby \
libmagick++-dev  git-core git-svn git-doc \
git-cvs irb libaspell-dev

Ruby Gems

强制升级使用RubyGems v1.4,Gitorious支持需要.

#REALLY_GEM_UPDATE_SYSTEM=1 gem update –system

OK, 我们安装rake,daemons等

#gem install –no-ri –no-rdoc -v 0.8.7 rake && \
gem install –no-ri –no-rdoc -v 1.1.0 daemons && \
gem install -b –no-ri –no-rdoc \
rmagick stompserver passenger bundler

#gem install raspell

下载安装Sphinx

#wget -c http://sphinxsearch.com/files/sphinx-0.9.9.tar.gz

#./configure –prefix=/usr;  make all install

我们查看下apache2安装是否正常, 然后用git clone取gitorious代码

#git clone git://gitorious.org/gitorious/mainline.git /var/www/gitorious

#cd /var/www/gitorious

#git submodule init
#git submodule update

#ln -s /var/www/gitorious/script/gitorious /usr/bin

#cd /var/www/gitorious/doc/templates/ubuntu/ && \
cp git-daemon git-poller git-ultrasphinx stomp /etc/init.d/ && \
cd /etc/init.d/ && \
chmod 755 git-daemon git-poller git-ultrasphinx stomp

# update-rc.d git-daemon defaults && \
update-rc.d git-poller defaults && \
update-rc.d git-ultrasphinx defaults && \
update-rc.d stomp defaults

# ln -s /usr/ /opt/ruby-enterprise

下载rots GIT

# git clone git://github.com/roman/rots.git

#cd rots && gem build rots.gemspec && gem install rots-0.2.1.gem

#rm -rf /usr/lib/ruby/gems/1.8/bundler/gems/rots-babb5559aae8

#vi /var/www/gitorious/Gemfile:

gem “rots”, :git => ‘https://github.com/roman/rots.git‘    把这一行替换为:

gem “rots”, :git => “~> 0.2.1″

#$(gem contents passenger | grep passenger-install-apache2-module)

#vi /etc/apache2/mods-available/passenger.load

 

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.11
PassengerRuby /usr/bin/ruby1.8

 

#a2enmod passenger

#a2enmod rewrite

#a2enmod ssl

创建Apache2的gitorious配置文件:

/etc/apache2/sites-available/gitorious

<VirtualHost *:80>
ServerName gitorious.virest.org
DocumentRoot /var/www/gitorious/public
</VirtualHost>

/etc/apache2/sites-available/gitorious-ssl

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
DocumentRoot /var/www/gitorious/public
SSLEngine on
SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
BrowserMatch “.*MSIE.*” nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
</VirtualHost>
</IfModule>

#a2ensite gitorious

#a2ensite gitorious-ssl

创建mysql用户

mysql -u root -p
Enter password: (your mysql root password you selected while installing the packages)
mysql> GRANT ALL PRIVILEGES ON *.* TO ’gitorious’@'localhost’ IDENTIFIED BY ’<insert password>’ WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;

配置Gitorious

#cd /var/www/gitorious
#bundle install && \
#bundler pack
#adduser --system --home /var/www/gitorious/ --no-create-home --group --shell /bin/bash git && \     chown -R git:git /var/www/gitorious
#su - git && \
    mkdir .ssh && \     touch .ssh/authorized_keys && \     chmod 700 .ssh && \     chmod 600 .ssh/authorized_keys && \     mkdir tmp/pids && \     mkdir repositories && \     mkdir tarballs
#cp config/database.sample.yml config/database.yml && \     cp config/gitorious.sample.yml config/gitorious.yml && \     cp config/broker.yml.example config/broker.yml
  • 产品段信息修改下适合的配置信息
  • repository_base_path   /var/www/gitorious/repositories
  • cookie_secret  设置一段字符段,长于30个字母
  • gitorious_client_port  80
  • gitorious_host
  • archive_cache_dir  /var/www/gitorious/tarballs
  • archive_work_dir  /tmp/tarballs-work
  • hide_http_clone_urls   true
  • is_gitorious_dot_org  false
在config/boot.rb中加入:   require ‘thread’

OK,最后完工工作:

export RAILS_ENV=production && \
bundle exec rake db:create && \
bundle exec rake db:migrate && \
bundle exec rake ultrasphinx:bootstrap
#crontab -e
* * * * * cd /var/www/gitorious && /usr/bin/bundle exec rake ultrasphinx:index RAILS_ENV=production

建立gitorious 管理账号:

env RAILS_ENV=production ruby1.8 script/create_admin

 

 

 

 

Tags: ,

11 八 11 五步曲设置监控ESX

khan.chan {at} virest.org

from:opsview.com

我们五步曲来设置用Opsview和vSphere SDK来监控ESX环境.

确认下我们的佐料:

第一步:

下载适合平台的SDK Libraries:http://communities.vmware.com/community/vmtn/developer/forums/vsphere_sdk_perl

第二步:运行命令配置:

opsview@opsmstpr01:~$ sudo tar -zxvf VMware-vSphere-Perl-SDK-4.1.0-254719.x86_64.tar.gz
opsview@opsmstpr01:~$ sudo vmware-vsphere-cli-distrib/vmware-install.pl
Creating a new vSphere CLI installer database using the tar4 format.
Installing vSphere CLI.
Installing version 254719 of vSphere CLI
You must read and accept the vSphere CLI End User License Agreement to continue.
Press enter to display it.

第三步: 下载和安装Nagios 插件:check_esx3:
http://exchange.nagios.org/directory/Plugins/Operating-Systems/*-Virtual-Environments/VMWare/check_esx3/details

第四步:在你的Opsview上用Nagios运行帐号执行如下命令测试:
/check_esx3 -H $HOSTADDRESS$ -u root -p password -l cpu
./check_esx3 -H $HOSTADDRESS$ -u root -p password -l runtime -s list
./check_esx3 -H $HOSTADDRESS$ -u root -p password -l io
./check_esx3 -H $HOSTADDRESS$ -u root -p password -l mem -s usage
./check_esx3 -H $HOSTADDRESS$ -u root -p password -l net
./check_esx3 -H $HOSTADDRESS$ -u root -p password -l runtime -s issues
./check_esx3 -H $HOSTADDRESS$ -u root -p password -l runtime -s status
./check_esx3 -H $HOSTADDRESS$ -u root -p password -l service
./check_esx3 -H $HOSTADDRESS$ -u root -p password -l storage -s path
./check_esx3 -H $HOSTADDRESS$ -u root -p password -l mem -s swap
./check_esx3 -H $HOSTADDRESS$ -u root -p password -l vmfs

第五步:  创建Opsview的服务和主机模板,可参考:http://docs.opsview.com/doku.php

 

 

01 八 11 mysql-master-master-replication_1

khan.chan {at} virest.org

需要赘言吗? :-)     不需要; 应该看的懂.

更多性能和问题请自己动手,mysql自增奇偶还是会有些问题的,所以正式生产环境需多努力了解,本文只是让其run起来而已.

[关键词:mysql auto_increment_increment auto_increment_offset log-bin ]

master1:

[mysqld]
log-bin
server-id    = 1
binlog-do-db    = test
binlog-ignore-db    = mysql
replicate-do-db    = test
replicate-ignore-db    = mysql
log-slave-updates
slave-skip-errors    = all
sync_binlog    = 1
auto_increment_increment    = 2
auto_increment_offset        = 1

 

mysql> grant replication slave on *.* to ‘repl’@'%’ identified by ‘access’;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> show master status;
+——————-+———-+————–+——————+
| File              | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+——————-+———-+————–+——————+
| mysqld-bin.000001 |       98 | test         | mysql            |
+——————-+———-+————–+——————+
1 row in set (0.01 sec)

master2:

[mysqld]
log-bin
server-id    = 2
binlog-do-db    = test
binlog-ignore-db    = mysql
replicate-do-db    = test
replicate-ignore-db    = mysql
log-slave-updates
slave-skip-errors    = all
sync_binlog    = 1
auto_increment_increment    = 2
auto_increment_offset        = 2

 

mysql> change master to master_host=’192.168.3.209′,master_user=’repl’,master_password=’access’,master_log_file=’mysqld-bin.000001′,master_log_pos=98;
Query OK, 0 rows affected (0.03 sec)

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.3.209
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysqld-bin.000001
Read_Master_Log_Pos: 98
Relay_Log_File: mysqld-relay-bin.000002
Relay_Log_Pos: 236
Relay_Master_Log_File: mysqld-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: test
Replicate_Ignore_DB: mysql
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 98
Relay_Log_Space: 236
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
1 row in set (0.00 sec)

master2:

mysql> grant replication slave on *.* to ‘repl’@'%’ identified by ‘access’;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> show master status;
+——————-+———-+————–+——————+
| File              | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+——————-+———-+————–+——————+
| mysqld-bin.000001 |       98 | test         | mysql            |
+——————-+———-+————–+——————+
1 row in set (0.00 sec)

master1:

mysql> change master to master_host=’192.168.3.210′,master_user=’repl’,master_password=’access’,master_log_file=’mysqld-bin.000001′,master_log_pos=98;
Query OK, 0 rows affected (0.02 sec)

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.3.210
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysqld-bin.000001
Read_Master_Log_Pos: 98
Relay_Log_File: mysqld-relay-bin.000002
Relay_Log_Pos: 236
Relay_Master_Log_File: mysqld-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: test
Replicate_Ignore_DB: mysql
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 98
Relay_Log_Space: 236
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
1 row in set (0.00 sec)

ERROR:
No query specified

 

master1:

mysql> use test;
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql> create table who_repl
-> (id int not null auto_increment primary key,
-> str varchar(255) not null) engine myisam;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into who_repl(str) values
-> (‘master wugui test table’);
Query OK, 1 row affected (0.01 sec)

mysql> show tables;
+—————-+
| Tables_in_test |
+—————-+
| who_repl       |
+—————-+
1 row in set (0.00 sec)

mysql> select * from who_repl;
+—-+————————-+
| id | str                     |
+—-+————————-+
|  1 | master wugui test table |
+—-+————————-+
1 row in set (0.00 sec)

master2:

查看下Master2主机,who_repl Table表已经过来了.

mysql> use test;
Database changed
mysql> show tables;
+—————-+
| Tables_in_test |
+—————-+
| who_repl       |
+—————-+
1 row in set (0.00 sec)

然后我们在master2主机上新插入条数据:

mysql> insert into who_repl(str) values(‘Master2 say hello’);
Query OK, 1 row affected (0.00 sec)

mysql> select * from who_repl;
+—-+————————-+
| id | str                     |
+—-+————————-+
|  1 | master wugui test table |
|  2 | Master2 say hello       |
+—-+————————-+
2 rows in set (0.00 sec)

master1看下:

mysql> select * from who_repl;
+—-+————————-+
| id | str                     |
+—-+————————-+
|  1 | master wugui test table |
|  2 | Master2 say hello       |
+—-+————————-+
2 rows in set (0.00 sec)