4. Create a database server (MySQL):

Source: Internet
Author: User
Tags chmod iptables rsync aliyun

To create a database server (MySQL):

# Optimization by Onekey

Sed-i ' s#selinux=enforcing#selinux=disabled# '/etc/selinux/config

grep selinux=disabled/etc/selinux/config

Setenforce 0

Getenforce

/etc/init.d/iptables stop

/etc/init.d/iptables stop

Chkconfig iptables off

Chkconfig|egrep-v "Crond|sshd|network|rsyslog|sysstat" |awk ' {print "Chkconfig", $, "Off"} ' |bash

Useradd Oldboy

\cp/etc/sudoers/etc/sudoers.bak

echo "Oldboy all= (All) nopasswd:all" >>/etc/sudoers

Tail-l/etc/sudoers

Visudo-c

echo ' Export tmout=1800 ' >>/etc/profile

echo ' Export histsize=5 ' >>/etc/profile

echo ' Export histfilesize=5 ' >>/etc/profile

. /etc/profile

Echo ' *-nofile 65535 ' >>/etc/security/limits.conf

echo ">/etc/udev/rules.d/70-persistent-net.rules" >>/etc/rc.local

#about SELinux

Cat >>/etc/sysctl.conf <<eof

Net.ipv4.tcp_fin_timeout = 2

Net.ipv4.tcp_tw_reuse = 1

Net.ipv4.tcp_tw_recycle = 1

Net.ipv4.tcp_syncookies = 1

Net.ipv4.tcp_keepalive_time = 600

Net.ipv4.ip_local_port_range = 4000 65000

Net.ipv4.tcp_max_syn_backlog = 16384

Net.ipv4.tcp_max_tw_buckets = 36000

Net.ipv4.route.gc_timeout = 100

Net.ipv4.tcp_syn_retries = 1

Net.ipv4.tcp_synack_retries = 1

Net.core.somaxconn = 16384

Net.core.netdv_max_backlog = 16384

Net.ipv4.tcp_max_orphans = 16384

Net.nf_conntrack_max = 25000000

Net.netfilter.nf_conntrack_max = 25000000

net.netfilter.nf_conntrack_tcp_timeout_established = 180

net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120

Net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60

net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120

Eof

#set IP and hosts for MySQL

Cat >/etc/sysconfig/network-scripts/ifcfg-eth0<<eof

Device=eth0

Type=ethernet

Onboot=yes

Nm_controlled=yes

Bootproto=static

ipaddr=10.0.0.51

netsk=255.255.255.0

gateway=10.0.0.2

nameserver=202.96.128.86

Eof

Cat >/etc/sysconfig/network-scripts/ifcfg-eth1 <<eof

Device=eth1

Type=ethernet

Onboot=yes

Nm_controlled=yes

ipaddr=172.16.1.51

netsk=255.255.255.0

Eof

Cat >/etc/sysconfig/network<<eof

Networking=yes

Hostname=db01

Eof

Hostname DB01

Cat >/etc/hosts <<eof

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4

:: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6

172.16.1.5 LB01

172.16.1.6 LB02

172.16.1.7 WEB02

172.16.1.8 WEB01

172.16.1.31 nfs01

172.16.1.41 Backup

172.16.1.51 DB01

172.16.1.61 M01

Eof

#/etc/init.d/network Reload


#make some dir

Mkdir-p/server/scripts/server/tools/application


Reboot


====================================================================================================


#yum Repo and Epel

Yum-y Install wget

\cp/etc/yum.repos.d/centos-base.repo{,.backup}

Wget-o/etc/yum.repos.d/centos-base.repo Http://mirrors.aliyun.com/repo/Centos-6.repo

Wget-o/etc/yum.repos.d/epel.repo Http://mirrors.aliyun.com/repo/epel-6.repo

Yum Clean All

Yum Makecache

#setup some tools and develpment

Yum-y Install Lrzsz nmap Tree Dos2unix NC wget

Yum groupinstall-y "Base" "Compatibility Libraries" "Debugging Tools" "Development tools"


#set NTP cron

echo ' #time sync by NTP Server at 20170608 ' >>/var/spool/cron/root

Echo ' */5 * * * * */usr/sbin/ntpdate 172.16.1.61 >/dev/null 2>&1 ' >>/var/spool/cron/root

Crontab-l


#tar configs for every server rsync to backup

#install rsync

Yum-y Install Rsync

#create Passwordfile

echo "Oldboy" >/etc/rsync.password

chmod 600/etc/rsync.password

Cat >/server/scripts/bak.sh <<eof

#!/bin/sh

# #create by 20has at 2017-5-18

ip=\$ (Ifconfig eth1|awk-f "[:]+" ' Nr==2{print \$4} ')

time=\$ (Date +%f)

Mkdir-p/backup/\ $IP

CD/&& \

Tar-zcf/backup/\ $IP/\ $TIME. tar.gz var/spool/cron/root etc/rc.local server/scripts etc/sysconfig/iptables

Md5sum/backup/\ $IP/\ $TIME. tar.gz >/backup/\ $IP/flag.log

rsync-az/backup/[Email Protected]::backup--password-file=/etc/rsync.password

#del

Find/backup-type f-name "*.tar.gz"-mtime +7 |xargs rm-f

Eof

#add Cron to Rsync backup

Echo ' #add cron to rsync backup at 20170608 ' >>/var/spool/cron/root

Echo ' XX * * * */bin/sh/server/scripts/bak.sh &>/dev/null ' >>/var/spool/cron/root






#setup MySQL

Cd/server/tools

TAR-XF mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz

\MV mysql-5.5.56-linux-glibc2.5-x86_64/application/mysql-5.5.56

Ln-s/application/mysql-5.5.56/application/mysql

Useradd mysql-u890-s/sbin/nologin-m

ID MySQL

Chown-r Mysql.mysql/application/mysql

Ll-d/application/mysql

Mkdir-p/application/mysql/data

Cd/application/mysql

/application/mysql/scripts/mysql_install_db--basedir=/application/mysql/--datadir=/application/mysql/data/-- User=mysql

Sed-i ' s#/usr/local/#/application/#g '/application/mysql/bin/mysqld_safe

\CP support-files/my-small.cnf/etc/my.cnf

/application/mysql/bin/mysqld_safe--user=mysql &

Path= "/application/mysql/bin/: $PATH"

Echo ' path= '/application/mysql/bin/: $PATH "' >>/etc/profile

which MySQL

Sed-i ' s#/usr/local/#/application/#g ' support-files/mysql.server

\CP Support-files/mysql.server/etc/init.d/mysqld

chmod +x/etc/init.d/mysqld

/etc/init.d/mysqld stop

Lsof-i: 3306

/etc/init.d/mysqld start

Lsof-i: 3306

Chkconfig--add mysqld

Mysql

show databases;

Quit


Mysqladmin-uroot Password oldboy123

MYSQL-UROOT-POLDBOY123-E "CREATE database WordPress;"

Mysql-uroot-poldboy123-e "Grant all on wordpress.* to [e-mail protected] ' 172.16.1.% ' identified by ' 123456 ';"

MYSQL-UROOT-POLDBOY123-E "flush privileges;"

4. Create a database server (MySQL):

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.