LAMP--原始碼MySQL叢集版搭建

kumu_linux發表於2012-09-21

LAMP--原始碼MySQL叢集版搭建

環境:RHEL6.1 x86

 

軟體如下:

#ls

apr-1.4.6.tar.g        memcached-1.4.13.tar.gz              pcre-7.9.tar.gz

apr-iconv-1.2.1.tar.gz libevent-2.0.18-stable.tar.gz               mysql-cluster-gpl-7.0.5.tar.gz

apr-util-1.4.1.tar.gz    libiconv-1.13.tar.gz                     httpd-2.2.22.tar.gz            

mysql-cluster-gpl-7.2.5.tar.gz           jdk-6u18-ea-bin-b02-linux-i586-09_sep_2009.bin

 

1.解除安裝系統自帶java

# yum remove java -y

 

2.安裝 java

#./ jdk-6u18-ea-bin-b02-linux-i586-09_sep_2009.bin

#mv jdk1.6.0_18/ /usr/java

# vim /etc/profile

---------------------加入如下內容到/etc/profile中---------------------

JAVA_HOME=/usr/java

CLASS_PATH=/usr/java/jre:/usr/java/lib

PATH=$PATH:/usr/java/bin/

---------------------------------------------------------------------------------

 

3.環境要生效 

#source /etc/profile

 

4.libevent  

libevent-2.0.18-stable.tar.gz --> 解壓

#./configure

#make && make install

#echo /usr/local/lib >/etc/ld.so.conf.d/lamp.conf

# ldconfig  //執行ldconfig使庫生效

 

5編譯 memcached 

memcached-1.4.13.tar.gz --> 解壓

#./configure --enable-sasl--enable-sasl-pwdb --with-libevent=/usr/local

#make && make install

 

6.安裝 mysql-cluster  <保證系統中有mysql使用者,uid=27 gid=27 >

mysql-cluster-gpl-7.2.5.tar.gz

如果之前安裝過MySQL則執行以下a、b操作:

a. stop mysql                      停庫

    b. rm -rf /usr/local/mysql      刪除MySQL安裝目錄

 

# cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/mysql -DMYSQL_DATADIR:PATH=/database -DMEMCACHED_HOME:PATH=/usr/local -DWITH_CLASSPATH:STRING=/usr/java -DWITH_EXTRA_CHARSETS:STRING=all -DWITH_INNOBASE_STORAGE_ENGINE:BOOL=ON -DWITH_NDBCLUSTER_STORAGE_ENGINE:BOOL=ON -DWITH_PARTITION_STORAGE_ENGINE:BOOL=ON -DWITH_PERFSCHEMA_STORAGE_ENGINE:BOOL=ON

#make && make install

c.啟動指令碼

#cp /usr/src/lamp/mysql-cluster-gpl-7.2.5/support-files/mysql.server/etc/rc.d/init.d/mysql5

d.配置檔案

# mkdir /usr/local/mysql/etc

#vim /usr/local/mysql/etc/my.cnf

# cat /usr/local/mysql/etc

[mysqld]

user=mysql

basedir=/usr/local/mysql

datadir=/database

socket=/var/run/mysqld/mysql5.socket

pid-file=/var/run/mysqld/mysql5.pid

general-log

general-log-file=/var/log/mysqld/mysql5-access.log

log-error=/var/log/mysqld/mysql5-error.log

port=3306

e.startup

 

Apache及其相關軟體安裝

//刪除之前安裝的Apache目錄

# rm -rf /usr/local/apache2

# yum install -y openssl* nss-develbzip2-devel libzip-* net-snmp-*  

//yum安裝之後所需要的一些軟體

 

apr-1.4.6.tar.gz  --> 解壓

#./configure --disable-ipv6--enable-threads

#make && make install

……

      Libraries have been installed in:

         /usr/local/apr/lib

……

#echo /usr/local/apr/lib >>/etc/ld.so.conf.d/lamp.conf

//把/usr/local/apr/lib加入庫共享庫目錄中,執行ldconfig命令生效

 

libiconv-1.13.tar.gz --> 解壓

#./configure --enable-static

#make && make install

 

apr-iconv-1.2.1.tar.gz --> 解壓

# ./configure--with-apr=/usr/local/apr/bin/apr-1-config

#make && make install

 

apr-util-1.4.1.tar.gz --> 解壓

#ln -s /usr/src/lamp/apr-iconv-1.2.1/usr/src/lamp/apr-util-1.4.1/apr-iconv

#./configure--with-apr=/usr/local/apr/bin/apr-1-config --with-apr-iconv=./arp-iconv--with-openssl=/usr --with-nss=/usr --with-mysql=/usr/local/mysql--with-iconv=/usr/local

#make && make install

 

pcre-7.9.tar.gz --> 解壓

#./configure --enable-rebuild-chartables--enable-utf8 --enable-newline-is-any --enable-pcregrep-libz --enable-pcregrep-libbz2

# make && make install

 

httpd-2.2.22.tar.gz --> 解壓

# ./configure--enable-modules=all --enable-mods-shared=all --enable-file-cache--enable-cache --enable-disk-cache --enable-mem-cache --enable-dumpio--enable-echo --enable-example --enable-logio --enable-mime-magic--enable-expires --enable-headers --enable-unique-id --enable-proxy--enable-proxy-balancer --enable-proxy-http --enable-proxy-ajp--enable-proxy-connect --enable-ssl --enable-static-ab --enable-http--enable-info --enable-cgi --enable-vhost-alias --enable-so --enable-rewrite--with-apr=/usr/local/apr/bin/apr-1-config--with-apr-util=/usr/local/apr/bin/apu-1-config --with-pcre=/usr/local--with-ssl=/usr --with-mpm=prefork

#make && make install

 

相關配置:

###############################################################################################################

1.中文

/usr/local/apache2/conf/httpd.conf

/usr/local/apache2/conf/extra/httpd-languages.conf

httpd-languages.conf

DefaultLanguage zh-CN       

LanguagePriority zh-CN ...... #修改中文優先順序

 

2.虛擬主機

/usr/local//apache2/conf//httpd.conf

Includeconf/extra/httpd-vhosts.conf

NameVirtualHost*:80

<virtualhost *:80>

  docuementroot /www

  servername    teacher.cluster.com

  customlog   /var/log/httpd/teacher-access.log combined

  errorlog  /var/log/httpd/teacher-error.log

</virtualhost>

 

3.404

/usr/local//apache2/conf//httpd.conf

ErrorDocument404 /404.html

 

4.允許訪問

    Order deny,allow

    Deny from all

 

5.索引

DirectoryIndex index.htmlindex.php

 

6.監控

/usr/local//apache2/conf//httpd.conf

Includeconf/extra/httpd-info.conf

<Location /server-status>

    SetHandlerserver-status

    Order deny,allow

    Deny from all

    Allow from10.1.1.0/255.255.255.0

</Location>

ExtendedStatus On

 ###############################################################################################################

freetype-2.4.9.tar.gz --> 解壓

#./configure

#make && make install

 

libpng-1.5.9.tar.gz --> 解壓

# ./configure --with-zlib-prefix=/usr--with-pkgconfigdir=/usr/lib/pkgconfig/

#make && make install

 

jpegsrc.v8.tar.gz --> 解壓

#./configure && make &&make install

 

# yum install -y imake

xpm-3.4k.tar.gz --> 解壓

#xmkmf -a

#make

# make install.man

 

gd-2.0.36RC1.tar.gz --> 解壓

#./configure--with-libiconv-prefix=/usr/local --with-png=/usr/local--with-freetype=/usr/local --with-fontconfig=/usr --with-jpeg=/usr/local--with-xpm=/usr/local

#make && make install

 

libmcrypt-2.5.8.tar.bz2 --> 解壓

# ./configure--enable-static

#make && make install

 

mhash-0.9.9.9.tar.bz2 --> 解壓

# ./configure

#make && make install

 

mcrypt-2.6.6.tar.gz --> 解壓

# ./configure--with-libiconv-prefix=/usr/local --with-libmcrypt-prefix=/usr/local

# make && make install

 

#yum install -y libxml2  libcurl-devel

 

php-5.3.10.tar.gz --> 解壓

#./configure--with-apxs2=/usr/local/apache2/bin/apxs --disable-ipv6 --with-libxml-dir=/usr--with-openssl=/usr --with-pcre-regex=/usr/local --with-zlib=/usr--with-bz2=/usr --enable-calendar --with-curl=/usr  --with-pcre-dir=/usr/local --enable-ftp--with-openssl-dir=/usr --with-gd=/usr/local --with-jpeg-dir=/usr/local--with-png-dir=/usr/local --with-zlib-dir=/usr/local --with-xpm-dir=/usr--with-freetype-dir=/usr/local --enable-gd-native-ttf --enable-gd-jis-conv--with-mhash=/usr/local --enable-mbstring --with-mcrypt=/usr/local--with-mysql=/usr/local/mysql --with-mysql-sock=/var/run/myqld/mysql5.socket--with-mysqli=/usr/local/mysql/bin/mysql_config --with-snmp=/usr--enable-sockets --enable-zip

# make && make install

 

注意:php一旦編譯失敗,刪除原始碼,重新編譯!!!

 

php相關配置

###############################################################################################################

a. cp/usr/src/lamp/php-5.3.10/php.ini-production /usr/local/lib/php.ini

 

php.ini

1.session

session.save_path = "/tmp/session"    <- session目錄需要建立, 屬性(改成Apache屬主即可)

 

2.  support mysql

mysql.default_socket = /var/run/mysqld/mysql5.socket

mysqli.default_socket = /var/run/mysqld/mysql5.socket

 

3.upload file limit

upload_max_filesize = 2M  #網頁上傳限制

 

b.  /usr/local/apache2/conf/httpd.conf

LoadModule php5_module       modules/libphp5.so    

#確認,無需再次加入,安裝之後自動加入到Apache配置檔案中

 

AddType application/x-httpd-php .php .phtml

AddType application/x-httpd-php-source .phps

#以上兩行需要手動加入

 

c.restart apache(重啟Apache生效)

 

d.add php patch <php編譯完成之後加入擴充套件>

如加入: bcmath擴充套件模組

cd到bcmath的目錄下(php自帶的擴充套件在原始碼目錄的ext目錄下),執行如下操作即可

# phpize  //生成編譯環境和configure檔案

# ./configure

# make install

 

# vi /usr/local/lib/php.ini  //手動加入如下內容到php.ini配置檔案即可

extension_dir ="/usr/local/lib/php/extensions/no-debug-non-zts-20090626/"

extension="bcmath.so"

###############################################################################################################


相關文章