一次机器初始化安装软件的经过

来源:互联网 发布:淘宝如何代理话费 编辑:程序博客网 时间:2024/05/29 19:08

来了一台华为的服务器,需要安装java以及mysql。

好吧,开干

  • 安装java
cd /usr/localwget http://soft.ops.ac.cn/java/jdk-7u79-linux-x64.tar.gztar xzvf jdk-7u79-linux-x64.tar.gzln -s jdk-7u79-linux-x64 javaecho 'export PATH=/usr/local/java/bin' >> /etc/profileecho 'export JAVA_HOME=/usr/local/java' >> /etc/profile
  • 安装mysql
echo '''# CentOS-Base.repo## The mirror system uses the connecting IP address of the client and the# update status of each mirror to pick mirrors that are updated to and# geographically close to the client.  You should use this for CentOS updates# unless you are manually picking other mirrors.## If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead.##[base]name=CentOS-$releasever - Base - mirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=osgpgcheck=1gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6#released updates [updates]name=CentOS-$releasever - Updates - mirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/        http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updatesgpgcheck=1gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6#additional packages that may be useful[extras]name=CentOS-$releasever - Extras - mirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extrasgpgcheck=1gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6#additional packages that extend functionality of existing packages[centosplus]name=CentOS-$releasever - Plus - mirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplusgpgcheck=1enabled=0gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6#contrib - packages by Centos Users[contrib]name=CentOS-$releasever - Contrib - mirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/        http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contribgpgcheck=1enabled=0gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6 ''' > /etc/yum.repos.d/base.repoecho '''[mysql-community]name=MySQL Community Server baseurl=http://repo.mysql.com/yum/mysql-community/el/6/$basearch/enabled=1gpgcheck=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql >> /etc/yum.repos.d/mysql.repoecho '''[epel]name=Extra Packages for Enterprise Linux 6 - $basearchbaseurl=http://mirrors.aliyun.com/epel/6/$basearch        http://mirrors.aliyuncs.com/epel/6/$basearch#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearchfailovermethod=priorityenabled=1gpgcheck=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6[epel-debuginfo]name=Extra Packages for Enterprise Linux 6 - $basearch - Debugbaseurl=http://mirrors.aliyun.com/epel/6/$basearch/debug        http://mirrors.aliyuncs.com/epel/6/$basearch/debug#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearchfailovermethod=priorityenabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6gpgcheck=0[epel-source]name=Extra Packages for Enterprise Linux 6 - $basearch - Sourcebaseurl=http://mirrors.aliyun.com/epel/6/SRPMS        http://mirrors.aliyuncs.com/epel/6/SRPMS#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearchfailovermethod=priorityenabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6gpgcheck=0''' > /etc/yum.repos.d/epel.repo
yum install mysql mysql-server mysql-devel --enablerepo=mysql-community
echo '''[mysqld]datadir=/data/mysqlsocket=/data/mysql/mysql.socksymbolic-links=0sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES long_query_time=5slow-query-logslow-query-log-file=/data/logs/mysql/mysql.slow.loglog-queries-not-using-indexes=falselog-bin=mysqld-binlower_case_table_names=1[mysqld_safe]log=/data/logs/mysql/mysqld.loglog-error=/data/logs/mysql/mysqld.e.logpid-file=/var/run/mysqld/mysqld.pid''' > /etc/my.cnf
mkdir -p /data/logs/mysqlmkdir -p /data/mysqltouch /data/logs/mysql/mysql.slow.logtouch /data/logs/mysql/mysqld.e.logchown -R mysql:mysql /data/logs/mysqlchown -R mysql:mysql /data/mysql
service mysqld restartchkconfig mysqld on

总结:
1. 排障的时候,如果是shell程序,可以用 set -x在开头,这样就可以debug shell程序了。
2. selinux没有特别要求就关闭吧,否则mysql这种,调整路径后,也没法启动
3. 虽然只是安装java和mysql,但是还是花了3个小时左右,有点太浪费了。

0 0
原创粉丝点击