Generally, the architecture deployment is in two formats: LNMP and LAMP. Here I am talking about LNMP architecture deployment, nginx, mysql, php, and memcache compilation configuration installation, mysql Master/Slave configuration and permission issues, background monitoring of nagio, cacti, zabbix introduction,
######################################## ##################################
Before deploying the architecture, install the necessary libraries,
Install required Libraries
Yum-y groupinstall "Development tools"
Yum install-y gcc-c ++ make cmake zlib-devel openssh openssl-devel net-snmp pcre-devel libjpeg-devel libpng-devel freetype-devel libxml2 libxml2-devel glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses-devel curl-devel kernel e2fsprogs-devel xinetd lrzsz dos2unix telnet python-devel mysql-devlibel XSLT-devel unixODBC-devel sqlite-devel
######################################## ##################################
Mysql compilation and installation and some extensions
1.1 mysql source code compilation and installation, Mysql 5.6.14
: Http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.14.tar.gz
Check whether mysql has been installed before,
Rpm-qa | grep mysql
If yes, delete it.
Rpm-e mysql // normal deletion Mode
Rpm-e -- nodeps mysql // strong deletion mode. If the above command is used to delete other dependent files, you can use this command to forcibly delete them.
Compile and install cmake. Install cmake first.
Yum-y install cmake
Cd/app
Groupadd mysql
Useradd mysql-g mysql
Mkdir-p/usr/local/mysq
Mkdir-p/app/mysql/data
Mkdir-p/app/mysql/log
Tar zxvf mysql-5.6.14.tar.gz
Cd mysql-5.6.14
Cmake \
-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \
-DMYSQL_UNIX_ADDR =/usr/local/mysql. sock \
-DDEFAULT_CHARSET = utf8 \
-DDEFAULT_COLLATION = utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE = 1 \
-DWITH_INNOBASE_STORAGE_ENGINE = 1 \
-DWITH_ARCHIVE_STORAGE_ENGINE = 1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE = 1 \
-DWITH_MEMORY_STORAGE_ENGINE = 1 \
-DWITH_READLINE = 1 \
-DENABLED_LOCAL_INFILE = 1 \
-DMYSQL_DATADIR =/app/mysql/data \
-DMYSQL_USER = mysql \
-DMYSQL_TCP_PORT = 3306
Make
Make install
Make clean
Chown-R mysql: mysql/usr/local/mysql
Chown-R mysql: mysql/app/mysql/data
Chown-R mysql: mysql/app/mysql/log
Cd/usr/local/mysql
Scripts/mysql_install_db -- user = mysql -- datadir =/app/mysql/data
/Usr/local/mysql/bin/mysqld_safe &
Cp support-files/mysql. server/etc/init. d/mysql
Ln-s/usr/local/mysql/bin/mysql/usr/bin
Ln-s/usr/local/mysql/bin/mysql/usr/sbin
Chkconfig mysql on
Service mysql start
1.2 database account Permissions
Mysql gives permissions:
Grant permission on database. * username @ login host identified by "password"
Example: grant all on *. * to root@10.240.53.98 identified by "123456"
Refresh: fulsh privileges
1.3 Database Backup mysqldump
Export data using mysqldump
A. Only export the table structure
Mysqldump -- opt-d database name-u username-p password> xx. SQL
For example, mysqldump -- opt-d shop_data-u root-p admin> onlystruct_shop_data. SQL
B. Export data only
Mysqldump-t database name-u username-p password> xx. SQL
For example, mysqldump -- t shop_data-u root-p admin> onlydata_shop_data. SQL
C. Export all data and structures
Mysqldump database-u username-p password> xx. SQL
For example, mysqldump shop_data-u root-p admin> shop_data. SQL
D. Export a specific table
Mysqldump database-u username-p password-B -- table Name> xx. SQL
For example, mysqldump shop_data-u root-p admin-B -- table user> user. SQL
Default font format -- default-character-set = utf8
1.4 import data sources
Source import data
Source/home/root/XX. SQL can only be used after logging on to mysql-uroot-padmin
For example, source/home/root/test. SQL
1.5. Change the Database Password mysqladmin
Mysql password change:
Add the new password mysqladmin-uroot password
Old password Change New password: mysqladmin-uroot-p old password New password
######################################## ##################################
Nginx compilation and Installation
2.1 Download the installation package
Wget http://nginx.org/download/nginx-1.5.7.tar.gz
2.2 resolve Dependencies
To compile and install nginx, you must first install the Development package group "Development Tools" and "Development Libraries ". You also need to install the pcre-devel package:
Yum groupinstall "Development Tools"-y
Yum-y install pcre-devel
2.3 compile and install
First, add the user nginx to run the nginx service process:
Groupadd-r nginx
Useradd-r-g nginx
Tar -xzvfnginx-1.5.7.tar.gz
Then start compilation and installation:
. /Configure -- prefix =/usr/local/nginx -- sbin-path =/usr/sbin/nginx -- conf-path =/etc/nginx. conf -- error-log-path =/var/log/nginx/error. log -- http-log-path =/var/log/nginx/access. log -- pid-path =/var/run/nginx. pid -- lock-path =/var/lock/nginx. lock -- user = nginx -- group = nginx -- with-http_ssl_module -- with-http_flv_module -- with-http_stub_status_module -- with-http_gzip_static_module -- http-client-body-temp-path =/var/tmp/nginx/client -- http-proxy -temp-path =/var/tmp/nginx/proxy -- http-fastcgi-temp-path =/var/tmp/nginx/fcgi -- http-uwsgi-temp-path =/ var/tmp/nginx/uwsgi -- http-scgi-temp-path =/var/tmp/nginx/scgi -- with-pcre
Make & make install
Cp/app/nginx-1.7.0/conf/nginx. conf/etc/nginx. conf
(If you want to use nginx perl module, you can add the -- with-http_perl_module option for the configure script to achieve, but the current module is still in the experimental use stage, may appear in the operation of unexpected, therefore, the implementation method is not described here. If you want to use the nginx-based cgi function, you can also implement it based on FCGI. For specific implementation methods, refer to the online documentation.
2.3. Provide SysV init script for nginx:
Create a file/etc/rc. d/init. d/nginx with the following content:
Vim/etc/rc. d/init. d/nginx
#! /Bin/sh
#
# Nginx-this script starts and stops the nginx daemon
#
# Chkconfig:-85 15
# Description: Nginx is an HTTP (S) server, HTTP (S) reverse \
# Proxy and IMAP/POP3 proxy server
# Processname: nginx
# Config:/etc/nginx. conf
# Config:/etc/sysconfig/nginx
# Pidfile:/var/run/nginx. pid
# Source function library.
./Etc/rc. d/init. d/functions
# Source networking configuration.
./Etc/sysconfig/network
# Check that networking is up.
["$ NETWORKING" = "no"] & exit 0
Nginx = "/usr/sbin/nginx"
Prog = $ (basename $ nginx)
NGINX_CONF_FILE = "/etc/nginx. conf"
[-F/etc/sysconfig/nginx] &./etc/sysconfig/nginx
Lockfile =/var/lock/subsys/nginx
Make_dirs (){
# Make required directories
User = 'nginx-V 2> & 1 | grep "configure arguments:" | sed's/[^ *] * -- user = \ ([^] * \). */\ 1/G '-'
Options = '$ nginx-V 2> & 1 | grep' configure arguments :''
For opt in $ options; do
If ['echo $ opt | grep'. *-temp-path'']; then
Value = 'echo $ opt | cut-d "="-f 2'
If [! -D "$ value"]; then
# Echo "creating" $ value
Mkdir-p $ value & chown-R $ user $ value
Fi
Fi
Done
}
Start (){
[-X $ nginx] | exit 5
[-F $ NGINX_CONF_FILE] | exit 6
Make_dirs
Echo-n $ "Starting $ prog :"
Daemon $ nginx-c $ NGINX_CONF_FILE
Retval =$?
Echo
[$ Retval-eq 0] & touch $ lockfile
Return $ retval
}
Stop (){
Echo-n $ "Stopping $ prog :"
Killproc $ prog-QUIT
Retval =$?
Echo
[$ Retval-eq 0] & rm-f $ lockfile
Return $ retval
}
Restart (){
Configtest | return $?
Stop
Sleep 1
Start
}
Reload (){
Configtest | return $?
Echo-n $ "Reloading $ prog :"
Killproc $ nginx-HUP
RETVAL =$?
Echo
}
Force_reload (){
Restart
}
Configtest (){
$ Nginx-t-c $ NGINX_CONF_FILE
}
Rh_status (){
Status $ prog
}
Rh_status_q (){
Rh_status>/dev/null 2> & 1
}
Case "$1" in
Start)
Rh_status_q & exit 0
$1
;;
Stop)
Rh_status_q | exit 0
$1
;;
Restart | configtest)
$1
;;
Reload)
Rh_status_q | exit 7
$1
;;
Force-reload)
Force_reload
;;
Status)
Rh_status
;;
Condrestart | try-restart)
Rh_status_q | exit 0
;;
*)
Echo $ "Usage: $0 {start | stop | status | restart | condrestart | try-restart | reload | force-reload | configtest }"
Exit 2
Esac
Chmod u + x/etc/rc. d/init. d/nginx
Chkconfig -- add nginx
Chkconfig nginx on
Service nginx start
######################################## ######################################## ####
Install memcached
3.1 download the installation package
Download memcached-1.4.15.tar.gz installation package
Wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
3.2 install dependency
Yum install libevent-devel-y
3.3 compile and install
Cd/app/
Tar-xvzf memcached-1.4.15.tar.gz
Cd memcached-1.4.15
./Configure
Make
Make install
Memcache-d-m 64-u root-p 11211-c 10000-P/tmp/memcached. pid
---------------------------------------------------------------------
Start ::
Memcache-d-m 64-u root-p 11211-c 10000-P/tmp/memcached. pid
Shutdown:
Kill 'cat/tmp/memcached. Pi'
----------------------------------------------------------------------
Startup Parameter Parsing
D: Start a daemon,
-M indicates the amount of memory allocated to Memcache. The unit is MB. Here I am 10 MB,
-U is the user who runs Memcache. Here I am root,
-L is the IP address of the listening server. If there are multiple IP addresses, I have specified the IP address 192.168.0.200,
-P is the port for Memcache listening. I have set port 12000 here, preferably port 1024 or above,
-The "c" option is the maximum number of concurrent connections. The default value is 1024. I have set 256 here, which is based on the load of your server,
-P is the pid file for saving Memcache. Here I save it in/tmp/memcached. pid,
######################################## ######################################## ####
Php installation
4.1 download the installation package
Wget http: // 115.182.6.10: 8080/src/php-5.4.23.tar.gz
4.2 install dependency
Yum-y install libmcrypt-devel
Compile and install
Tar zxvf php-5.4.23.tar.gz
Cd php-5.4.23
./Configure -- prefix =/usr/local/php -- enable-fpm -- with-mcrypt -- with-openssl \
-- Enable-mbstring -- enable-pdo -- with-curl -- disable-debug -- disable-rpath \
-- Enable-inline-optimization -- with-bz2 -- with-zlib -- enable-sockets \
-- Enable-sysvsem -- enable-sysvshm -- enable-pcntl -- enable-mbregex \
-- With-mhash -- enable-zip -- with-pcre-regex -- with-mysql -- with-mysqli \
-- With-gd -- with-jpeg-dir
Make
Make test
Make install
Sh/bin/iptables. sh
Start
/Usr/local/php/sbin/php-fpm-c/usr/local/php/etc/php-fpm.conf
Cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
Install php in yum
Iptables-F
Yum install-y httpd
Yum-y install -- enablerepo = remi php
Yum-y install -- enablerepo = remi php-pdo
Yum-y install -- enablerepo = remi php-mysql
Yum-y install -- enablerepo = remi php-pear
Yum-y install -- enablerepo = remi php-mcrypt
Yum-y install -- enablerepo = remi php-pear-DB
Yum-y install -- enablerepo = remi php-mbstring
Yum-y install -- enablerepo = remi php-devel
Yum-y install -- enablerepo = remi php-gd
Yum-y install -- enablerepo = remi zlib-devel
Yum-y install -- enablerepo = remi pcre-devel
Yum -- enablerepo = remi install php-memcache
Printf "\ n" | pecl install apc
Printf "\ n" | pecl install memcache
Pecl install redis
Yum-y remove libmcrypt
Yum-y install libmcrypt-devel
Sh/bin/iptables. sh
######################################## ######################################## ####
Redis Installation
5.1 download the installation package
Wget http: // 115.182.6.10: 8080/src/redis-2.8.3.tar.gz
5.2 compile and install
Tar zxvf redis-2.8.3.tar.gz
Cd redis-2.8.3
Make
Make install
5.3 configuration parameters: redis. conf
Vim/usr/local/redis/etc/redis. conf
---------------------------------------------------------
#! /Bin/bash
Daemonize yes
Pidfile/usr/local/redis/var/redis. pid
Port 6379
Timeout 300
Loglevel debug
Logfile/usr/local/redis/var/redis. log
Databases 16
Save 900 1
Save 300 10
Save 60 10000
Rdbcompression yes
Dbfilename dump. rdb
Dir/usr/local/redis/var/
Appendonly no
Appendfsync always
Glueoutputbuf yes
Objects no
Shareobjectspoolsize 1024
---------------------------------------------------------------------------
Cp/usr/local/redis/etc/redis. conf/app/redis-2.8.3/redis. conf
Start redis
Cd/app/redis-2.6.7/src/
./Redis-server
This article from the "Flying Eagles" blog, please be sure to keep this source http://749806593.blog.51cto.com/6662384/1373404