CentOS 64 bit install mongodb,python, tomcat,etc, to achieve a web platform system_2

CentOS 64 bit install mongodb,python, tomcat,etc, to achieve a web platform system_2

在linux机CentOs 64位中安装FreeWiFi平台,所有的组件安装过程大致如下面所示,参考的是安装步骤txt文档,在其基础上结合个人实际在协助国外客户机安装时出现的问题进行一些修改和完善。

首先准备好一份安装包。

安装包比较大,可以通过上传百度云/腾讯微云,从对方linux机下载

 

#一、安装时间服务器

yum install ntp -y

ntpdate 0.uk.pool.ntp.org

vi /etc/ntp.conf

#press I to insert

 

server 3.cn.pool.ntp.org

server 1.asia.pool.ntp.org

server 0.asia.pool.ntp.org

#press esc, : , wq, enter #to save and quit

 

chkconfig --level 35 ntpd on

service ntpd start    

 

二、mongodb安装配置

cd /usr/local/

wget http://hdwuhan.ddns.info:51492/other/mongodb-linux-x86_64-rhel62-3.2.3.tgz //如域名无法访问,请使用hdwuhan.ddns.info

wget http://119.96.204.253:51492/other/mongodb-linux-x86_64-rhel62-3.2.3.tgz

 

#Change:We can't execute the wget command above for the oversea customer. So here we need to download from http://hdwuhan.ddns.info:51492/other/mongodb-linux-x86_64-rhel62-3.2.3.tgz

Then transfer to its side, move the file to /usr/local/

 

tar zxvf mongodb-linux-x86_64-rhel62-3.2.3.tgz

rm -f mongodb-linux-x86_64-rhel62-3.2.3.tgz

mv mongodb-linux-x86_64-rhel62-3.2.3 mongodb

sed -i '$a #mongo\nexport MONGO_HOME=/usr/local/mongodb\nexport PATH=$MONGO_HOME/bin:$PATH' /etc/profile

source /etc/profile

#The profile can be edit, if shows error here, you can open the profile to check.

 

cd /usr/local/mongodb/    

mkdir -p data/rtdata/logs

touch data/rtdata/logs/mongodb.log

mkdir -p data/rtdata/db

wget http://119.96.204.253:51492/other/mongodb.conf #检查配置文件,需要包含mongodb存储引擎的内存限制

# Change:We shall download it to our local PC then transfer it.

 

/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/mongodb.conf #(遇到服务器重启,可用sudo和./mongod --repair)

 

#创建用户

#使用mongo命令进入mongo命令行

mongo

#创建管理员>>

use admin

db.createUser({user: "root",pwd: "123456",roles:[{ role: "root", db: "admin" }]})

exit()

#创建用户成功后关闭服务 kill -9 PID

ps -ef |grep mongo

#get the <PID> of the mongo process

kill -9 <PID>

 

#认证启动服务

/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/mongodb.conf --auth

#after that you can check its status again by

ps -ef |grep mongo 

 

#三、mysql安装运行

wget http://119.96.204.253:51492/other/mysql57-community-release-el6-7.noarch.rpm

#Change: We shall download it in advanced then transfer it.

in addiction, the current path maybe /usr/local/

 

rpm -Uvh mysql57-community-release-el6-7.noarch.rpm

rm -f mysql57-community-release-el6-7.noarch.rpm

cd /etc/yum.repos.d

rm -f mysql-community.repo

wget http://119.96.204.253:51492/other/mysql-community.repo

wget http://119.96.204.253:51492/other/mysql-community-source.repo

yum install mysql mysql-server #(查看安装的是否5.5版)

#如果安装报错,修改mysql-community.repo文件,去掉校验:gpgcheck=1--->gpgcheck=0

chkconfig mysqld on

vi /etc/my.cnf #进行配置

#增加以下配置:

#Press I to insert

max_connections=1000

lower_case_table_names=1

max_allowed_packet = 200M

# press esc, :, wq,enter #to save and quit    

 

service mysqld start

/usr/bin/mysqladmin -u root password 'sa'

mysql -uroot -psa

#source 命令导入sql脚本

source /home/icloudboss/freewifi.sql

 

#四、安装Redis

cd /usr/local/

wget http://hdwhirtu.vicp.cc:51492/other/redis-3.0.1.tar.gz

#Change: we shall download it by ourselves, then transfer it

tar -zxvf redis-3.0.1.tar.gz&& rm -rf redis-3.0.1.tar.gz&& cd redis-3.0.1/ #解压压缩包

make&&make install #(make MALLOC=libc)

cp redis.conf /etc/

sed -i '37s/no/yes/' /etc/redis.conf

cd /usr/local/bin/

wget http://119.96.204.253:51492/other/redis_start.sh && chmod +x redis_start.sh

ln -s /usr/local/bin/redis-cli /usr/bin/

nohup /usr/local/bin/redis_start.sh > /dev/null 2>&1 &

 

#五、安装tomcat

#删除openjdk

rpm -qa |grep java

rpm -e --nodeps java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64 #//删除服务器实际查询出来的安装程序名

rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64

rpm -e --nodeps tzdata-java-2013g-1.el6.noarch

wget http://119.96.204.253:51492/other/jdk-7u71-linux-x64.rpm

rpm -Uvh jdk-7u71-linux-x64.rpm

rm -f jdk-7u71-linux-x64.rpm

#配置环境变量

vim /etc/profile

#在文件中export PATH下面添加以下代码:

#press I to insert.

export JAVA_HOME=/usr/java/jdk1.7.0_71

export CALSSPATH=$JAVA_HOME/lib/*.*

export PATH=$PATH:$JAVA_HOME/bin

export TOMCAT_HOME=/usr/local/tomcat

export CATALINA_HOME=/usr/local/tomcat

#press esc,:,wq,enter #to save and quit

 

cd /usr/local

wget http://119.96.204.253:51492/other/apache-tomcat-7.0.55.tar.gz

#Change: we shall download it by ourselves then transfer it.

mkdir tomcat &&tar zxvf apache-tomcat-7.0.55.tar.gz -C ./tomcat --strip-components 1

#配置tomcat java选项

cd /usr/local/tomcat/bin

vi catalina.sh

#press I to insert.

JAVA_OPTS="$JAVA_OPTS -Xms256m -Xmx512m -Xss1024K -XX:PermSize=128m -XX:MaxPermSize=256m"

#press esc,:,wq,enter

cd /usr/local/tomcat/conf

rm -f server.xml

wget http://119.96.204.253:51492/other/freewifi.cer

wget http://119.96.204.253:51492/other/freewifi.jks

wget http://119.96.204.253:51492/other/server.xml

#Change: we shall download them by ourselves then transfer them.

Current path maybe /usr/local/

 

#将安装包中freewifi.war,auth.war,fileserver.war放入/usr/local/tomcat/webapps目录

mv freewifi.war auth.war fileserver.war -t /usr/local/tomcat/webapps

 

mkdir /usr/local/tomcat/webapps1

#将安装包中freewifi-tactics.war放入/usr/local/tomcat/webapps1目录,并将freewifi-tactics.war修改为freewifi.war #As below.

mv freewifi-tactics.war /usr/local/tomcat/webapps1/freewifi.war

 

#启动tomcat

/usr/local/tomcat/bin/startup.sh

 

#六、安装thrift-server

cd /usr/local

#将安装包中thrift-server文件夹复制到/usr/local/目录

cd /usr/local/thrift-server

chmod +x startup.sh

#启动thrift-server

nohup ./startup.sh &

 

#七、python模块安装运行(升级到2.7,若自带python为2.7可不升级)输入python回车,可查看版本

yum install bzip2-devel openssl openssl-devel gcc-c++ -y

cd /usr/local

wget http://119.96.204.253:51492/other/Python-2.7.10.tar.xz

#Change: we shall download it by ourselves then transfer it.

 

tar xvf Python-2.7.10.tar.xz #(解压tar.xz文件:先 xz -d xxx.tar.xz 将 xxx.tar.xz解压成 xxx.tar 然后,再用 tar xvf xxx.tar来解包。)

cd Python-2.7.10

./configure --enable-shared --prefix=/usr/local/python27/

make MALLOC=libc&&make install

mv /usr/bin/python /usr/bin/python_old

ln -s /usr/local/python27/bin/python /usr/bin/python

sed -i '$a /usr/local/python27/lib' /etc/ld.so.conf

ldconfig

wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py (此步骤如果执行报错,则运行wget http://119.96.204.253:51492/other/ez_setup.py 然后chmod +x ez_setup.py)

#Change: we shall download it by ourselves then transfer it.

 

chmod +x ez_setup.py

python ez_setup.py --insecure

Here errors occur:

#After I search the Internet, I find out the solution.

 

wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate

python get-pip.py

pip install six

chmod +x ez_setup.py

python ez_setup.py --insecure

#OK

 

hd.log #I don't know what this command mean.

 

wget http://119.96.204.253:51492/other/pip-7.1.2.tar.gz

#Change: we shall download it by ourselves then transfer it.

 

tar -zxvf pip-7.1.2.tar.gz

rm -f pip-7.1.2.tar.gz

cd pip-7.1.2

python setup.py install

ln -s /usr/local/python27/bin/pip /usr/bin/pip

pip install tornado

#wait for installing...

# it is in the /usr/local/ now

sed -i '1s/python/python_old/' /usr/bin/yum

 

安装python出错后想要重新执行python2.7安装步骤,期间遇到一个问题

yum 安装一个软件包,出现如下错误;

-bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directory

 

办法:查看yum和python的rpm是否安装

# ll /usr/bin/yum #yum命令存在

-rwxr-xr-x 1 root root 801 Sep 21 2011 /usr/bin/yum

 

# ll python #原因在这

lrwxrwxrwx 1 root root 26 May 7 15:06 python -> PREFIX/Python-2.7.2/python

原来python的软连接源文件已经不存在,所以出现上面错误;

解决办法:

重新做一个python的软连接,用系统的python的rpm包python2.6;问题解决。

# ln -s /usr/bin/python2.6 /usr/bin/python

另外删除软链接为 rm -rf /目录

 

 

#获取unzip_json.tar.gz程序包到/usr/local目录,as below line.

mv /usr/local/unzip/unzip_json.tar.gz /usr/local/ #move the unzip_json.. to local

 

cd /usr/local

tar zxvf unzip_json.tar.gz

cd unzip_json

chmod +x setup.sh startup.sh shutdown.sh

 

./setup.sh #启动unzip

nohup ./startup.sh &

#It is OK when return as-- nohup: ignoring input and appending output to `nohup.out'

tail -200f /usr/local/unzip_json/logs/log #查看是否报错

Error occurs as below

could not connect to 127.0.0.1:7991

#这里重新打开对应服务

cd /usr/local/thrift-server

chmod +x startup.sh

nohup ./startup.sh &

#然后继续

tail -200f /usr/local/unzip_json/logs/log #没有报错了

 

#本次安装期间,因为linux机中途有关机过,所以thrift-server需要重新打开。

 

#最后把tomcat重启,ifconfig查看到本机IP,假设本机IP为172.16.22.111,则freewifi平台访问地址:http://172.16.22.111:8080/freewifi.

之前说到,我安装期间的linux机中途关机过,所以至此仍不能打开freewifi网址。需要检查把上述所有的服务都开启。

freewifi暂时都是手工来控制启动的,客户机在安装期间有关机过,所以接下来一项一项重启服务如下

ntpd时间服务器

Mongodb服务

Mysql服务

Redis服务

Tomcat服务

thrift-server服务

python服务

tomcat重启

#指令如下,#后yes表示开启了,no没开。

ps -ef |grep ntpd #y

ps -ef |grep mongodb #no

ps -ef |grep mysql #y

ps -ef |grep redis #no

ps -ef |grep tomcat #no

ps -ef |grep thrift-server #no

ps -ef |grep python #yes

 

# 通过kill -9 <PID> 关闭进程,然后再开启他们(开启方法见上述步骤所示)

 

以下是原文后续提示,暂时可以不用管,可能再进一步使用中有用处

1、freewifi平台访问地址:http://172.16.22.111:8080/freewifi 或者 https://172.16.22.111:8089/freewifi 47.88.138.97 https://47.88.138.97:8089/freewifi

2、fileserver http地址: http://172.16.22.111:8080/fileserver https地址:https://172.16.22.111:8089/fileserver https://47.88.138.97:8089/fileserver

3、策略服务器https地址(webapp1中的freewifi.war)https://172.16.22.111:8888/freewifi 端口在server.xml修改

4、unzip的注册端口61503,(端口在配置文件/usr/local/unzip_json/unzip.conf中修改)

 

路由器升级地址cli.conf中的update server 配置为172.16.22.111:8888/freewifi (8888为策略服务器的https端口)

路由器注册地址run.conf中的updateUrl=http://172.16.22.111:61503/freewifi/rese/orderFileUpload.hd (61503为unzip的server_port端口)

You should ask the technicians for support with the default account to login the freewifi website. 

 

posted @ 2017-04-06 10:23  HenryCh  阅读(155)  评论(0编辑  收藏  举报