CentOS6.5安裝Java、Tomcat、MariaDB10。java
Javanode
要點,先卸載OpenJDK,否則SunJDK不起做用python
1.輸入命令rpm -qa | grep java,會顯示,mysql
javapackages-tools-3.4.1-5.el7.noarch
java-1.7.0-openjdk-headless-1.7.0.51-2.4.5.5.el7.x86_64
java-1.7.0-openjdk-1.7.0.51-2.4.5.5.el7.x86_64
python-javapackages-3.4.1-5.el7.noarch
tzdata-java-2014b-1.el7.noarchlinux
2.輸入命令,sql
rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.51-2.4.5.5.el7.x86_64數據庫
rpm -e --nodeps java-1.7.0-openjdk-1.7.0.51-2.4.5.5.el7.x86_64apache
3.下載「jdk-6u10-linux-x64.bin」放到/home/java目錄下tomcat
4.輸入命令chmod 777 jdk-6u10-linux-x64.binapp
5.輸入命令./jdk-6u10-linux-x64.bin,按照提示,輸入yes
(若是解壓版,tar xvf jdk-7u80-linux-x64.tar.gz)
6.編輯/etc/profile
export JAVA_HOME=/home/java/jdk1.6.0_10
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
7.使配置生效,輸入命令source /etc/profile
8.輸入命令java -version,完成
Tomcat
1.下載「apache-tomcat-6.0.41.tar.gz」,放到/home/tomcat目錄下
2.輸入命令tar -zxvf apache-tomcat-6.0.41.tar.gz
3.進入解壓目錄的bin目錄,輸入命令./startup.sh
4.完成
附設置JVM:編輯catalina.sh第一行添加
JAVA_OPTS="-XX:PermSize=256M -XX:MaxPermSize=512m -XX:MaxNewSize=512m -Xms8000m -Xmx8000m -Dcom.sun.management.jmxremote -XX:+UseConcMarkSweepGC -XX:ParallelGCThreads=4"
(
直接指定jdk,catalina.sh
JAVA_HOME=/apps/svr/jdk1.7.0_80
CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
PATH=$PATH:$JAVA_HOME/bin
)
MariaDB10
要點:必需要建立mysql組、mysql用戶,建立軟鏈接,初始化數據庫,data文件的權限,指定my.cnf。本次的安裝目錄是/home/system
一、輸入命令groupadd mysql //建立用戶組
二、輸入命令useradd -g mysql mysql //建立用戶
三、輸入命令cd /home/system
四、輸入命令tar xfz mariadb-10.0.11-linux-i686.tar.gz //解壓
五、把解壓的文件名改成mariadb
六、輸入命令ln -s mariadb mysql //建立軟鏈接
七、把mariadb/support-files下的my-medium.cnf複製到mariadb目錄下,並改成my.cnf
八、輸入命令./scripts/mysql_install_db --defaults-file=./my.cnf //初始化數據庫
九、輸入命令chown -R root .
十、輸入命令chown -R mysql data
十一、輸入命令./bin/mysqld_safe --defaults-file=./my.cnf //啓動服務
十二、輸入命令./bin/mysqladmin -u root password '123456' //修改root登陸密碼
1三、輸入命令./bin/mysql -u root -p //登陸數據庫
1四、輸入命令./bin/mysqladmin -u root -p shutdown //中止服務
1五、配置環境變量,編輯/etc/profile,添加export PATH=$PATH:/home/system/mysql/bin/
yum安裝
一、yum install MariaDB-server MariaDB-client,
具體yum源,https://downloads.mariadb.org/mariadb/repositories
二、修改/etc/my.cnf
三、初始化mysql_install_db --defaults-file=/etc/my.cnf --datadir=/apps/mysql_data/ --user=mysql
四、命令
mysqladmin -u root password "123456"
mysql -uroot -p
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
/etc/init.d/mysql start
/etc/init.d/mysql stop
/etc/init.d/mysql status
二進制版本安裝
安裝目錄用/apps/db
tar -xvzf mariadb-10.2.8-linux-x86_64.tar.gz,並改成mariadb
cd /apps/db/mariadb
mv /etc/my.cnf /etc/my.cnf.bak
cp support-files/my-small.cnf /etc/my.cnf
修改vi /etc/my.cnf
basedir = /apps/db/mariadb
初次安裝,要建立mysql用戶和組,並給當前目錄賦予權限:
groupadd mysql
useradd -r -g mysql -s /sbin/nologin mysql
chown -R mysql .
chgrp -R mysql .
初始化安裝: ./scripts/mysql_install_db --user=mysql
調整權限:
chown -R root .
chown -R mysql data/
啓動腳本: bin/mysqld_safe --user=mysql &
添加mysql到系統服務目錄: cp support-files/mysql.server /etc/init.d/mysqld
若是是以前安裝過mysql,那麼如今就已經啓動了,第一次安裝須要手動啓動服務: /etc/init.d/mysqld start
添加mysqld到系統服務,隨系統一塊兒啓動: chkconfig mysqld on
查看mysql服務運行狀態: systemctl status mysqld.service
./bin/mysqladmin -u root password '123456'
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
flush privileges;
附:
一、經常使用配置
[client]
default-character-set=utf8
[mysqld]
character_set_server=utf8
collation-server=utf8_general_ci
default-storage-engine=INNODB
innodb_buffer_pool_size = 1000M
innodb_additional_mem_pool_size = 20M
max_allowed_packet = 20M
set-variable=lower_case_table_names=1
二、開啓遠程訪問
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;
flush privileges;
三、指定IP操做關閉
./bin/mysqladmin -u root -h xx.xx.xx.xx -p shutdown
四、清除日誌文件binlog show binary logs; purge binary logs to 'mysql-bin.000028';