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

CentOS 64 bit install mongodb,python, tomcat,etc, to achieve a web platform system. java

在linux機CentOs 64位中安裝FreeWiFi平臺,全部的組件安裝過程大體以下面所示,參考的是安裝步驟txt文檔,在其基礎上結合我的實際在協助國外客戶機安裝時出現的問題進行一些修改和完善。 node

首先準備好一份安裝包。 python

安裝包比較大,能夠經過上傳百度雲,從對方linux機下載 mysql

 

#1、安裝時間服務器 linux

yum install ntp -y c++

ntpdate 0.uk.pool.ntp.org web

vi /etc/ntp.conf redis

#press I to insert sql

 

server 3.cn.pool.ntp.org mongodb

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    

 

2、mongodb安裝配置

cd /usr/local/

wget http://hdwuhan.ddns.info:51492/other/mongodb-linux-x86_64-rhel62-3.2.3.tgz //如域名沒法訪問,請使用hdwuhan.ddns.info

#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://hdwuhan.ddns.info: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

 

#3、mysql安裝運行

wget http://hdwuhan.ddns.info: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://hdwuhan.ddns.info:51492/other/mysql-community.repo

wget http://hdwuhan.ddns.info: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

 

#4、安裝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://hdwuhan.ddns.info: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 &

 

#5、安裝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://hdwuhan.ddns.info: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://hdwuhan.ddns.info: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://hdwuhan.ddns.info:51492/other/freewifi.cer

wget http://hdwuhan.ddns.info:51492/other/freewifi.jks

wget http://hdwuhan.ddns.info: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

 

#6、安裝thrift-server

cd /usr/local

#將安裝包中thrift-server文件夾複製到/usr/local/目錄

cd /usr/local/thrift-server

chmod +x startup.sh

#啓動thrift-server

nohup ./startup.sh &

 

#7、python模塊安裝運行(升級到2.7,若自帶python爲2.7可不升級)輸入python回車,可查看版本

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

cd /usr/local

wget http://hdwuhan.ddns.info: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://hdwuhan.ddns.info: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://hdwuhan.ddns.info: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> 關閉進程,而後再開啓他們(開啓方法見上述步驟所示)

 

如下是原文後續提示,暫時能夠不用管,可能再進一步使用中有用處

一、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

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

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

四、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.

相關文章
相關標籤/搜索