最近公司要上新项目,所以要台机器做测试,领导要求把所有服务搭建到同一台服务器上。
开发需求: 1.java 1.7.0_45 路径:/usr/java/jdk1.0.0_45/ 环境变量:JAVA_HOME=/usr/java
2.tomcat 7.0.67 启动参数:JAVA_OPTS="-Xms2048m -Xmx2048m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:NewSize=1024m -XX:MaxNewSize=1024m -XX:SurvivorRatio=10"
3.mysql 5.6.23-72.1
4.mongodb 3.0.7
5.redis 3.0.1 启动参数:初始化内存8G
一、先现在所需源码包:
1 wget http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.67/bin/apache-tomcat-7.0.67.tar.gz 2 3 wget wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.23.tar.gz 4 5 wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.7.tgz 6 7 wget http://download.redis.io/releases/redis-3.0.1.tar.gz 8 9 wget http://prdownloads.sourceforge.net/tcl/tcl8.6.4-src.tar.gz 10 11 wget http://download.oracle.com/otn/java/jdk/7u40-b43/jdk-7u40-linux-x64.tar.gz
jdk下载记得点击列表上面的“我接受”按钮
一、安装jdk环境:
- 解压: 1 tar xvf jdk-7u45-linux-x64.tar.gz -C /usr/java/
- 将java路径添加到环境变量。我是直接打开/etc/profile文件把java的路径添加进去的。推荐大家更改文件一定要小心。
-
source /etc/profile
- java -version 是否能看到java版本信息,
java version "1.7.0_45" Java(TM) SE Runtime Environment (build 1.7.0_45-b18) Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)```
能看到就说明成功了。
二、tomcat
-
tar xzvf apache-tomcat-7.0.67.tar.gz -C /usr/local/
-
mv apache-tomcat-7.0.67 apache-tomcat7
- 打开tomcat的配置文件,修改参数:JAVA_OPTS="-Xms2048m -Xmx2048m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:NewSize=1024m -XX:MaxNewSize=1024m -XX:SurvivorRatio=10"
- 启动
tomcat sh /usr/local/apache-tomcat7/startup.sh
- 查看tomcat是否启动:
netstat -anpt |grep 8080
三、安装MySQL
- 先安装依赖库文件
yum -y install ncurses-devel yum -y install gcc gcc++ yum install gcc-c++ libstdc++-deve
- 源码包编译安装cmake:
tar cvf cmake-2.8.12.tar.gz -C /usr/src cd /usr/src/cmake-2.8.12/ ./configure && make && make install
- 创建mysql用户
useradd -M -s /sbin/nologin mysql
-
tar xzvf mysql-5.6.23.tar.gz -C /usr/src
-
cd /usr/src/mysql-5.6.23
-
直接cmake安装MySQL:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all & & make && make install
- 改属组属主
chown -R mysql:root /usr/local/mysql/
- 配置文件:
cp my-default.cnf /etc/my.cnf
- 创建启动文件:
cp mysql.server /etc/init.d/mysqld
- 给执行权限:
chmod +x /etc/init.d/mysqld
- 添加开机自启:
chkconfig mysqld --add
- 环境变量:
echo "export PATH=$PATH:/usr/local/mysql/bin" >>/etc/profile
四、mongodb
- mongodb不用预编译安装所以直接解包到local下:
tar xzvf mongodb-linux-x86_64-3.0.7.tgz -C /usr/local
- 改个名:
mv mongodb-linux-x86_64-3.0.7 mongodb
- 环境变量
echo "export PATH=$PATH:/usr/local/mongodb/bin">>/etc/profile
- 更新当前环境变量:
source /etc/profile
- 创建数据路径:
mkdir /usr/local/mongodb/data
- 创建日志文件:
touch /usr/local/mongodb/logs
-
无密码启动
mongodb:/usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data --logpath=/usr/local/mongodb/logs --logappend --auth --port=27017 --fork
-
cd/usr/local/mongodb/bin
- 启动
./mongo
- ./mongo再次启动,遇到报错:
1 [root@localhost bin]# ./mongo 2 MongoDB shell version: 3.0.7 3 connecting to: test 4 2017-11-30T08:59:57.337+0800 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused 5 2017-11-30T08:59:57.340+0800 E QUERY Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed 6 at connect (src/mongo/shell/mongo.js:179:14) 7 at (connect):1:6 at src/mongo/shell/mongo.js:179 8 exception: connect failed
链接失败找原因,果断删除data目录下的mongod.lock文件,可能是因为没有正确关闭mongodb导致的错误。
- 启动成功:
[root@localhost bin]# ./mongo MongoDB shell version: 3.0.7 connecting to: test Welcome to the MongoDB shell. For interactive help, type "help". For more comprehensive documentation, see http://docs.mongodb.org/ Questions? Try the support group http://groups.google.com/group/mongodb-user > 9-9 0 > exit
bye
这个编辑器真是用的我难受
后续配置看另外一篇博客把