Java+mysql Server Environment Build notes

Source: Internet
Author: User
Tags auth bind mysql version zip iptables java web install redis aliyun

One, install upload command

Yum-y Install Lrzsz


Two, install configuration Java(You must have Sun's jdk,openjdk is not possible (OPENJDK payment encryption will be an error), the current version is 1.7)

1, to detect the Java version, if it is openjdk, you want to uninstall off

Yum List installed |grep Java
Yum-y Remove java-1.7.0-openjdk*


2, install if the sun's JDK is not installed.
Download Address: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Or in the Progarm package, find jdk-7u79-linux-x64.tar.gz upload to the server, assuming that the/opt/
Unpack and modify the environment variables:

TAR-ZXVF jdk-7u79-linux-x64.tar.gz
Vi/etc/profile

At the end of the profile file, add the following lines:

Export Java_home= "/opt/jdk1.7.0_79"
Export path= "$PATH: $JAVA _home/bin"
Export Classpath= ".: $JAVA _home/lib"

Keep in mind that during the above add process, do not add a space on either side of the equal sign, otherwise "not valid identifier" will appear, because the source/etc/profile is not recognized as redundant to the space, will be understood as part of the path.
Then save and detect if Java is installed successfully

Source/etc/profile
Java-version


Third, install the configuration MySQL
1, to see if CentOS has been installed with MySQL.

Yum List Installed | grep MySQL

2, uninstall installed MySQL, if there are multiple dependencies, then uninstall, when the results are displayed as complete! That is, uninstall is complete.

Yum-y Remove mysql-libs.x86_64

#若要完全清空数据, you want to delete the data directory

rm-rf/var/lib/mysql/

3, view the MySQL version information on the Yum Library (the CentOS system requires a normal network connection).

Yum List | grep MySQL
#或
Yum-y List mysql*

4, use Yum to install the MySQL database, when the result is displayed as "complete! "The installation is complete."

Yum-y install mysql-server MySQL mysql-devel

5, view the installed version

Rpm-qi Mysql-server

6, start MySQL, shut down, restart MySQL

Service mysqld Start
Service Mysqld Stop
Service mysqld Restart

7, configure Root/cookie remote Connection account

Mysql>create USER ' root ' @ '% ' identified by ' Cookie ';
Mysql>grant all privileges in *.* to ' root ' @ '% ' identified by ' cookies ' with GRANT OPTION;
Mysql>flush privileges;

8, if the Telnet database server's 3306 ports do not make sense, modify the firewall configuration


Vi/etc/sysconfig/iptables

#添加一行
-A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT

#保存后, restart iptables;
Service Iptables Restart


9, if you still can't connect remotely, you can see the MySQL boot binding address (if you want to modify the port, also here to modify):

Vi/etc/my.cnf

#修改绑定地址为0.0.0.0, restart the database
bind-address=0.0.0.0

10, Import data

Four, installation configuration zookeeper

1, find zookeeper.tar.gz in the program package, upload to/opt/, and unzip

TAR-ZXVF zookeeper.tar.gz

2, go into the Zookeeper directory and start the zookeeper

CD Zookeeper
SH bin/zkserver.sh start

3, view zookeeper status, and several other common operation commands


#启动ZK服务:
SH bin/zkserver.sh start

#查看ZK服务状态:
SH bin/zkserver.sh status

#停止ZK服务:
SH bin/zkserver.sh stop

#重启ZK服务:
SH bin/zkserver.sh restart

#客户端联接:
SH bin/zkcli.sh-server 127.0.0.1:2181

#客户端联接之后, use the following command to see the zookeeper directory
LS/



Five, installation configuration Dubboadmin

1, upload dubboadmin.zip to/home/directory, and Unzip

#解压
Unzip Dubboadmin.zip

2, Start dubboadmin

#进入dubboadmin目录并启动
Cd/home/dubboadmin
SH bin/startup.sh

3, go backstage.

#在浏览器里输入, the first time to enter the prompt to enter the account password (root/root)
Http://192.168.1.99:9999/governance/providers


Six, installation configuration Redis


1, because CentOS does not have Redis repository, first we download the third party Fedora repository:

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

RPM-IVH epel-release-6-8.noarch.rpm

2, installation


#安装
Yum Install Redis

#查看redis安装项
Find/-name *redis*

#启动redis服务
Redis-server/etc/redis.conf


3, login Redis, add password (' Redis 127.0.0.1:6379> ' after the input part)


#redis客户端联接
Redis-cli

#redis登陆后, view all configurations
Redis 127.0.0.1:6379> Config Get *

#设置密码为cookie
Redis 127.0.0.1:6379> config set Requirepass cookie

#验证密码
Redis 127.0.0.1:6379> Auth Cookies



Seven, installation configuration MONGO

1, check the system Yum source is MONGO related resources, if not, to add related yum source configuration


#检查是否有mongo源
Yum Info Mongo-10gen

#如果提示没有匹配的源的话, you will manually add the
Vi/etc/yum.repos.d/10gen.repo

#添加如下配置, and save
#64-bit System Add
[10gen]
Name=10gen Repository
Baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
Gpgcheck=0

#32-bit System Add
[10gen]
Name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686
Gpgcheck=0

#查看系统位数
Uname-a


2, install MONGO

#安装mongo服务器端
Yum-y Install Mongo-10gen-server

#安装mongo客户端
Yum-y Install Mongo-10gen

3, configure and start the MONGO service


#修改绑定地址, modify bind_ip=127.0.0.1 to bind_ip=0.0.0.0
Vi/etc/mongod.conf

#启动mongo服务
/usr/bin/mongod-f/etc/mongod.conf

#检查mongo服务
/etc/init.d/mongod
/etc/init.d/mongod status


4, add accounts and libraries


#登陆mongo
Mongo

#显示当前库
> show databases;

#创建location库
> Use location

#添加帐号
> Db.adduser ("Root", "cookie")

#登陆验证
> Db.auth (' Root ', ' cookie ')


Eight, installation configuration ROCKETMQ

1, upload alibaba-rocketmq.tar.gz to/opt/, and unzip

TAR-ZXVF alibaba-rocketmq.tar.gz

2, Start ROCKETMQ


#进入到rocketmq的bin目录
Cd/opt/alibaba-rocketmq/bin

#后台启动namesrv
Nohup./mqnamesrv >/var/log/ns.log &

#启动namesrv的时候报了一个错: caused by:java.net.UnknownHostException:test:Name or service not known
The hostname=test is defined in the #这是由于在/etc/sysconfig/network, but there is no address to test in/etc/hosts, and adding test to/etc/hosts after 127.0.0.1
Vi/etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 test

#后台启动mqborker, you need to bind the NAMESRV_ADDR address first
Export namesrv_addr=192.168.1.99:9876
Nohup./mqbroker >/var/log/mq.log &

#查看namesrv启动是否成功 (Successfully printed: The Name Server boot success.)
Tail-f/var/log/ns.log

#查看mqborker启动是否成功 (Successfully printed: The Broker[test, 192.168.1.99:10911] boot success. and name server is 192.168.1.99:9876)
Tail-f/var/log/mq.log


Nine, configuring Tomcat for each service

1, find Tomcat.zip and cookie.sh in program, upload to/home/directory
2, install Tomcat for each service, and perform various operations


#安装所有服务
SH cookie.sh Install

#安装单个服务, like pay.
SH cookie.sh Install pay

#启动所有服务
SH cookie.sh start

#启动单个服务, like pay.
SH cookie.sh start pay

#关闭所有服务
SH cookie.sh stop

#关闭单个服务, like pay.
SH cookie.sh Stop pay


10, the production environment, the department needs to optimize matters

1,mysql modify default port, account password encryption
2,mongo modify default port, account password increase strength
3,redis modify default port, account password increase strength
4,ROCKETMQ Modify Default port
5,redis,mongo,rocketmq,zookeeper Cluster Department



quickly build Javaweb environment on Aliyun server Jdktomcatmysql

Aliyun Forum There are many wonderful tutorials, but the building of the Web environment is mostly PHP environment, the younger brother as a Java rookie, have time to write a little JSP program, but in the Linux environment to build a Java Web environment is indeed the first time, really experienced bumpy ah ~~~~~ finished, Write a simple tutorial to help friends who want to use Java Web projects on Aliyun servers.


First of all, praise the Aliyun service, operating system installation, reset, and many important functions can be a key to complete, there is no understanding of the place to send mail to customer service, the answer is very detailed, so we do not have to worry about what operation to be stumped.


Here is the server configuration I purchased:


My site is about 2000IP per day, 10,000 pages of traffic (very small station, let everyone joke), with this configuration more than enough ~ ~
URL: http://www.wowtools.org, we can go to experience the speed, very smooth. (PS: This is a World of Warcraft pet-related sites, like to play games friends to join the favorites Oh ~ ~)


Well, let's start with our theme: quickly build a Java Web environment (JDK Tomcat MySQL)

First you have to install SSH on your computer and learn to use it (there are many good SSH video tutorials in the forum, and it takes a few minutes to look at it).

1, (optional operation) installation operation panel Vpsmate
First, it is recommended to install an operator panel with Liunx's friends, the benefits are two: 1, many commands can be in the Web interface point mouse on the implementation; 2, when you go out, the server suddenly problems, you may not find the installation of SSH machine, at this time, using the panel simple operation, Not really. Restart the service directly through the panel.

Speaking of panels, here to recommend Vpsmate, this is the champion of the Aliyun Developer contest, the use of natural is very suitable for Aliyun server. It can easily install, uninstall, monitor a lot of software on the server, and occupy little memory, not used when almost no memory, use up to only about 20m. Installation process is very simple, refer to the Vpsmate official website of this tutorial bar: Http://www.vpsmate.org/install


2. Install MySQL Database
Database should be a necessary software in Web applications, of course, you can choose to install Oracle and the like, the operation is very similar.
If you do not choose the first step of the operation, please refer to this post to complete the installation of MySQL: http://www.blogjava.net/amigoxie/archive/2013/02/22/395605.html


If you complete the first step, you can login to your vpsmate panel, and then click Service Management--> database service-->mysql Installation Services, can be a key to complete the installation operation.
There may be some software packages that could not be found during the installation, and the error "Software source IUS installation failed!" "You can follow this post to solve this problem according to your own operating system version: http://www.mirrtalk.net/?p=472

3. Installation Jdk/jre
In fact, the installation of the JRE should be enough, but I prefer to toss the server, in the future may be on this server to do something else, so directly installed the JDK.
Two commands can be completed:

wget http://download.oracle.com/otn-pub/java/jdk/7u40-b43/jdk-7u40-linux-x64.rpm? Authparam=1380464207_43e07da0c7f873c59a3441c9966cb8e9
RPM-IVH *.rpm


After installation to set up the environment variables in the/etc/profile to add the following content (you can use VI to edit profile, you can download and then upload the edit):


Java_home=/usr/java/jdk1.7.0_40
Classpath= $JAVA _home/lib: $JAVA _home/jre/lib
Path= $PATH: $JAVA _home/bin: $JAVA _home/jre/bin
Export PATH CLASSPATH Java_home


4. Install Tomcat
The same is done with two commands:

wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-7/v7.0.42/bin/apache-tomcat-7.0.42.tar.gz
TAR-ZXVF apa*


When you're done, copy the Tomcat folder to a location you like, like I'd put it under/usr/local:
Cp-r tomcat/usr/local




------------------------------------------------------


At this point, the Java Web environment is built to complete ~ ~ ~, upload your Web project to the WebApp folder, and then run the bin directory./startup.sh, you can visit your website.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.