System environment: Centos 6.5 64-bit
1. Installing the Java environment here is jdk1.7.60
Create a java directory under the /usr/local directory. You can download jdk-7u60-linux-x64.tar.gz from the official website of oracle or the mirror website and put it in /usr/local/java.
cd /usr/local/java, execute decompression: tar zxvf jdk-7u60-linux-x64.tar.gz.
After decompression is completed, configure the JAVA_HOME and JAR_HOME environment variables. Open /etc/profile file, command: vi /etc/profile, add at the end
export JAVA_HOME=/usr/local/java/jdk1.7.0_60
export JRE_HOME=/usr/local/java/jdk1.7.0_60/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$PATH
Press the ESC key, and then enter: wq to save the exit document, enter source /etc/profile to take effect immediately (this method setting is valid for all users at once)
Check whether the installation is successful java -version.
[Note: Modify the ~/.bashrc file (this method is only valid for the current user after modification, and is valid for all shells of the user)
Use vim editor to open the ~/.bashrc file and add the definition of jdk environment variables at the end of the file. If the above method does not work, you can try this method]
2. Install tomcat, here is apache-tomcat-8.0.33.tar.gz
Download tomcat (the binary version is not the source code version) into the /usr/local directory, tar zxvf apache-tomcat-8.0.33.tar.gz, and get the decompressed apache-tomcat-8.0.33
Directory, modify the directory name tomcat.
The memory size can be configured, cd /usr/local/tomcat/bin/, vi catalina.sh, added under line 85:
JAVA_OPTS="-server -Xms800m -Xmx800m -XX:PermSize=64M -XX:MaxNewSize=256m
-XX:MaxPermSize=128m -Djava.awt.headless=true "
Press ESC and then: wq to save and exit.
Start the tomcat server:
#cd /usr/local/tomcat/bin
#./startup.sh
2. Install MySQL
Uninstall the original mysql
Because mysql database is really popular on Linux, the mainstream Linux system versions currently downloaded basically integrate the mysql database. We can check whether the mysql database has been installed on our operating system through the following commands
Copy the code as follows: [root@xiaoluo ~]# rpm -qa | grep mysql // This command will check whether the mysql database has been installed on the operating system, and we will uninstall it through the rpm -e command or rpm -e --nodeps command
Copy the code as follows: [root@xiaoluo ~]# rpm -e mysql // Normal deletion mode
[root@xiaoluo ~]# rpm -e --nodeps mysql // Strong deletion mode. If you use the above command to delete it, it is prompted to have other files that depend on, then use this command to force it to delete it. After deletion, we can use the rpm -qa | grep mysql command to check whether mysql has been uninstalled successfully! !
3. Install mysql through yum
I use yum to install mysql database. First, we can enter the yum list | grep mysql command to view the downloadable version of the mysql database provided on yum:
[root@xiaoluo ~]# yum list | grep mysql
You can get the downloadable version information of the mysql database on the yum server:
Then we can install all mysql mysql-server mysql-devel by entering the yum install -y mysql-server mysql-devel command (note: when installing mysql, we did not install the mysql client, which is equivalent to installing the mysql database. We also need to install the mysql-server server)
[root@xiaoluo ~]# yum install -y mysql-server mysql mysql-deve
After waiting for a while, yum will help us choose the software needed to install the mysql database and some other attached software
We found that installing the mysql database through yum saves a lot of unnecessary trouble. When the following results appear, it means that the mysql database installation has been successful
At this time, we can check the version of mysql-server that has just been installed through the following command
[root@xiaoluo ~]# rpm -qi mysql-server
The mysql-server we installed is not the latest version. If you want to try the latest version, then go to the mysql official website to download the rpm package to install it. At this point, our mysql database has been installed.
4. The initialization and related configuration of mysql database
After installing the mysql database, we will find that there will be an additional mysqld service. This is our database service. We can start our mysql service by entering the service mysqld start command.
Note: If we start mysql service for the first time, the mysql server will first perform initialization configuration, such as:
[root@xiaoluo ~]# service mysqld start Initialize MySQL database: WARNING: The host 'xiaoluo' could not be looked up with resolveip.This probably means that your libc libraries are not 100 % compatible with this binary MySQL version. The MySQL daemon, mysqld, should worknormally with the exception that host name resolving will not work.This means that you should use IP addresses instead of hostnameswhen specifying MySQL privileges !Installing MySQL system tables...OKFilling help tables...OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands:/usr/bin/mysqladmin -u root password 'new-password'/usr/bin/mysqladmin -u root -h xiaoluo password 'new-password'Alternatively you can run:/usr/bin/mysql_secure_installation which will also give you the option of removing the testdatabases and anonymous user created by default. This is strongly recommended for production servers.See the manual for more instructions.You can start the MySQL daemon with:cd /usr ; /usr/bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.plcd /usr/mysql-test ; perl mysql-test-run.plPlease report any problems with the /usr/bin/mysqlbug script! [OK] Mysqld is being started: [OK]
At this time, we will see that after starting the mysql server for the first time, we will prompt a lot of information. The purpose is to initialize the mysql database. When we restart the mysql service again, we will not prompt so much information, such as:
[root@xiaoluo ~]# service mysqld restart stop mysqld: [OK] Starting mysqld: [OK]
When we use mysql database, we must first start the mysqld service. We can use the chkconfig --list | grep mysqld command to check whether the mysql service is automatically started, such as:
[root@xiaoluo ~]# chkconfig --list | grep mysqldmysqld 0: Close 1: Close 2: Close 3: Close 4: Close 5: Close 6: Close
We found that the mysqld service does not start automatically when powering on. Of course, we can set it to boot by using the chkconfig mysqld on command, so that we don't need to start manually every time.
[root@xiaoluo ~]# chkconfig mysqld on[root@xiaoluo ~]# chkconfig --list | grep mysqlmysqld 0: Close 1: Close 2: Enable 3: Enable 4: Enable 5: Enable 6: Close
After the mysql database is installed, there will be only one root administrator account, but the root account does not set a password for it at this time. When the mysql service is started for the first time, some initialization of the database will be carried out. In the output string of information, we see a line of information:
/usr/bin/mysqladmin -u root password 'new-password' // Set password for root account
So we can set a password for our root account through this command (note: this root account is mysql root account, not Linux root account)
[root@xiaoluo ~]# mysqladmin -u root password 'root' // Use this command to set the password to root account as root
At this time, we can log in to our mysql database through the mysql -u root -p command
Five. The main configuration file of mysql database
1./etc/my.cnf This is the main configuration file of mysql
We can check out some information about this file
[root@xiaoluo etc]# ls my.cnf my.cnf[root@xiaoluo etc]# cat my.cnf [mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid
2./var/lib/mysql database file storage location
Our mysql database database files are usually stored in the directory /ver/lib/mysql
[root@xiaoluo ~]# cd /var/lib/mysql/[root@xiaoluo mysql]# ls -l total dosage 20488-rw-rw---. 1 mysql mysql 10485760 April 6 22:01 ibdata1-rw-rw---. 1 mysql mysql 5242880 April 6 22:01 ib_logfile0-rw-rw---. 1 mysql mysql 5242880 April 6 21:59 ib_logfile1drwx----. 2 mysql mysql 4096 April 6 21:59 mysql // These two are the default two database files when the mysql database is installed. srwxrwxrwx. 1 mysql mysql 0 April 6 22:01 mysql.sockdrwx-----. 2 mysql mysql 4096 April 6 21:59 test // These two are the default two database files when the mysql database is installed.
We can create a database ourselves to verify the storage location of the database files
//Create a database of our own: mysql> create database xiaoluo;Query OK, 1 row affected (0.00 sec)[root@xiaoluo mysql]# ls -l total usage 20492-rw-rw---. 1 mysql mysql 10485760 April 6 22:01 ibdata1-rw-rw---. 1 mysql mysql 5242880 April 6 22:01 ib_logfile0-rw-rw---. 1 mysql mysql 5242880 April 6 21:59 ib_logfile1drwx----. 2 mysql mysql 4096 April 6 21:59 mysqlsrwxrwxrwx. 1 mysql mysql 0 April 6 22:01 mysql.sockdrwx-----. 2 mysql mysql 4096 April 6 21:59 testdrwx-----. 2 mysql mysql 4096 April 6 22:15 xiaoluo // This is the xiaoluo database we just created ourselves[root@xiaoluo mysql]# cd xiaoluo/[root@xiaoluo xiaoluo]# lsdb.opt
3./var/log the log output storage location of mysql database
Some log outputs of our mysql database are stored in the /var/log directory
[root@xiaoluoxiaoluo]# cd [root@xiaoluo ~]# cd /var/log[root@xiaoluo log]# lsamanda cron maillog-20130331 spice-vdagent.loganaconda.ifcfg.log cron-20130331 mcelog spooleranaconda.log cups messages spooler-20130331anaconda.program.log dirsrv messages-20130331 sssdanaconda.storage.log dmesg mysqld.log tallyloganaconda.syslog dmesg.old ntpstats tomcat6anaconda.xlog dracut.log piranha wpa_supplicant.loganaconda.yum.log gdm pm-powersave.log wtmpaudit httpd ppp Xorg.0.logboot.log ibacm.log prelink Xorg.0.log.oldbtmp lastlog sa Xorg.1.logbtmp-20130401 libvirt samba Xorg.2.logcluster luci secure Xorg.9.logConsoleKit maillog secure-20130331 yum.log
Among them, mysqld.log file is some log information generated by us operating with mysql database. By viewing the log file, we can obtain a lot of information from it.
Because our mysql database can be accessed through the network, it is not a stand-alone database. The protocol used is the tcp/ip protocol. We all know that the port number bound to the mysql database is 3306, so we can check whether the Linux system is listening to the port number of 3306 through the netstat -anp command:
The result is as shown above. The 3306 port number listened to by Linux system is our mysql database!
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.