本文共 9660 字,大约阅读时间需要 32 分钟。
主机 | 系统 | IP |
---|---|---|
Client | 6 | 172.22.46.10 |
powerdns | 7 | 172.22.46.70 |
route | 7 | 172.22.46.57;192.168.15.107;10.0.0.200 |
LVS | 7 | 192.168.15.108;10.0.0.100 |
webSV1 | 7 | 192.168.15.111;10.0.0.100 |
webSV2 | 7 | 192.168.15.112;10.0.0.100 |
proxysql | 7 | 192.168.15.113 |
mysqlmaster | 7 | 192.168.15.114 |
mysqlslave1 | 7 | 192.168.15.115 |
mysqlslave2 | 7 | 192.168.15.116 |
NFS | 7 | 192.168.15.118 |
NFSbak | 7 | 192.168.15.119 |
vim /etc/my.cnf[mysqld]log-bin=/data/bin/mysql-binbinlog-format=rowserver-id=4
mkdir /data/binchown -R mysql.mysql /data/bin
systemctl start mariadb
mysql -e "GRANT REPLICATION SLAVE ON *.* TO 'repluser'@'192.168.73.%' IDENTIFIED BY 'centos';"
mysql -e "SHOW MASTER LOGS;"+------------------+-----------+| Log_name | File_size |+------------------+-----------+| mysql-bin.000003 | 245 |+------------------+-----------+
vim /etc/my.cnf[mysqld]read-onlyserver-id=5
systemctl start mariadb
CHANGE MASTER TO MASTER_HOST='192.168.15.114',MASTER_USER='repluser',MASTER_PASSWORD='centos',MASTER_PORT=3306,MASTER_LOG_FILE='mysql-bin.000003',MASTER_LOG_POS=245;
MariaDB [(none)]> START SLAVE;MariaDB [(none)]> SHOW SLAVE STATUS\G;
MariaDB [(none)]> CREATE DATABASE DB1;
vim /etc/my.cnf[mysqld]read-onlyserver-id=6
systemctl start mariadb
CHANGE MASTER TO MASTER_HOST='192.168.15.114',MASTER_USER='repluser',MASTER_PASSWORD='centos',MASTER_PORT=3306,MASTER_LOG_FILE='mysql-bin.000003',MASTER_LOG_POS=245;
MariaDB [(none)]> START SLAVE;MariaDB [(none)]> SHOW SLAVE STATUS\G;
MariaDB [(none)]> CREATE DATABASE DB2;
cat <<EOF | tee /etc/yum.repos.d/proxysql.repo
[proxysql_repo]name= ProxySQL YUM repositorybaseurl= gpgcheck=1gpgkey=EOFyum repolistyum install proxysql mariadb -yservice proxysql start
mysql -uadmin -padmin -P6032 -h127.0.0.1
MySQL [(none)]>insert into mysql_servers(hostgroup_id,hostname,port)values(10,'192.168.15.115',3306);
MySQL [(none)]>insert into mysql_servers(hostgroup_id,hostname,port)values(10,'192.168.15.116',3306);MySQL [(none)]> select * from mysql_servers;MariaDB [(none)]> grant replication client on . to monitor@'192.168.15.%' identified by 'centos';
MySQL [(none)]> set mysql-monitor_username='monitor';
MySQL [(none)]> set mysql-monitor_password='centos';MySQL [(none)]> load mysql variables to runtime;
MySQL [(none)]> save mysql variables to disk;MySQL> select from mysql_server_connect_log;MySQL> select from mysql_server_ping_log;
MySQL> grant all on . to sqluser@'192.168.15.%' identified by 'centos';
MySQL [(none)]> insert into mysql_replication_hostgroups VALUES(10,20,"test");
MySQL [(none)]> SELECT * FROM mysql_replication_hostgroups;+------------------+------------------+---------+| writer_hostgroup | reader_hostgroup | comment || 10 | 20 | test |+------------------+------------------+---------+MySQL> load mysql users to runtime;
MySQL [(none)]> SELECT * FROM mysql_servers;
MySQL> save mysql users to disk;
MySQL [(none)]> INSERT INTO mysql_users(username,password,default_hostgroup) VALUES ('sqluser','centos',10);
MySQL [(none)]> SELECT * FROM mysql_users;
MySQL [(none)]> load mysql users to runtime;MySQL [(none)]> save mysql variables to disk;
MySQL [(none)]> INSERT INTO mysql_query_rules(rule_id,active,match_digest,destination_hostgroup,apply) VALUES (1,1,'^SELECT.*FOR UPDATE$',10,1),(2,1,'^SELECT',20,1);
MySQL [(none)]> select * from mysql_query_rules\G;
MySQL [(none)]> load mysql users to runtime;MySQL [(none)]> save mysql variables to disk;
[root@centos7 ~]# mysql -usqluser -pcentos -h192.168.15.113 -P6033 -e "SELECT @@server_id;"[root@centos7 ~]# mysql -usqluser -pcentos -h192.168.15.113 -P6033 -e 'begin;use db1;insert t1 values(1);select @@server_id;commit'
yum install nfs-utils -y
id apacheuid=997(apache) gid=995(apache) groups=995(apache)id apacheuid=997(apache) gid=995(apache) groups=995(apache)
useradd -r -u 48 -s /sbin/nologin apacheid apacheuid=48(apache) gid=48(apache) groups=48(apache)
mkdir /data/html
vim /etc/exports/data/html 192.168.15.111(rw,no_root_squash,anonuid=997,anongid=995) 192.168.15.112(rw,no_root_squash,anonuid=997,anongid=995)systemctl restart nfs
yum -y install rsync
mkdir /data/backupvim /etc/rsyncd.confuid = root gid = root use chroot = no max connections = 0log file = /var/log/rsyncd.logpid file = /var/run/rsyncd.pidreverse lookup = nohost allow = 192.168.15.118[backup]path = /data/backup/comment = backupreadonly = noauth users = rsyncusersecrets file = /etc/rsync.pass
echo "rsyncuser:centos" > /etc/rsync.passchmod 600 /etc/rsync.pass
systemctl start rsyncd
yum install inotify-tools -yecho "centos" > /etc/rsync.passchmod 600 /etc/rsync.passtouch /data/html/testrsync -avz --password-file=/etc/rsync.pass /data/html/ rsyncuser@192.168.15.119::backup
vim rsync.sh #!/bin/bashSRC='/data/html/'DEST='rsyncuser@192.168.15.119::backup'inotifywait -mrq --timefmt '%Y-%m-%d %H:%M' --format '%T %w %f' -e create,delete,moved_to,close_write,attrib ${SRC} |while read DATE TIME DIR FILE;doFILEPATH=${DIR}${FILE}rsync -az --delete --password-file=/etc/rsync.pass $SRC $DEST && echo "At ${TIME} on ${DATE}, file $FILEPATH was backuped up via rsync" >> /var/log/changelist.logdone
bash rsync.sh
touch /data/html/f1
yum install php-fpm php-mysql -y
vim /app/httpd24/conf/httpd.confDirectoryIndex index.php index.htmlLoadModule proxy_module modules/mod_proxy.soLoadModule proxy_fcgi_module modules/mod_proxy_fcgi.soaddtype application/x-httpd-php-source .phpsproxyrequests offproxypassmatch ^/(.*\.php)$ unix:/var/run/php.sock|fcgi://localhost/data/htmlservername www.mylinuxops.comDocumentroot /data/html require all granted
vim /etc/php.inidate.timezone = Aisa/Shanghai
vim /etc/php-fpm.d/www.conf ;listen = 127.0.0.1:9000listen = /var/run/php.sock;listen.allowed_clients = 127.0.0.1listen.mode = 0666
showmount -e 192.168.15.118vim /etc/fstab192.168.15.118:/data/html /data/html nfs defaults 0 0mount -adf
vim /data/html/index.php
vim VS.sh#!/bin/bashvip='10.0.0.100'iface='lo:1'mask='255.255.255.255'dev=lo:1case $1 instart)echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignoreecho 1 > /proc/sys/net/ipv4/conf/lo/arp_ignoreecho 2 > /proc/sys/net/ipv4/conf/all/arp_announceecho 2 > /proc/sys/net/ipv4/conf/lo/arp_announceifconfig $dev $vip netmask $mask #broadcast $vip up#route add -host $vip dev $dev;;stop)ifconfig $dev downecho 0 > /proc/sys/net/ipv4/conf/all/arp_ignoreecho 0 > /proc/sys/net/ipv4/conf/lo/arp_ignoreecho 0 > /proc/sys/net/ipv4/conf/all/arp_announceecho 0 > /proc/sys/net/ipv4/conf/lo/arp_announce;;*)echo "Usage: $(basename $0) start|stop"exit 1;;esacbash RS.sh
vim /etc/sysctl.confnet.ipv4.ip_forward = 1sysctl -pifconfig ens33:1 10.0.0.200/24
yum install ipvsadm net-tools -yvim VS.sh#!/bin/bashvip='10.0.0.100'iface='lo:1'mask='255.255.255.255'port='80'rs1='192.168.15.111'rs2='192.168.15.112'scheduler='wrr'type='-g'case $1 instart)ifconfig $iface $vip netmask $mask #broadcast $vip upiptables -Fipvsadm -A -t ${vip}:${port} -s $scheduleripvsadm -a -t ${vip}:${port} -r ${rs1} $type -w 1ipvsadm -a -t ${vip}:${port} -r ${rs2} $type -w 1;;stop)ipvsadm -Cifconfig $iface down;;*)echo "Usage $(basename $0) start|stop"exit 1esacbash VS.sh
yum install httpd php php-mysql mariadb-server -ysystemctl start httpd mariadb
yum install pdns pdns-backend-mysql -ymysql < pdns.sql vim /etc/pdns/pdns.conf launch=gmysqlgmysql-host=localhostgmysql-port=3306gmysql-dbname=powerdnsgmysql-user=powerdnsgmysql-password=centos
systemctl start pdns systemctl enable pdns
yum -y install httpd php php-devel php-gd php-mcrypt php-imap phpldap php-mysql php-odbc php-pear php-xml php-xmlrpc php-mbstring phpmcrypt php-mhash gettextsystemctl restart httpd mariadbsystemctl enable httpd mariadbtar xf poweradmin-2.1.7.tgz -C /var/www/html/mv /var/www/html/poweradmin-2.1.7 /var/www/html/poweradmin
rm -rf /var/www/html/poweradmin/install
访问www.mylinuxops.com
转载于:https://blog.51cto.com/13586612/2400438