安装apache(lap:192.168.176.122)
cd /sur/src
wget https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.34.tar.bz2
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.3.tar.bz2
wget http://mirrors.shu.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
yum install gcc-c++ apr-util-devel pcre* -y
tar jxf httpd-2.4.34.tar.bz2
tar jxf apr-1.6.3.tar.bz2
tar zxf apr-util-1.6.1.tar.gz
mv apr-1.6.3/ /usr/src/httpd-2.4.34/srclib/apr
mv apr-util-1.6.1/ /usr/src/httpd-2.4.34/srclib/apr-util
cd httpd-2.4.34/
./configure --prefix=/usr/local/apache --with-included-apr --with-included-apr-util --with-mpm=worker --enable-rewrite --enable-so
报错:解决方法安装PCRE库
yum install pcre* -y
!conf
上图所示表示预编译成功。
make -j4 && make -j4 install
echo "ServerName localhost:80">> /usr/local/apache/conf/httpd.conf
/usr/local/apache/bin/apachectl start
/usr/local/apache/bin/apachectl start
安装php考虑兼容性建议使用php5.6.37
wget http://cn.php.net/distributions/php-5.6.37.tar.bz2
tar jxf php-5.6.37.tar.bz2
yum install libxml2 lib
./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-apxs2=/usr/local/apache/bin/apxs
make -j4&&make -j4 install
#vim /usr/local/apache/conf/httpd.conf
添加如下内容
AddType application/x-httpd-php .php
DirectoryIndex index.php index.html index.htm
#/usr/local/apache/bin/apachectl restart
安装mysql主从(主192.168.176.121,从192.168.176.123)
cd /usr/src
#wget http://down1.chinaunix.net/distfiles/mysql-5.5.20.tar.gz
# tar –zxf mysql-5.5.20
#cd mysql-5.5.20
#yum install -y gcc c ncurses-devel cmake libaio bison gcc-c++ git cmake ncurses-devel ncurses
#cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql55/
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock
-DMYSQL_DATADIR=/data/mysql
-DSYSCONFDIR=/etc
-DMYSQL_USER=mysql
-DMYSQL_TCP_PORT=3306
-DWITH_XTRADB_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_READLINE=1
-DENABLED_LOCAL_INFILE=1
-DWITH_EXTRA_CHARSETS=1
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DEXTRA_CHARSETS=all
-DWITH_BIG_TABLES=1
-DWITH_DEBUG=0
#make &&make install
#cp /usr/local/mysql55/support/my-large.cnf /etc/my.cnf
#cp /usr/loca;/mysql55/support/mysql.server /etc/init.d/mysqld
#chkconfig --add mysqld
#chkconfig --level 35 mysqld on
#mkdir -p /data/mysql
#useradd mysql
#/usr/local/mysql55/scripts/mysql_install_db --user=mysql --datadir=/data/mysql --basedir=/usr/local/mysql55
#ln -s /usr/local/mysql55/bin/* /usr/bin/
#chown -R mysql /data/mysql/
#service mysqld start
配置主mysql
vim /etc/my.cnf
添加如下两行并重启mysql
server-id=1
log-bin=mysql-bin
授权
mysql>grant replication slave on *.* to tongbu121@'%' identified by "123456";
mysql>show master status;
记住bin-log文件名和pos点
配置从库
vim /etc/my.cnf
添加如下一行并重启mysql
server-id=2
mysql>change master to master_host='192.168.176.121',master_user='tongbu121',master_password='123456',master_log_file='mysql-bin000003',master_log_pos=390;
mysql>start slave;
mysql>show slave statusG;
双yes即只从建立成功,测试一下
主从配置成功
proxy安装配置
cd /usr/src
wget http://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-Proxy/mysql-proxy-0.8.4-linux-el6-x86-64bit.tar.gz
useradd -r mysql-prox
tar zxf mysql-proxy-0.8.4-linux-el6-x86-64bit.tar.gz
mv mysql-proxy-0.8.4-linux-el6-x86-64bit /usr/local/mysql-proxy
echo "export PATH=$PATH:/usr/local/mysql-proxy/bin/">> /etc/profile
source /etc/profile
启动proxy
mysql-proxy --daemon --log-level=debug --user=mysql-proxy --keepalive --log-file=/var/log/mysql-proxy.log --plugins="proxy" --proxy-backend-addresses="192.168.176.121:3306" --proxy-read-only-backend-addresses="192.168.176.123:3306" --proxy-lua-script="/usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua" --plugins=admin --admin-username="admin" --admin-password="admin" --admin-lua-script="/usr/local/mysql-proxy/lib/mysql-proxy/lua/admin.lua"
查看
yum install mysql -y
尝试登录以4041端口mysql-proxy管理平台
状态为unknow,为不正常链接。
systemctl stop firewalld
setenforce 0
关闭防火墙使用下列命令刷新一下
主从创建test1库和t1表(需要主从库上授权mysql-proxy 远程登录mysql)
mysql -h192.168.176.124 -umysql-proxy -p123456 -P4040 -e "select * from test1.t1;"
搭建discuz论坛
OK搭建成功。