一、安装准备环境
1.安装centos6.5
精简安装
2.安装工具包
yum install wget
yum install zip
yum install unzip
yum -y install openssh-clients (scp)
3.准备软件
wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
wget https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-5.4.zip
wget https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-2.6.zip
wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.30.tar.gz
4.安装jdk1.7.0_45(必须1.7以上)
unzip jdk1.7.0_45.zip
mkdir /usr/java
mv jdk1.7.0_45 /usr/java/
vi /etc/profile (编辑/etc/profile文件,配置JAVA环境变量,追加以下内容)
export JAVA_HOME=/usr/java/jdk1.7.0_45
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
保存退出
. /etc/profile(使修改生效)
java -version (验证)
5.安装MAVEN
tar -zxvf apache-maven-3.3.9-bin.tar.gz
mv apache-maven-3.3.9 /usr/
vi /etc/profile(编辑/etc/profile文件,配置MAVEN环境变量,追加以下内容)
export M3_HOME=/usr/apache-maven-3.3.9
export PATH=${M3_HOME}/bin:${PATH}
保存退出
. /etc/profile(使修改生效)
mvn -version (验证)
mkdir /usr/apache-maven-3.3.9/repo (创建本地存储库目录)
vi /usr/apache-maven-3.3.9/conf/setting.xml (编辑本地存储库位置)
<localRepository>/usr/apache-maven-3.3.9/repo</localRepository>
6.安装mysql
yum -y install make gcc-c++ cmake bison-devel ncurses-devel perl
tar xvf mysql-5.6.30.tar.gz
cd mysql-5.6.30
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
make && make install(有点慢)
groupadd mysql
useradd -g mysql mysql
chown -R mysql:mysql /usr/local/mysql
cd /usr/local/mysql
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
cp support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on
service mysql start
Starting MySQL. ERROR! The server quit without updating PID file (/var/lib/mysql/jenkins.sonar.pid).
vi /usr/local/mysql/my.cnf
datadir=/usr/local/mysql/data
service mysql start
vi /etc/profile
PATH=/usr/local/mysql/bin:$PATH
export PATH
. /etc/profile
mysql> SET PASSWORD = PASSWORD('123456');
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '111111' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
service mysql restart
mysql 配置完成!
7.安装sonar
unzip sonarqube-5.4.zip
mv sonarqube-5.4 /usr/
8.配置sonarque5.4
mysql -u root -p
mysql> CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> grant all on sonar.* to sonar identified by 'sonar';
mysql> grant all on sonar.* to sonar@'%' identified by 'sonar';
mysql> flush privileges;
mysql> exit;
service mysql restart
配置maven
vi /usr/apache-maven-3.3.9/conf/setting.xml (添加以下内容)
<profiles>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<sonar.jdbc.url>jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true</sonar.jdbc.url>
<sonar.jdbc.username>sonar</sonar.jdbc.username>
<sonar.jdbc.password>sonar</sonar.jdbc.password>
<sonar.host.url>http://localhost:9000</sonar.host.url>
</properties>
</profile>
</profiles>
# vim /usr/sonarqube-5.4/conf/sonar.properties
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
sonar.jdbc.driverClassName=com.mysql.jdbc.Driver
sonar.jdbc.validationQuery=select 1
保存退出!
cd /usr/sonarqube-5.4/bin/linux-x86-64/
sonar.sh start (启动)
http://ip:9000登录
用户名 密码
admin admin
9.安装jenkins
# wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
# rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
service jenkins start
Starting Jenkins bash: /usr/bin/java: 没有那个文件或目录
vi /etc/init.d/jenkins
/usr/java/jdk1.7.0_45/bin/java
service jenkins start
http://ip:8080 (登录jenkins)
cat /var/lib/jenkins/secrets/initialAdminPassword (登录用的密码,用户名是admin,登录后记得修改)
10.安装sonar-scanner
unzip sonar-scanner-2.6.zip
mv sonar-scanner-2.6 /usr/
cd /usr/sonar-scanner-2.6
vi sonar-scanner.properties
sonar.host.url=http://localhost:9000
sonar.sourceEncoding=UTF-8
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
sonar.jdbc.driverClassName=com.mysql.jdbc.Driver
sonar.jdbc.validationQuery=select 1
vi /etc/profile
export SONAR_SCANNER_OPTS="-Xmx512m -XX:MaxPermSize=128m"
. /etc/profile
至此安装完成,接下来是配置了!
1.安装centos6.5
精简安装
2.安装工具包
yum install wget
yum install zip
yum install unzip
yum -y install openssh-clients (scp)
3.准备软件
wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
wget https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-5.4.zip
wget https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-2.6.zip
wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.30.tar.gz
4.安装jdk1.7.0_45(必须1.7以上)
unzip jdk1.7.0_45.zip
mkdir /usr/java
mv jdk1.7.0_45 /usr/java/
vi /etc/profile (编辑/etc/profile文件,配置JAVA环境变量,追加以下内容)
export JAVA_HOME=/usr/java/jdk1.7.0_45
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
保存退出
. /etc/profile(使修改生效)
java -version (验证)
5.安装MAVEN
tar -zxvf apache-maven-3.3.9-bin.tar.gz
mv apache-maven-3.3.9 /usr/
vi /etc/profile(编辑/etc/profile文件,配置MAVEN环境变量,追加以下内容)
export M3_HOME=/usr/apache-maven-3.3.9
export PATH=${M3_HOME}/bin:${PATH}
保存退出
. /etc/profile(使修改生效)
mvn -version (验证)
mkdir /usr/apache-maven-3.3.9/repo (创建本地存储库目录)
vi /usr/apache-maven-3.3.9/conf/setting.xml (编辑本地存储库位置)
<localRepository>/usr/apache-maven-3.3.9/repo</localRepository>
6.安装mysql
yum -y install make gcc-c++ cmake bison-devel ncurses-devel perl
tar xvf mysql-5.6.30.tar.gz
cd mysql-5.6.30
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
make && make install(有点慢)
groupadd mysql
useradd -g mysql mysql
chown -R mysql:mysql /usr/local/mysql
cd /usr/local/mysql
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
cp support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on
service mysql start
Starting MySQL. ERROR! The server quit without updating PID file (/var/lib/mysql/jenkins.sonar.pid).
vi /usr/local/mysql/my.cnf
datadir=/usr/local/mysql/data
service mysql start
vi /etc/profile
PATH=/usr/local/mysql/bin:$PATH
export PATH
. /etc/profile
mysql> SET PASSWORD = PASSWORD('123456');
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '111111' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
service mysql restart
mysql 配置完成!
7.安装sonar
unzip sonarqube-5.4.zip
mv sonarqube-5.4 /usr/
8.配置sonarque5.4
mysql -u root -p
mysql> CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> grant all on sonar.* to sonar identified by 'sonar';
mysql> grant all on sonar.* to sonar@'%' identified by 'sonar';
mysql> flush privileges;
mysql> exit;
service mysql restart
配置maven
vi /usr/apache-maven-3.3.9/conf/setting.xml (添加以下内容)
<profiles>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<sonar.jdbc.url>jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true</sonar.jdbc.url>
<sonar.jdbc.username>sonar</sonar.jdbc.username>
<sonar.jdbc.password>sonar</sonar.jdbc.password>
<sonar.host.url>http://localhost:9000</sonar.host.url>
</properties>
</profile>
</profiles>
# vim /usr/sonarqube-5.4/conf/sonar.properties
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
sonar.jdbc.driverClassName=com.mysql.jdbc.Driver
sonar.jdbc.validationQuery=select 1
保存退出!
cd /usr/sonarqube-5.4/bin/linux-x86-64/
sonar.sh start (启动)
http://ip:9000登录
用户名 密码
admin admin
9.安装jenkins
# wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
# rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
service jenkins start
Starting Jenkins bash: /usr/bin/java: 没有那个文件或目录
vi /etc/init.d/jenkins
/usr/java/jdk1.7.0_45/bin/java
service jenkins start
http://ip:8080 (登录jenkins)
cat /var/lib/jenkins/secrets/initialAdminPassword (登录用的密码,用户名是admin,登录后记得修改)
10.安装sonar-scanner
unzip sonar-scanner-2.6.zip
mv sonar-scanner-2.6 /usr/
cd /usr/sonar-scanner-2.6
vi sonar-scanner.properties
sonar.host.url=http://localhost:9000
sonar.sourceEncoding=UTF-8
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
sonar.jdbc.driverClassName=com.mysql.jdbc.Driver
sonar.jdbc.validationQuery=select 1
vi /etc/profile
export SONAR_SCANNER_OPTS="-Xmx512m -XX:MaxPermSize=128m"
. /etc/profile
至此安装完成,接下来是配置了!