Install the Kickstart service on a blank host with one click to distribute centos5.8 and mysql5.7.16

Source: Internet
Author: User
Tags create directory iptables

#!/bin/bashchkconfig --add sshd chkconfig sshd onyum -y install vim  man wget# need to turn off the DHCP function of the virtual Switch # requires an open network # Native Segment 192.168.2.x ip20# client hard disk size 100gb# borrowed a classmate's MySQL one-click installation version # After the installation is complete, the client manually confirms that the restart          line194 can be modified to automatically reboot # missing to determine if MySQL successfully downloaded and prompted the judge: #1. Whether the local FTP shared folder has mysql*.tar.gz  ———— no→2.wget successfully downloaded   ———— no→3. Prompt the user and exit the script # Lack of intelligent judgment to parameterize the native IP and bring it into kiskstart each service # need to insert a 6.8 CD in the optical drive #ks tool does not need to be installed, as long as the KS file is well-prepared, install the KS to install the graphical interface is too waste of time and memory and hard disk #dhcpyum - Y install dhcpcreate_dhcp_conf ()  {cat > /etc/dhcp/dhcpd.conf <<eof# dhcpd.conf#sample configuration file for isc dhcpdlog-facility local7; #internal  subnetsubnet 192.168.2.0 netmask 255.255.255.0{range 192.168.2.100  192.168.2.200;option routers 192.168.2.2;default-lease-time 600;next-server 192.168.2.20; filename  "pxelinux.0";} Eof}create_dhcp_confservice dhcpd rEstartchkconfig --add dhcpdchkconfig dhcpd on#vsftp,for download mysql from  server to clientwget -n --no-check-certificate https://cdn.mysql.com//downloads /mysql-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz -p /var/ftp/yum -y install  vsftpdchkconfig --add vsftpd chkconfig vsftpd on#tftpyum -y install  Tftp-server tftpcreate_tftpserver_conf () {Cat > /etc/xinetd.d/tftp <<eofservice  tftp{socket_type =dgramprotocol =udpwait          =yesuser         =rootserver        =/usr/sbin/in.tftpdserver_args  = -s /var/lib/tftpbootdisable       =noper_source   =11cps           =100 2flags        =ipv4}eof}create_tftpserver_confchkconfig --add  Xinetdchkconfig xinetd onservice xinetd reloadservice xinetd restart#iptables  selinux/etc/init.d/iptables stopchkconfig --del iptablessetenforce 0sed -i   "S/enforcing/permissive/g"  /etc/selinux/config#kickstart#yum -y install  system-config-kickstart#yum -y groupinstall  "Desktop" #yum  -y groupinstall  "X  window system "#yum  -y groupinstall  chinese support" #nfsmkdir  /ksmkdir  -p /iso/6.8yum -y install nfs-utilscat > /etc/exports <<eof/ Ks  192.168.2.0/24 (RO)/iso 192.168.2.0/24 (RO) eofchkconfig --add nfschkconfig nfs  onchkconfig --add rpcbindchkconfig rpcbind on service rpcbind  restartservice nfs restart# Startup file Alias cp= ' cp -i ' unalias_for_copy () {unalias cp}unalias_for_copyyum -y install syslinux# Copy the pxelinux.0  file to the/var/lib/tftpboot/  folder #syslinux is a powerful bootloader and is compatible with a variety of media. More precisely: Syslinux is a small Linux operating system that is designed to simplify the first time you install Linux, and to create repair or other special-purpose boot disks. cp -f /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/umount /mediamount  /dev/ cdrom /mediamkdir -p /iso/6.8/cp -rf  /media/* /iso/6.8/cp -rf / iso/6.8/isolinux/{initrd.img,vmlinuz} /var/lib/tftpboot/cp /iso/6.8/isolinux/*.msg /var/lib/ Tftpboot/mkdir -p /var/lib/tftpboot/pxelinux.cfgcp -rf /iso/6.8/isolinux/isolinux.cfg  /var/lib/tftpboot/pxelinux.cfg/defaultcat > /var/lib/tftpboot/pxelinux.cfg/default  <<EOFdefault ksprompt 1timeout 6display boot.msgmenu background  splash.jpgmenu title welcome to centos 6.8!menu color border 0 #ffffffff  #00000000menu  color sel 7  #ffffffff   #ff000000menu  color title  0  #ffffffff   #00000000menu  color tabmsg 0  #ffffffff   #00000000menu  color unsel 0  #ffffffff   #00000000menu  color hotsel 0  #ff000000   #ffffffffmenu  color hotkey 7  #ffffffff   #ff000000menu  color scrollbar  0  #ffffffff   #00000000label  linux  menu label ^Install or  upgrade an existing system  menu default  kernel vmlinuz   append initrd=initrd.imglabel ks  kernel vmlinuz  append ks=nfs : 192.168.2.20:/ks/c68m57.cfg initrd=initrd.imglabel vesa  menu label install  system with ^basic video driver  kernel vmlinuz  append  initrd=initrd.img nomOdesetlabel rescue  menu label ^rescue installed system  kernel  vmlinuz  append initrd=initrd.img rescuelabel local  menu label  Boot from ^local drive  localboot 0xfffflabel memtest86   Menu label ^memory test  kernel memtest  append -eofalias cp = ' Cp -i ' #创建kickstart配置文件cat  > /ks/c68m57.cfg <<eof#platform=x86, amd64,   or  Intel EM64T#version=DEVEL# Firewall configurationfirewall --disabled#  Install os instead of upgradeinstall# use nfs installation medianfs  --server=192.168.2.20 --dir=/iso/6.8# root password# If encrypted password is used, the string after each password encryption is random, The password you set cannot be reused rootpw --plaintext sa123456# system authorization informationauth   --useshadow  --passalgo=sha512# use graphical installgraphical# system keyboardkeyboard us#  system languagelang zh_cn# selinux configurationselinux --permissive# do  not configure the x window systemskipx# installation logging  levellogging --level=info# reboot after installation#reboot# system  Timezonetimezone  asia/shanghai# network informationnetwork  --bootproto=static  --device=eth0 --gateway=192.168.2.2 --ip=192.168.2.88 --nameserver=192.168.2.2 -- netmask=255.255.255.0 --onboot=on# system bootloader configurationbootloader -- location=mbr# partition clearing informationclearpart --all --initlabel #  Disk partitioning informationpart swap --fstype= "Swap"  --size=4096part /boot  --fstype= "Ext4"  --size=300part /&nbsP;--fstype= "Ext4"  --size=30270part /data --fstype= "XFS"  --grow --size=1%postyum  -y install vim openssh manchkconfig --add sshdchkconfig sshd oncat> >/etc/crontab<<EEE00 0 1 * * root ntpdate -s  time.nist.goveeechown -r mysql:mysql /data/mysqlecho  "Create directory with authorization complete" cd /data/mysql/ 3306echo  "Create MY.CNF" cat >> my.cnf << eop#my.cnf[client]port             = 3306socket           = /data/mysql/3306/tmp/mysql3306.sock[mysql]prompt= "\\[email protected ]\\h:\\p [\\d]> "  #pager =" Less -i -n -s "#tee =/data/mysql/3306/ query.logno-auto-rehashntpdate -s time.nist.gov#paragraph for mysqlwget -n ftp:/ /192.168.2.20/mysql/mysql-5.7.14-linux-glibc2.5-x86_64_x.taR.gz -p /usr/local/src/ groupadd  mysqluseradd -d /usr/local/mysql -s  /sbin/nologin -g mysql -M -n mysqlcd /usr/local/src/tar -zxf  mysql-5.7.14-linux-glibc2.5-x86_64_x.tar.gz -c /usr/localecho  "decompression complete" CD&NBSP; /ln -s mysql-5.7.14-linux-glibc2.5-x86_64 mysqlecho  "Create a soft connection" chown -r mysql:mysql &NBSP;/USR/LOCAL/MYSQLMKDIR&NBSP;-P&NBSP;/DATA/MYSQL/3306/{DATA,LOGS,TMP}[MYSQLD] #miscuser  =  Mysqlbasedir = /usr/local/mysqldatadir = /data/mysql/3306/dataport = 3306socket  = /data/mysql/3306/tmp/mysql3306.sockevent_scheduler = 0tmpdir = /data/mysql/ 3306/tmp#timeoutinteractive_timeout = 3600wait_timeout = 3600#character  Setcharacter-set-server = utf8open_files_limit = 65535max_connections = 500max_ connect_errors = 100000lower_case_table_names&Nbsp;=1#symi replication#rpl_semi_sync_master_enabled=1#rpl_semi_sync_master_timeout=1000 # 1  second#rpl_semi_sync_slave_enabled=1#logslog-output=fileslow_query_log = 1slow_query_log_file  = slow.loglog-error = error.loglog_warnings = 2pid-file =  Mysql.pidlong_query_time = 1#log-slow-admin-statements = 1#log-queries-not-using-indexes  = 1log-slow-slave-statements = 1#binlog#binlog_format = statementbinlog_format  = rowserver-id = 13306log-bin = /data/mysql/3306/logs/mysql-binbinlog_cache_ size = 4mmax_binlog_size = 256mmax_binlog_cache_size = 1msync_binlog =  0expire_logs_days = 10#procedure log_bin_trust_function_creators=1#gtid-mode =  onenforce-gtid-consistency=1#relay logskip_slave_start = 1max_relay_log_size =  128mrelay_log_purge = 1relay_log_recovery = 1relay-log=relay-binrelay-log-index=relay-bin.indexlog_slave_updates#slave-skip-errors= 1032,1053,1062#skip-grant-tables#buffers & cachetable_open_cache = 2048table_ Definition_cache = 2048table_open_cache = 2048max_heap_table_size = 96msort_ Buffer_size = 128kjoin_buffer_size = 128kthread_cache_size = 200query_cache_size  = 0query_cache_type = 0query_cache_limit = 256kquery_cache_min_res_unit =  512thread_stack = 192ktmp_table_size = 96mkey_buffer_size = 8mread_buffer_ Size = 2mread_rnd_buffer_size = 16mbulk_insert_buffer_size = 32m#myisammyisam_ sort_buffer_size = 128mmyisam_max_sort_file_size = 1gmyisam_repair_threads = 1# Innodbinnodb_buffer_pool_size = 1ginnodb_buffer_pool_instances = 1innodb_data_file_path  = ibdata1:1024m:autOextendinnodb_flush_log_at_trx_commit = 2innodb_log_buffer_size = 8minnodb_log_file_size  = 100minnodb_log_files_in_group = 3innodb_max_dirty_pages_pct = 50innodb_file_ per_table = 1innodb_rollback_on_timeoutinnodb_status_file = 1innodb_io_capacity =  200transaction_isolation = READ-COMMITTEDinnodb_flush_method = O_DIRECTEOPecho  "Create boot file" cat >> mysqld << eep#!/bin/bashmysql_port=3306# port mysql_user= "Root" # User Mysql_pwd= "" #密码CmdPath = "/usr/local/mysql/bin" mysql_sock= "/data/mysql/\${mysql_port}/tmp/mysql\${mysql_port}. Sock "#startup  functionfunction_start_mysql () {        if [  ! -e  "\ $mysql _sock"  ];then      printf  "starting  mysql...\n "      \${cmdpath}/mysqld --defaults-file=/data/mysql/\${mysql_ Port}/my.cnf 2>&1 > /dev/null &        else           printf  "mysql is running...\n"            exit        fi}function_stop _mysql () {          if [ ! -e  "\ $mysql _ Sock " ];then                 printf  "stoping mysql...\n"                  exit        else                 printf  "mysql is  stopped...\n "                \ ${cmdpath}/mysqladmin -u\${mysql_user} -p\${mysql_pwd} -s \ $mysql _sock shutdown         fi}function_restart_mysql () {        printf  " restarting mysql...\n "        function_stop_mysql         sleep 2        function_start _mysql}case \$1 instart)         function_start_mysql;; Stop)         function_stop_mysql;; Restart)         function_restart_mysql;; *)         printf  "Usage: /data/mysql/\${mysql_port}/mysqld  {start|stop|restart} \n "esaceepecho " completed "/usr/local/mysql/bin/mysqld --defaults-file=/data /mysql/3306/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql/3306/data --user=mysql --initializeecho  "MySQL initialization complete" echo  ' Export path=/usr/local/mysql/bin: $PATH '  >> /etc/profilesource /etc/profileecho  "Variable configuration complete" cat /data/mysql/3306/data/ error.log |grep  "[email protected]" |awk -f  " "   ' {print $11} '  > /data/mysql/3306/password.txtecho  "root random password complete cat /data/mysql/3306/password.txt" chmod +x / data/mysql/3306/mysqldecho  "Start command/data/mysql/3306/mysqld start" echo  "Close command/data/mysql/3306/mysqld  stop "echo " script author Ye Liangjian  QQ88263188  "#paragraph  end of mysql00 0 1  * * root ntpdate -s time.nist.goveeentpdate -s time.nist.gov%endeof


This article is from the "Network management Diary of FF" blog, make sure to keep this source http://l0vesql.blog.51cto.com/4159433/1913606

Install the Kickstart service on a blank host with one click to distribute centos5.8 and mysql5.7.16

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.