It is based on this trend that IBM released its own public cloud products, the product name is IBM Bluemix, is currently in the open testing phase. Bluemix is built on the Apache Open source project Cloud Foundry, and provides the quality service (services) developed by IBM and its partners for use by IT practitioners. This article takes the core component of the Bluemix platform-bluemix Java Runtime as the main line, to introduce the IBM public cloud product Bluemix to the reader, and to share with the reader the change which the platform cloud brings to IT.
This is a familiar legend: Legend, Phoenix is the messenger of the human world, every 500 years, it will be burdened with accumulated in the world of all the unpleasant and hatred, committed to the flames of fire, to the end of life and beauty in exchange for the peace and happiness of the world. After the body undergoes great pain and samsara, they can gain a better body to be reborn. Buddhists call this story "Nirvana".
Indeed, the end of all suffering and sharpening is also where new hopes begin. As an IT practitioner, especially a programmer, have you ever thought about or expected to experience such nirvana? If you have been or are experiencing the following pain, then Bluemix is prepared for you.
constantly install a variety of runtime, containers and cumbersome third party dependencies install and configure all necessary services (databases, mobile services, etc.) to correlate the required services with applications, configure ports/ip/firewalls, and so on to establish dynamic routing and load balancing mechanisms to ensure high availability from bottom to application level Ensure the complete collection and efficient analysis of logs daily need to do a good job in the application of performance monitoring to ensure that the application can be flexible according to the size of the load at last, constantly repeat the development of the "test" on the line of reincarnation
What did Bluemix bring?
Bluemix is committed to addressing the above problems in the software development process and is designed to help programmers develop, test, deploy and implement cloud platform applications faster.
What is Bluemix?
Simply put, Bluemix is an open public cloud platform that allows programmers to run almost any type of application on top of it, without being distracted by other factors such as hardware, software, and networking. As mentioned above, Bluemix is in the middle tier of the cloud world, the PaaS layer. As shown in the following illustration:
Figure 1. The role played by Bluemix
Generally speaking, PaaS refers to a series of software services running on the Iaas layer and provides the server platform or development environment as a service to the user, i.e. "Platform as service". Bluemix runs on IBM's IaaS layer product Softlayer. Softlayer was acquired by IBM in 2013, which mainly provides users with enterprise-class IT infrastructure construction and solutions, whether in terms of performance or security, there is a high quality assurance, interested readers can refer to the end of the article Resources link further study. The user's application can be deployed to the BLUEMIX environment through simple operations (most scenarios require only one simple command), and programmers do not need to care about the underlying operating system, the runtime, the network, etc. everything that has nothing to do with the code itself, And you can put all the energy into the program design and optimization.
Reasons to choose Bluemix
Bluemix as a PaaS layer product gives programmers a lot of advantages: first, save time and effort, programmers can put all their minds on the application of writing and tuning, without worrying about the complex platform infrastructure and facilities, more conducive to explore the creativity of programmers, the development of higher quality, High-performance applications; second, accelerate the application on the line, in the actual operation, only a few simple commands or a few clicks of the UI interface can easily complete the deployment of a variety of applications, without worrying about hardware procurement, software installation, such as the preparatory work; It's easy to meet the needs of applications for new features and new services, IBM and its partners are responsible for delivering quality services, and programmers can add services to their applications simply by "binding" operations; Bluemix supported languages, runtimes, frameworks, etc. are known to programmers, using The Bluemix platform has little need to add new learning costs; Finally, the bluemix-bottom adoption of IaaS is a Softlayer that can provide enterprise-class requirements, and can effectively guarantee the high performance and high security of the platform.
Currently, Bluemix is in the open beta phase, and programmers can easily use the platform cloud services provided by Bluemix simply by registering. In the testing phase, each registered account can obtain 8G of memory space to deploy and run enough applications, including up to 20 cloud services, registered URL is: www.bluemix.net
Bluemix Runtime and Buildpacks
When the program is run in Bluemix, it is provided to the user in the form of buildpacks, and the relationship between the runtime and Buildpack can be understood through the following diagram.
Figure 2. Graphic Buildpack
There are four kinds of bludpacks in Bluemix, respectively, Liberty for Java,node.js,ruby on Rails,ruby Sinatra. If the deployed application is one of the top four languages, then when deploying the application there is no need to specify the corresponding Buildpack, and the platform itself chooses the corresponding buildpack according to the application type of the deployment. In the section at the beginning of this article, we mentioned that Bluemix supports almost all types of applications, so what other types of applications are deployed in addition to the above four applications? The answer is to explicitly specify the type of buildpack needed for the application when deploying the application, some from the community, some from the programmer's own development, because Bluemix is an open cloud platform architecture that allows third parties to make customized extensions based on their standards. The following figure lists the runtime types currently supported by Bluemi.
Figure 3. Runtime (runtimes)
Bluemix Service (services) and functional plug-ins (ONS)
Applications often do not exist alone and require additional additional value to enrich them, and in bluemix these applications are added to the service (services) and functionality Plug-ins (ONS). In Bluemix, the programmers are provided with a variety of services, including: Web and application services, mobile development services, data management services, large data, DevOps services, and so on. Bluemix can enrich applications by adding the appropriate services to the application at minimal cost, either through the command line or through a browser-based UI. During use, users can create instances of multiple services, as well as multiple applications that can use the same service instance at the same time.
The functional plug-in (ONS) can be understood as a special service that provides a higher level of additional functionality for runtime. Users can enrich the running application by choosing whether the application is connected to one or more functional plug-ins according to their own needs. The difference between functional plug-ins and services is that the same space, there can only be a plug-in instance, multiple applications to go along with a function plug-in, in fact, the same plug-in instance, sharing the same service resources.
For services and functional plug-ins, when a service is bound to an application, or when the application is connected to a functional plug-in, the service information about the service and function plug-in is written into a "vcap_services" system environment variable that the user can call in the code System.getenv ("Vcap_services") to obtain specific information, which follows a certain format of the JSON string, such as for a database of services, read the environment variable is mainly the database connection information, Users can obtain and establish a connection to the database in the application.
How to use the Bluemix Java runtime
Bluemix provides a variety of methods for programmers to develop, test applications and eventually run in the Bluemix runtime, this article focuses on the Bluemix Java runtime, and to the reader to introduce the most commonly used methods, the other run-time use of the method and the introduction of this article, the reader can use their own.
Deploying and managing applications using command line tools
Command-line tools are always popular with most programmers, efficient and high-performance, and anything you want to do on Bluemix can be done with command-line tools. For example, these are the most frequent operations we use when dealing with applications.
application deployment, startup, stop, restart and deletion, service creation, binding, and Unbind Operations view and monitor application logs
The command-line tools are also easy to install, please read the reference resource installation command-line tool at the end of the article first. Before using Bluemix, need to register Bluemix account first, visit Www.bluemix.net Register Bluemix account, when these are completed, let us start your platform cloud journey!
When using the command line to deploy Java EE applications to Bluemix, Bluemix supports deployments of three format applications: War,ear and directly uploading a Liberty server to Bluemix. In addition to supporting packaged files in these three formats, it is also supported to extract packaged files into a directory structure and upload and deploy the entire directory structure to the BLUEMIX environment through a command line. We will use a WAR application as an example to explain each step of the operation in detail, the deployment of the other two formats is almost the same as the deployment of the war application, for details please read the reference Resources-deployment Liberty application to Bluemix.
Login Bluemix
Log in to Bluemix using the previously registered username and password to prepare for the deployment application:
First, the "CF API" is used to establish a bluemix connection, and the connection address is https://api.ng.bluemix.net
Listing 1. Connect Bluemix
USAGE:CF API [URL]C:\USERS\IBM_ADMIN>CF API https://api.ng.bluemix.netSetting API endpoint to https:// Api.ng.bluemix.net ... OKAPI endpoint:https://api.ng.bluemix.net (API version:2.2.0) not logged in. Use ' CF login ' to log in.
Second, run "CF login" to login to Bluemix and select the organization and space to work on
Listing 2. Login Bluemix
USAGE:CF Login [-A api_url] [-u USERNAME] [P PASSWORD] [-O ORG] [s SPACE]C:\USERS\IBM_ADMIN>CF loginapi Endpoint:https ://api.ng.bluemix.netusername> xiuleizh@cn.ibm.compassword>authenticating ... Okselect a org (or press ENTER to skip): 1. Xiuleizh@cn.ibm.com2 oe_runtimes_svtorg> 1Targeted org xiuleizh@cn.ibm.comtargeted space Devapi endpoint:https:// Api.ng.bluemix.net (API version:2.2.0) User:xiuleizh@cn.ibm.comorg:xiuleizh@cn.ibm.comspace:dev
Deployment applied to Bluemix
This article provides an example application for everyone to download the deployment, the application is Hellowithmongo.war, which contains a simple servlet and some of the Non-sql database Mongo basic operations, in the Bluemix provided by the database services included in the Mongo database, we use it directly.
Run the CF push command to deploy the application to Bluemix:
Listing 3. Deployment applied to Bluemix
Usage:push a single app (with or without a manifest): CF Push app [-B buildpack_name] [-C COMMAND] [-D DOMAIN] [-F Manifest_path] [-I num_instances] [M MEMORY] [-N HOST] [-P PATH] [-S STACK] [-T TIMEOUT] [--no-hostname] [--no-manifest] [--no-route] [--no-start] C:\USERS\IBM_ADMIN>CF push hellomongodw-p C:\A_Workspace\apps\HelloWithMongo.warCreating app Hellomongodw in org Xiuleizh@cn.ibm.com/space Dev as xiuleizh@cn.ibm.com ... Okusing Route hellomongodw.ng.bluemix.netBinding hellomongodw.ng.bluemix.net to Hellomongodw ... Okuploading Hellomongodw ... Uploading from:c:\a_workspace\apps\hellowithmongo.war53.4k, filesokstarting app Hellomongodw in org Xiuleizh@cn.ibm.com/space Dev as xiuleizh@cn.ibm.com.-----> Downloaded App package (484K) Okbuildpack Version: 20140527-0132-----> Downloading IBM 1.7.0 JRE from http://file.icap.cdl.ibm.com/icapShared/jre/ Ibm-java-jre-7.0-6.0-linux-x86_64-small-footprint-uncompressed-jar-20140116.tar.gz (0.0s) Expanding JRE to. Java ( 1.2S) DowNloading from output/wlp/com.ibm.ws.liberty-2014.4.0.0-201405270132.tar.gz ... (0.0s). Installing archive ... (0.6s).-----> Uploading droplet (93M) 0 of 1 instances running, 1 starting1 of 1 instances Runningapp startedshowing Tiyatien and status for app Hellomongodw in org Xiuleizh@cn.ibm.com/space dev as xiuleizh@cn.ibm.com ... okrequested state:startedinstances:1/1usage:1g x 1 instancesurls:hellomongodw.ng.bluemix.net state since CPU memory Disk#0 running 2014-05-30 06:45:02 PM 0.6% 329.8M of 1G 179.1M of 1G
After successful deployment, you can run the CF apps to view the running status of the application. Here are a few things to note: The first,<app_name> best to be unique, not to repeat with other applications deployed on Bluemix, because by default this <app_name> and domain composition of the access connection applied, that is:< App_name>.ng.bluemix.net, each application of the access connection should be unique, if not unique, the deployment process will be an error to remind us, we just change a different name can; second, the CF push command will push all content under the current directory by default To the cloud, unless we display the specified content to be deployed using the –p parameter; Third, from the above output, you can see that the application access path is "urls:hellomongodw.ng.bluemix.net", namely "http:// Hellomongodw.ng.bluemix.net, which is also the uniform format "Appname.domain" of the access path applied in the default Bluemix.