2014年4月10日星期四

ubuntu 12.04 install ntp server over http

1.install ntp server package
#apt-get update
#apt-get upgrade
#apt-get install ntp

2. modify ntp configuration
#vim /etc/ntp.conf

driftfile /var/lib/ntp/ntp.drift
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
server 127.127.1.0
restrict csp.garmin.com notrap nomodify nopeer noquery
restrict 192.168.200.0 mask 255.255.255.0
restrict 127.0.0.1
broadcast 192.168.200.255
disable auth
broadcastclient

3. restart ntp serivce
#/etc/init.d/ntp restart

4.add third party component to source.list
#vim /etc/apt/source.list
deb http://ppa.launchpad.net/landronimirc/htpdate/ubuntu precise main
deb-src http://ppa.launchpad.net/landronimirc/htpdate/ubuntu precise main

5.add ppa key
#app-apt-repository ppa:landronimirc/htpdate

6.update repository
#apt-get update

7. install htpdate package
#apt-get install htpdate

8.setting crontab
#vim /etc/crontab
* */6 * * * /usr/bin/htpdate -d http://www.perl.org

9. restart cron job
#/etc/init.d/cron restart

2014年3月11日星期二

Multipath with storage

1.install multipath tools
#apt-get install multipath-tools  multipath-tools-boot

2. create multipath.conf
#cp /usr/share/doc/multipath-tools/examples/multipath.conf.synthetic /etc/multipath.conf

3.modify mutipath.conf
#vim /etc/multipath.conf

defaults {
        path_grouping_policy    multibus
        failback                immediate
        no_path_retry           fail
        user_friendly_names     yes
}
blacklist {
        devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
        devnode "^hd[a-z][[0-9]*]"
        devnode "^cciss!c[0-9]d[0-9]*[p[0-9]*]"

      }

blacklist define device not included by multipath

4.restart multipath service
#service multipath-tools restart

5.show multipath status
#multipath -ll
mpath0 (360050cc000203d7a0000000000000008) dm-0 OVERLAND,RAID 1200
[size=1.5T][features=0][hwhandler=0]
\_ round-robin 0 [prio=2][active]
 \_ 2:0:0:0 sda 8:0   [active][ready]
 \_ 2:0:1:0 sdb 8:16  [active][ready]

6. if your disk is GPT format then install fixparts and install deb 
#wget http://download.opensuse.org/repositories/home:/srs5694/xUbuntu_10.04/amd64/gptfdisk_0.8.8-1_amd64.de
#dpkg -i gptfdisk_0.8.8-1_amd64.deb
#apt-get -f install

7. format gpt disk 
# fixparts /dev/mapper/mpath0


2014年2月19日星期三

ubuntu 12.04 install php + mysql + apache2 + oracle + mssql develop environment

1. install all packages for os
# apt-get update
# apt-get upgrade

2. install compiler packages
# apt-get install buiild-essential fakeroot dpkg-dev

3. install apache, mysql server, php
# aptg-get install mysql-server mysql-client php5 php5-cli libapache2-mod-auth-mysql apache2

4. check php function
# vim /var/www/1.php
echo phpinfo();
?>

5. install mssql odbc module
# apt-get install php5-sybase

6. install oracle module
# apt-get install libaio1 php-pear unzip

7. download instantclient for oracle
# cd /usr/local/lib
# wget http://download.oracle.com/otn/linux/instantclient/121010/instantclient-basic-linux.x64-12.1.0.1.0.zip
# wget http://download.oracle.com/otn/llinux/instantclient/instantclient-sdk-linux.x64-12.1.0.1.0.zip
# unzip instantclient-basic-linux.x64-12.1.0.1.0.zip
# unzip instantclient-sdk-linux.x64-12.1.0.1.0.zip
# cd instantclient_12_1
# ln -s libclntsh.so.12.1 libclntsh.so

8. add some line to /etc/environment
# vim /etc/environment

# Oracle Instant Client
LD_LIBRARY_PATH="/usr/local/lib/instantclient_12_1"
TNS_ADMIN="/usr/local/lib/instantclient_12_1"
ORACLE_BASE="/usr/local/lib/instantclient_12_1"
ORACLE_HOME=$ORACLE_BASE

9. install oci8 package for pear
# pecl install oci8
when you get the prompt for oracle_home, key in the path 
'instantclient,/usr/local/lib/instantclient_12_1'

10. add extension to php.ini
# vim /etc/php5/apache2/php.ini

extension=oci8.so

11. change apache default charset to utf-8
#vim /etc/apache2/conf.d/charset
uncomment AddDefaultCharset UTF-8


12. restart apache
#/etc/init.d/apache2 restart

2014年2月11日星期二

manual install mysql server

1. update and install some package need to install mysql
# apt-get update
# apt-get install fakeroot build-essential dpkg-dev libaio-dev

2. download mysql compress file from mysql site and decompress it
# tar zxvf mysql-advanced-5.5.28-linux2.6-x86_64.tar.gz

3. move it to /usr/local and create software link for mysql
# mv mysql-advanced-5.5.28 /usr/local/
# cd /usr/local
# ln -s mysql-advanced-5.5.28 mysql

4.create mysql user and group
# adduser -d /home/mysql -m mysql

5. change file owner and install mysql
# chown -R mysql /usr/local/mysql
# chown -R mysql /usr/local/mysql

6.install mysql server
#/usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/var/lib/mysql --user=mysql

7.copy mysql configure to /etc/
#cp suuport-files/my-medium.cnf /etc/my.cnf

8.start mysql server
#/usr/local/mysql/bin/mysql_safe --user=mysql &

9. add mysql search path to default environment
# vim /etc/environments
add /usr/local/mysql/bin to the end of the line

10. cp mysql script to /etc/init.d/
# cp support-file/mysql.server /etc/mysql.server

11. login mysql and change root password
#mysql -u root

grant all on *.* to 'root'@'localhost' identified by 'xxxxx'
flush privileges

12. restart mysql to confirm the password for rooot
# /etc/init.d/mysql.server restart

2013年12月10日星期二

enable sftp transfer to instead of the ftp protocol

1. add these lines to /etc/ssh/sshd_config

Subsystem sftp internal-sftp

Match Group sftpusers
    ChrootDirectory %h
    ForceCommand internal-sftp
    AllowTcpForwarding no

2. add one group name sftpuser
#groupadd sftpusers

2. add one user for testing
useradd -g sftpusers -d /home/sftp/user1 -m user1
usermod -s /bin/false

3. add /bin/false to /etc/shells 

4. change permission for the user
# chown root:root /home/sftp/user1
# chmod 755 /home/sftp/user1

5. restart the ssh service
# /etc/inti.d/ssh restart

6. create another folder to writable and mount it to the subfolder
# mkdir -p /home/sftp-write/user1
# mkdir /home/sftp/incoming
# mount --bind /home/sftp-write/user1/ /home/sftp/user/incoming

7. testing for the sftp  
#sftp user1@xxxx.xxxx.xxxx.xxxx

2013年11月13日星期三

ssh autologin to multi server

situation:
         three server with ip 10.10.10.1, 10.10.10.2, 10.10.10,3

1. install all open ssh package on these servers
# apt-get install ssh

2. create the same user account on these servers
# useradd -d /home/user1 -m user1
# passwd user1

3. on one of these three server , generate the public key
# ssh-keygen -t rsa

4. copy public key to the others
#ssh-copy-id -i user1@10.10.10.2
#ssh-copy-id -i user1@10.10.10.3

5. testing the autologin function
#ssh 10.10.10.2

2013年11月9日星期六

how to install mongoDB

1. insert into key from url to get mongDB key
#sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

2.modify the apt source.ist
#echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list

3. update the repository
#sudo apt-get update

4. install mongoDB
#sudo apt-get install mongodb-10gen

5.testing the mongoDB
#mongo