码迷,mamicode.com
首页 > Web开发 > 详细

部署社交网站(步骤超详细)

时间:2018-10-01 18:24:56      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:logger   图片   line   libxml2   yum   fsmo   hostname   日志文件   ati   

实验具体任务要求:
1:部署SVN服务器为PHP程序员创建repo目录的访问账户,通知程序员可以导入代码
2:部署MySQL主从服务器,根据PHP程序员要求创建数据库与表
3:部署Nginx服务器
4:部署PHP服务器
5:部署MFS,将MFS文件系统挂载在前端PHP服务器的相关目录下
6:通知上线部署人员可以发布上线
7:保住数据库服务、PHP服务、Nginx服务依次启动,并通知测试人员开始测试,网站维护人员检查Nginx、PHP与数据库服务器是否正常工作
实验拓扑图:
技术分享图片
实验环境介绍:
技术分享图片
具体实验步骤:

-------一:SVN部署 192.168.120.128-----------------------

hostnamectl set-hostname svn
bash
[root@svn ~]# systemctl stop firewalld.service
[root@svn ~]# setenforce 0
[root@svn ~]# yum install subversion -y
[root@svn ~]# mkdir -p /opt/svn/repo #创建目录
[root@svn ~]# svnadmin create /opt/svn/repo #创建一个新的仓库
[root@svn ~]# vim /opt/svn/repo/conf/svnserve.conf

第19行 anon-access = none #匿名用户u没有任何权限
第20行 auth-access = write #认证用户具有写的权限
第27行 password-db = /opt/svn/repo/conf/passwd #用户的密码文件
第34行 authz-db = /opt/svn/repo/conf/authz #用户的信息文件

[root@svn ~]# svnserve -d -r /opt/svn/repo/
[root@svn ~]# netstat -natp | grep svnserve
tcp 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 49381/svnserve
#创建一个用户配置passwd文件
[root@svn ~]# vim /opt/svn/repo/conf/passwd
末尾插入
zhangsan=123
sysadmin=123

#配置authz文件给zhangsan用户赋权读写
[root@svn ~]# vim /opt/svn/repo/conf/authz

末尾插入
[/]
zhangsan = rw
sysadmin = rw

[/webphp]
zhangsan = rw
sysadmin = rw

#注释用不到的
#[aliases]
#[groups]
[root@svn ~]# cd /opt/svn/repo/
[root@svn repo]# mkdir webphp #创建webphp文件夹
[root@svn repo]# touch webphp/abc.txt webphp/123.txt #导入webphp测试文件
[root@svn repo]# svn import webphp file:///opt/svn/repo/webphp -m "initial" #初始化webphp目录
正在增加 webphp/abc.txt
正在增加 webphp/123.txt
提交后的版本为 1。

-------------------------二:部署Nginx服务器 192.168.120.139---------------------
#安装环境包
[root@nginx ~]# systemctl stop firewalld.service
[root@nginx ~]# setenforce 0
[root@nginx ~]# yum install pcre-devel zlib-devel -y
[root@nginx ~]# useradd -M -s /sbin/nologin nginx #添加管理nginx的用户和组
[root@nginx ~]# mkdir /abc
[root@nginx ~]# mount.cifs //192.168.100.10/rhel6 /abc
Password for root@//192.168.100.10/rhel6:
[root@nginx ~]# cd /abc
[root@nginx abc]# cd LNMP/
[root@nginx LNMP]# tar xzvf nginx-1.6.0.tar.gz -C /opt
[root@nginx LNMP]# cd /opt/nginx-1.6.0/
[root@nginx nginx-1.6.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module
[root@nginx nginx-1.6.0]# make && make install
#编译安装
修改nginx配置文件中的fastcgi访问接口,用于访问PHP页面。
末尾插入
[root@nginx nginx-1.6.0]# vim /usr/local/nginx/conf/nginx.conf
location / {
root html/webphp;
index index.html index.htm;
}

    location ~\.php$ {
        root /var/www/html/webphp;  #指定PHP服务器站点家目录
     fastcgi_pass 192.168.137.12:9000;  #指定PHP服务器地址及端口
    fastcgi_index index.php;
    include fastcgi.conf;
    }

[root@nginx nginx-1.6.0]# nginx
[root@nginx nginx-1.6.0]# netstat -ntap | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 8149/nginx: master

---------------------------三:部署PHP服务器 192.168.137.12------------------
[root@php ~]# systemctl stop firewalld.service
[root@php ~]# setenforce 0
ps:通过配置php-fpm进程监听9000端口来接受Nginx的请求
#安装环境包和依赖包
[root@php ~]# yum install gd libxml2-devel libjpeg-devel libpng-devel mysql-devel gcc gcc-c++ make -y
[root@php ~]# mkdir /abc
[root@php ~]# mount.cifs //192.168.100.10/rhel6 /abc
Password for root@//192.168.100.10/rhel6:
[root@php ~]# cd /abc/Y2C/
[root@php ~]# tar zxvf php-5.3.28.tar.gz -C /opt/
[root@php Y2C]# cd /opt/php-5.3.28/
[root@php php-5.3.28]# useradd -M -s /sbin/nologin php
[root@php php-5.3.28]# cp /usr/lib64/mysql/libmysqlclient.so.18.0.0 /usr/lib/libmysqlclient.so
[root@php php-5.3.28]# ./configure --prefix=/usr/local/php --with-gd --with-zlib --with-mysql --with-mysqli --with-mysql-sock --with-config-file-path=/usr/local/php --enable-mbstring --enable-fpm --with-jpeg-dir=/usr/lib
[root@php php-5.3.28]# make && make install
#修改配置文件和进行一些优化
[root@php php-5.3.28]# cp php.ini-development /usr/local/php/php.ini
[root@php php-5.3.28]# ln -s /usr/local/php/bin/ /usr/local/bin/
[root@php php-5.3.28]# ln -s /usr/local/php/sbin/
/usr/local/sbin/
#开启fpm模块
[root@php php-5.3.28]# cd /usr/local/php/etc
[root@php etc]# cp php-fpm.conf.default php-fpm.conf
[root@php etc]# vim php-fpm.conf

;pid = run/php-fpm.pid
;user = php
;group = php
;listen = 0.0.0.0:9000
;pm.max_childre = 50
;pm.start_servers = 20
;pm.min_spare_servers = 5
;pm.max_spare_servers = 35

listen = 0.0.0.0:9000 #监听所有ip

#启动php-fpm进程,查看9000端口开启
[root@php etc]# /usr/local/sbin/php-fpm
[root@php etc]# netstat -ntap | grep 9000
tcp 0 0 0.0.0.0:9000 0.0.0.0:* LISTEN 22353/php-fpm: mast
#创建php服务器站点
[root@php etc]# mkdir -p /var/www/html/webphp
[root@php etc]# vim /var/www/html/webphp/index.php
this is web

-----------四:部署MySQL 主从服务 192.168.120.145/192.168.120.146------------------
(以下步骤两台同样操作)
[root@master ~]# systemctl stop firewalld.service
[root@master ~]# setenforce 0
[root@master ~]# yum install gcc gcc-c++ make cmake ncurses-devel bisonlibaio-devel -y
[root@master ~]# useradd -s /sbin/nologin mysql
[root@master ~]# mkdir -p /usr/local/mysql
[root@master ~]# mkdir /abc
[root@master ~]# mount.cifs //192.168.100.10/rhel6 /abc
Password for root@//192.168.100.10/rhel6:
[root@master ~]# cd /abc/LAMP/
[root@master LAMP]# tar zxvf mysql-5.5.24.tar.gz -C /opt/
[root@master LAMP]# cd /opt/mysql-5.5.24/
[root@master mysql-5.5.24]#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/home/mysql \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306

[root@master mysql-5.5.24]# make && make install
[root@master mysql-5.5.24]# chown -R mysql.mysql /usr/local/mysql
[root@master mysql-5.5.24]# cp support-files/my-medium.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
[root@master mysql-5.5.24]# vim /etc/profile
末尾添加
export PATH=$PATH:/usr/local/mysql/bin/
[root@master mysql-5.5.24]# source /etc/profile
[root@master mysql-5.5.24]# cp support-files/mysql.server /etc/init.d/mysqld
[root@master mysql-5.5.24]# chkconfig --add mysqld
[root@master mysql-5.5.24]#chkconfig mysqld --level 35 on
#初始化mysql
[root@master mysql-5.5.24]#/usr/local/mysql/scripts/mysql_install_db \
--user=mysql \
--ldata=/var/lib/mysql \
--basedir=/usr/local/mysql \
--datadir=/home/mysql

[root@master mysql-5.5.24]# chmod +x /etc/init.d/mysqld
[root@master mysql-5.5.24]# ln -s /var/lib/mysql/mysql.sock /home/mysql/mysql.sock
[root@master mysql-5.5.24]# vim /etc/init.d/mysqld
第46行 basedir=/usr/local/mysql
第47行 datadir=/home/mysql

#启动MySQL服务
[root@master mysql-5.5.24]# systemctl daemon-reload
[root@master mysql-5.5.24]# service mysqld start
Starting MySQL.. SUCCESS!
#给root用户设置密码
[root@master mysql-5.5.24]# mysqladmin -u root -p password ‘123123‘
Enter password:
#登录MySQL
[root@master mysql-5.5.24]# mysql -u root -p
Enter password:
-----------------MySQL主从配置----------------------------------
##Master服务器配置##
[root@master mysql-5.5.24]# vim /etc/my.cnf
第57行 server-id = 11
第58行 log-slave-updates=true

[root@master mysql-5.5.24]# systemctl restart mysqld.service
[root@master mysql-5.5.24]# mysql -u root -p
mysql> grant replication slave on . to ‘adm‘@‘192.168.120.%‘ identified by ‘123‘;
Query OK, 0 rows affected (0.00 sec)#授权给192.168.120.0网段的服务器同步权限
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)#刷新
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000004 | 332 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

##Slave服务器配置##
[root@slave mysql-5.5.24]# vim /etc/my.cnf
第57行 server-id = 22 //id和主服务器不能一致//
第58行 relay-log=relay-log-bin //从主服务器上同步日志文件记录到本地//
第59行 relay-log-index=slave-relay-bin.index //定义relay-log的位置和名称//

[root@slave mysql-5.5.24]# systemctl restart mysqld.service
[root@slave mysql-5.5.24]# mysql -u root -p
mysql> change master to master_host=‘192.168.120.145‘,master_user=‘adm‘,master_password=‘123‘,master_log_file=‘mysql-bin.000004‘,master_log_pos=332;
Query OK, 0 rows affected (0.00 sec)

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

mysql> show slave status \G;
Slave_IO_Running: Yes
Slave_SQL_Running: Yes

##两条YES则MYSQL主从复制完成##

-------------五:MFS 文件系统部署----------------------------
master server 192.168.120.134
metalogger 192.168.120.147
chunk1 192.168.120.135
chunk2 192.168.120.148
chunk3 192.168.120.137

##搭建Master Server##
[root@mfsmaster ~]# systemctl stop firewalld.service
[root@mfsmaster ~]# setenforce 0
[root@mfsmaster ~]#yum install gcc gcc-c++ zlib-devel -y
[root@mfsmaster ~]# useradd -s /sbin/nologin mfs
[root@mfsmaster ~]# mkdir /abc
[root@mfsmaster ~]# mount.cifs //192.168.100.10/rhel6 /abc
Password for root@//192.168.100.10/rhel6:
[root@mfsmaster ~]# cd /abc/Y2C
[root@mfsmaster Y2C]# tar zxvf mfs-1.6.27-5.tar.gz -C /opt/
[root@mfsmaster Y2C]# cd /opt/mfs-1.6.27/
[root@mfsmaster mfs-1.6.27]#./configure \
--prefix=/usr/local/mfs \
--with-default-user=mfs \
--with-default-group=mfs \
--disable-mfschunkserver \
--disable-mfsmount
[root@mfsmaster mfs-1.6.27]# make && make install
[root@mfsmaster mfs-1.6.27]# cd /usr/local/mfs/etc/mfs/
[root@mfsmaster mfs]# ls
mfsexports.cfg.dist mfsmaster.cfg.dist mfsmetalogger.cfg.dist mfstopology.cfg.dist
[root@mfsmaster mfs]# cp mfsexports.cfg.dist mfsexports.cfg
[root@mfsmaster mfs]# cp mfsmaster.cfg.dist mfsmaster.cfg
[root@mfsmaster mfs]# cp mfstopology.cfg.dist mfstopology.cfg
[root@mfsmaster mfs]# cd /usr/local/mfs/var/mfs/
[root@mfsmaster mfs]# cp metadata.mfs.empty metadata.mfs
[root@mfsmaster mfs]# /usr/local/mfs/sbin/mfsmaster start
working directory: /usr/local/mfs/var/mfs
lockfile created and locked
initializing mfsmaster modules ...
loading sessions ... file not found
if it is not fresh installation then you have to restart all active mounts !!!
exports file has been loaded
mfstopology: incomplete definition in line: 7
mfstopology: incomplete definition in line: 7
mfstopology: incomplete definition in line: 22
mfstopology: incomplete definition in line: 22
mfstopology: incomplete definition in line: 28
mfstopology: incomplete definition in line: 28
topology file has been loaded
loading metadata ...
create new empty filesystemmetadata file has been loaded
no charts data file - initializing empty charts
master <-> metaloggers module: listen on :9419
master <-> chunkservers module: listen on
:9420
main master server module: listen on :9421
mfsmaster daemon initialized properly
[root@mfsmaster mfs]# netstat -ntap | grep mfsmaster
tcp 0 0 0.0.0.0:9419 0.0.0.0:
LISTEN 47534/mfsmaster
tcp 0 0 0.0.0.0:9420 0.0.0.0: LISTEN 47534/mfsmaster
tcp 0 0 0.0.0.0:9421 0.0.0.0:
LISTEN 47534/mfsmaster

##搭建MetalLogger Server##
[root@logger ~]# systemctl stop firewalld.service
[root@logger ~]# setenforce 0
[root@logger ~]#yum install gcc gcc-c++ zlib-devel -y
[root@logger ~]# useradd -s /sbin/nologin mfs
[root@logger ~]# mkdir /abc
[root@logger ~]# mount.cifs //192.168.100.10/rhel6 /abc
Password for root@//192.168.100.10/rhel6:
[root@logger ~]# cd /abc/Y2C/
[root@logger Y2C]# tar zxvf mfs-1.6.27-5.tar.gz -C /opt/
[root@logger Y2C]# cd /opt/mfs-1.6.27/
[root@logger mfs-1.6.27]# ./configure \
--prefix=/usr/local/mfs \
--with-default-user=mfs \
--with-default-group=mfs \
--disable-mfschunkserver \
--disable-mfsmount
[root@logger mfs-1.6.27]# make && make install
[root@logger mfs-1.6.27]# cd /usr/local/mfs/etc/mfs/
[root@logger mfs]# cp mfsexports.cfg.dist mfsexports.cfg
[root@logger mfs]# cp mfsmaster.cfg.dist mfsmaster.cfg
[root@logger mfs]# cp mfsmetalogger.cfg.dist mfsmetalogger.cfg
[root@logger mfs]# vim mfsmetalogger.cfg

第15行 MASTER_HOST = 192.168.120.134 #去除注释,改地址指向主服务器

[root@logger etc]# cd /usr/local/mfs/var/mfs/
[root@logger mfs]# cp metadata.mfs.empty metadata.mfs
[root@logger mfs]# /usr/local/mfs/sbin/mfsmetalogger start
working directory: /usr/local/mfs/var/mfs
[root@logger mfs]# netstat -ntap | grep mfs
tcp 0 0 192.168.120.147:57462 192.168.120.134:9419 ESTABLISHED 52148/mfsmetalogger

-------------------六:搭建Chunk Server(三台搭建一样)---------------------
#关闭防火墙
[root@chunk1 ~]# systemctl stop firewalld.service
[root@chunk1 ~]# setenforce 0
[root@chunk1 ~]# yum install gcc gcc-c++ zlib-devel -y
[root@chunk1 ~]# useradd -s /sbin/nologin mfs
[root@chunk1 ~]# mkdir /abc
[root@chunk1 ~]# mount.cifs //192.168.100.10/rhel6 /abc
Password for root@//192.168.100.10/rhel6:
[root@chunk1 ~]# cd /abc/Y2C/
[root@chunk1 Y2C]# tar zxvf mfs-1.6.27-5.tar.gz -C /opt/
[root@chunk1 Y2C]# cd /opt/mfs-1.6.27/
[root@chunk1 mfs-1.6.27]#./configure \
--prefix=/usr/local/mfs \
--with-default-user=mfs \
--with-default-group=mfs \
--disable-mfsmaster \
--disable-mfsmount
[root@chunk1 mfs-1.6.27]# make && make install
[root@chunk1 mfs-1.6.27]# cd /usr/local/mfs/etc/mfs/
[root@chunk1 mfs]# cp mfschunkserver.cfg.dist mfschunkserver.cfg
[root@chunk1 mfs]# cp mfshdd.cfg.dist mfshdd.cfg
[root@chunk1 mfs]# vim mfschunkserver.cfg
第12行 MASTER_HOST = 192.168.120.134

[root@chunk1 mfs]# vim mfshdd.cfg
#按G到末尾插入路径
/data

[root@chunk1 mfs]# mkdir /data
[root@chunk1 mfs]# chown -R mfs.mfs /data/
[root@chunk1 mfs]# /usr/local/mfs/sbin/mfschunkserver start
working directory: /usr/local/mfs/var/mfs
[root@chunk1 mfs]# netstat -ntap | grep mfschunkserve
tcp 0 0 0.0.0.0:9422 0.0.0.0:* LISTEN 14274/mfschunkserve
tcp 0 0 192.168.120.135:44916 192.168.120.134:9420 ESTABLISHED 14274/mfschunkserve

----------------七:MFS挂载(到PHP上192.168.120.144)------------------------

[root@php ~]# cd /abc/Y2C/
[root@php Y2C]# tar zxvf fuse-2.9.2.tar.gz -C /opt
[root@php Y2C]# cd /opt/fuse-2.9.2/
[root@php fuse-2.9.2]# ./configure
[root@php fuse-2.9.2]# make && make install
[root@php fuse-2.9.2]# vim /etc/profile
按G到末尾插入
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH

[root@php fuse-2.9.2]# source /etc/profile
[root@php fuse-2.9.2]# cd /abc/Y2C/
[root@php Y2C]# tar zxvf mfs-1.6.27-5.tar.gz -C /opt/
[root@php Y2C]# cd /opt/mfs-1.6.27/
[root@php mfs-1.6.27]#./configure \
--prefix=/usr/local/mfs \
--with-default-user=mfs \
--with-default-group=mfs \
--disable-mfsmaster \
--disable-mfschunkserver \
--enable-mfsmount

[root@php mfs-1.6.27]# make && make install
[root@php mfs-1.6.27]# mkdir /opt/mfs
[root@php mfs-1.6.27]# modprobe fuse
[root@php mfs-1.6.27]# /usr/local/mfs/bin/mfsmount /opt/mfs -H 192.168.120.134
[root@php mfs-1.6.27]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda1 20G 4.5G 16G 23% /
devtmpfs 474M 0 474M 0% /dev
tmpfs 489M 0 489M 0% /dev/shm
tmpfs 489M 14M 475M 3% /run
tmpfs 489M 0 489M 0% /sys/fs/cgroup
/dev/sda2 10G 35M 10G 1% /home
/dev/sda3 5.0G 303M 4.7G 6% /opt
/dev/sda6 1018M 329M 689M 33% /var
tmpfs 98M 32K 98M 1% /run/user/0
/dev/sr0 4.3G 4.3G 0 100% /run/media/root/CentOS 7 x86_64
//192.168.100.10/rhel6 311G 206G 106G 67% /abc
192.168.120.134:9421 47G 0 47G 0% /opt/mfs

-------------------------八:发布上线------------------------
[root@nginx ~]# yum install subversion -y
[root@nginx ~]# cd /usr/local/nginx/html/
[root@nginx html]# svn co svn://192.168.120.128/webphp
//根据提示使用账户 sysadmin 登录,即可部署代码
总结:内容很多,具体安装包,在我往期博客中有下载地址。

部署社交网站(步骤超详细)

标签:logger   图片   line   libxml2   yum   fsmo   hostname   日志文件   ati   

原文地址:http://blog.51cto.com/13756916/2288326

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!