lnmp/Lemp Project Construction {Project Framework # linux_____web_____php_____db # rhel7_____apache__-(libphp5.so)-__php__-(php-mysql)-__mariadb-Server # rhel7_____nginx___-(spawn-fcgi)-__php__-(php-mysql)-__mariadb-Server Installation Package # WEB Program # CGI Manager @ function (1) Listen on port 9000 (2) invoke PHP command @ software spawn-fcgi # PHP program PHP # database program MARIADB-Server # PHP-db Drive php-MySQL config nginx #/etc/nginx/conf.d/Configure Spawn-FCGI #/etc/sysconfig/spawn-fcgi Configuration mariadb-Server Create data File # finished PHP website Test}
lnmp/Lemp Project Building Experiment {[email protected]~]#Mount 172.25.254.250:/content/Mnt[[email protected]~]# rpm-ivh/mnt/item/nginx/other/nginx-1.8.0-1. El7.ngx.x86_64.rpm[[email protected]~]# rpm-ivh/mnt/item/nginx/epel/spawn-fcgi-1.6.3-5. El7.x86_64.rpm[[email protected]~]#Yum Install-Y php mariadb-server php-Mysql[[email protected]~]# cd/etc/nginx/conf.d/[email protected] conf.d]#CPdefault.conf www.bbs.com.conf[[email protected] conf.d]# vim Www.bbs.com.confserver {Listen the; server_name www.bbs.com; Root/usr/share/nginx/bbs.com; Index index.php index.html index.htm; Location~\.php$ {fastcgi_pass127.0.0.1:9000; Fastcgi_index index.php; Fastcgi_param Script_filename/usr/share/nginx/Bbs.com$fastcgi_script_name; Include Fastcgi_params; }}[[email protected] conf.d]#mkdir/usr/share/nginx/Bbs.com[[email protected] conf.d]# systemctl restart Nginx.service[[email protected] conf.d]# vim/etc/sysconfig/spawn-fcgioptions="-u nginx-g nginx-p 9000-c 32-f 1-p/var/run/spawn-fcgi.pid--/usr/bin/php-cgi"[email protected] conf.d]# systemctl start Spawn-Fcgi[[email protected] conf.d]#/sbin/chkconfig spawn-fcgi on[[email protected] conf.d]# Systemctl enable Mariadb.service[[email protected] conf.d]# systemctl start Mariad B.service[[email protected] conf.d]# mysqladmin-U root Password"uplooking"[email protected] php]#CPDiscuz_x3.2_sc_utf8.Zip/tmp/[[Email protected] php]# CD/tmp/[email protected] tmp]#UnzipDiscuz_x3.2_sc_utf8.Zip[email protected] tmp]#CP-R Upload/*/usr/share/nginx/bbs.com/[[email protected] tmp]# chown nginx/usr/share/nginx/bbs.com/-r[[email protected] ~]# echo 172.25.15.10 www.bbs.com >>/etc/hosts}
Project Migration {Migration Priority #数据库>process for other software migrations {1. Migration of Programs2. configuration file Migration3Backup and migration of data files4. Address modification5. Permission Modification}} LNMP Project Migration {Migration Priority #数据库>php Php-mysql spawn-fcgi Migration Process {1. Migration of Programs2. configuration file Migration3Backup and migration of data files4. Address modification5modification of permissions} database migration PHP-related programs Migration} database migration {operation on old machine {1>back up the data file and copy it to the new machine2>Modify the address in the configuration file (the configuration file here is not a database configuration file, but the configuration file of the program that uses the database)} actions on the new machine {1>Install the program and start the service2>Import data files on the old machine3>Modify permissions for a program}} Project migration Experiment {1. Database migration Experiment #实验目的: With the increase of website users, data volume is increasing, the database needs to be expanded, now want to put the database on a single server to solve the problem of insufficient database capacity #实验要求: The database from ServerB-Serverj2. LNMP Project Migration Experiment #实验目的: The original LNMP Service server aging, and now the company bought two new servers, to the LNMP service to the new server; The database is placed on a single server; PHP related programs are placed on a single server #实验要求: Data Library ServerB-->serverj;php Related Programs serverb-->ServerC3. LNMP Project migration and configuration of the second PHP service experiment #实验要求: The original LNMP Service server aging, now the company bought three new servers, to migrate LNMP services to the new server; The database is placed on a single server, and two units, two PHP Services} Please go to Experiment Forum Database Migration detailed experiment {#实验目的: With the increase of website users, the data volume is increasing, the database needs to be expanded, now want to put the database on a single server to solve the problem of insufficient database capacity # Experimental requirements: The database from the ServerB-serverj# Experimental steps:========================================================================serverb{#数据库备份 mysqldump--all-databases-uroot-puplooking >/tmp/mariadb.all.sql <--backing up and exporting database files to/tmp/mariadb.all.sql file #复制到serveri中SCP/tmp/mariadb.all.sql serveri:/tmp #地址的修改<== in the/usr/share/nginx/bbs.com/directory to find files ending in. php, locate the Uplooking keyword in the file, but not output (-Q), instead of outputting the file name of the file. Here uplooking is the password of the database, please make changes according to the actual situation. CD/usr/share/nginx/bbs.com; forIinch$(Find./-name"*.php"); Do grep-Q"uplooking"$i &&Echo$i; Donevim xxx.php #将找到的文件进行修改, change localhost to the IP address of the server where the database resides#define(' uc_dbhost ', ' localhost ');}serverj{#安装mariadb-Server Note version installs the same version of the packetYum Install-Y mariadb-server #开启服务, and set boot service self-systemctl enable Mariadb;systemctl start mariadb #查看数据库文件是否复制成功 ll/tmp/mariadb.all.sql #导入数据库文件 MySQL</tmp/Mariadb.all.sql #授权serverb的spawn-fcgi Accessing the database #1>Authorized IP AddressEcho "Grant all on bbs.* to [e- Mail protected] ' 192.168.0.11 ' identified by ' uplooking ';"| Mysql-u Root-P uplooking #2>Authorized Host nameEcho "Grant all on bbs.* to [e- Mail protected] ' serverb.pod15.example.com ' identified by ' uplooking ';"| Mysql-uuroot-puplooking #更新授权表 mysqladmin-uroot-puplooking flush-Privileges}--------------------------------------------------------------------------#测试serverb {#关闭数据库服务 systemctl stop mariadb}workstation{#通过浏览器登陆www. bbs.com Firefox} #问题和答案 #-U root cannot have spaces;-p uplooking cannot have spaces mysqldump--all-databases-uroot-puplooking >/tmp/Mariadb.all.sql#find Search*. PHP must be in double quotation marksFind./-name"*.php"#mysql登陆方式 MySQL-uroot-puplooking MySQL-U Root-p Enter Password #*.*What do you mean by all the files in the directory? Echo "Grant All on * * to [e-mail protected] ' 192.168.0.11 ' identifide by ' uplooking ';"| Mysql-uroot-puplooking/var/lib/MySQL} LNMP Project Migration Experiment {#实验目的: The server of the original LNMP service aged, now the company bought two new servers, to migrate the LNMP service to the new server; The database is placed on a single server; PHP related programs on one server # Experimental requirements: Database ServerB-->serverj;php Related Programs serverb-->serverc# Experimental steps:===============================================================#第一步--Database migration (ServerB-serverj) serverb{#数据库备份 mysqldump--all-databases-uroot-puplooking >/tmp/mariadb.all.sql <--backing up and exporting database files to/tmp/mariadb.all.sql file #复制到serveri中SCP/tmp/mariadb.all.sql serveri:/tmp #地址的修改<== in the/usr/share/nginx/bbs.com/directory to find files ending in. php, locate the Uplooking keyword in the file, but not output (-Q), instead of outputting the file name of the file. Here uplooking is the password of the database, please make changes according to the actual situation. CD/usr/share/nginx/bbs.com; forIinch$(Find./-name"*.php"); Do grep-Q"uplooking"$i &&Echo$i; Done#将找到的文件进行修改, modify server_name, the IP address of the server where the database resides, vim xxx.php}serverj{#安装mariadb-Server Note version installs the same version of the packetYum Install-Y mariadb-server #开启服务, and set boot service self-systemctl enable Mariadb;systemctl start mariadb #设置数据库密码 mysqladmin-U root Password'uplooking'#查看数据库文件是否复制成功 ll/tmp/mariadb.all.sql #导入数据库文件 MySQL</tmp/Mariadb.all.sql #授权serverb的spawn-fcgi Accessing the database #1>Authorized IP AddressEcho "Grant All on * * to [e-mail protected] ' 192.168.0.11 ' identified by ' uplooking ';"| Mysql-uroot-puplooking #2>Authorized Host nameEcho "Grant All on * * to [e-mail protected] ' serverb.pod15.example.com ' identified by ' uplooking ';"| Mysql-uroot-puplooking #更新授权表 mysqladmin-uroot-puplooking flush-Privileges}}---------------------------------------------------------------------------#第二步 Migration of--php related programs (ServerB-ServerC) serverb{#操作数据 (lazy approach, copy files directly to the past can be)SCP/etc/sysconfig/spawn-fcgi serverc:/etc/sysconfig/spawn-fcgi #将serverb中的php相关文件转移到 ServerC (requires the same directory, preferably packaged in a tar command to be copied to ServerC)Tar-CJF BBS.Tar. bz2/usr/share/nginx/bbs.com;SCPBbs.Tar. bz2 serverc:/usr/share/nginx/bbs.com #地址修改 ServerB in the/etc/nginx/CONF.D directory in the configuration file about PHP configuration PHP point to ServerC address location~\.php$ {fastcgi_pass127.0.0.1:9000; (instead of Servec's address) Fastcgi_index index.php; Fastcgi_param Script_filename/usr/share/nginx/Yeliangcheng.com$fastcgi_script_name; Include Fastcgi_params; }}serverc{#迁移程序--Install the same package PHP PHP-mysql/mnt/item/nginx/epel/spawn-fcgi-1.6.3-5. el7.x86_64.rpm #启动服务并设置开机自启 systemctl start Spawn-fcgi; /sbin/chkconfig spawn-fcgi on #php相关文件Tar-jxf/usr/share/nginx/bbs.com/bbs.Tar. bz2}===================================================================================#测试serverb {#关闭数据库服务 systemctl stop mariadb #关闭spawn-fcgi service Systemctl stop Spawn-fcgi/sbin/chkconfig spawn-fcgi off}workstation{#通过浏览器登陆www. bbs.com Firefox} #问题和解决}
0 Basic Learning Cloud computing and Big Data DBA cluster Architect "enterprise-level operation and maintenance technology and practice Project January 29, 2015 Friday"