環境:
centos 6.8
memory:1g
mysql 5.7 二進位制安裝包
1.安裝相關的環境包
yum -y install gcc glibc libaio libstdc++ libstdc ncurses-libs
2.檢視系統中是否存在已經安裝的mysql,如果有的話,將其解除安裝掉
rpm -qa | grep mysql
rpm -e mysql #普通刪除模式
rpm -e --nodeps mysql #強力刪除模式
3.建立組和使用者
groupadd mysql
useradd -r -g mysql -s /bin/false myqsl
4.解壓mysql5.7二進位制安裝包
tar -xvf mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz
mv /root/mysql-5.7.15-linux-glibc2.5-x86_64 /usr/local/mysql
5.建立相關目錄
mkdir -p /mydata/data330
chown mysql.mysql /mydata -r
6.修改my.cnf檔案
vi /etc/my.cnf
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
#user = root
#password = rootpwd
[mysqld3306] //這裡最好不要寫其他名稱,開始的時候我加了下劃線,但是命令無法識別
port = 3306
server_id = 3306
basedir =/usr/local/mysql
datadir =/mydata/data3306
socket =/tmp/mysql3306.sock
log-error =/var/log/mysqld_3306.log
pid-file =/mydata/data3306/mysqld3306.pid
[mysqld3307]
port = 3307
server_id = 3307
basedir =/usr/local/mysql
datadir =/mydata/data3307
socket =/tmp/mysql3307.sock
log-error =/var/log/mysqld_3307.log
pid-file =/mydata/data3306/mysqld3307.pid
修改好後儲存退出
7.新增環境變數
echo "path=$path:/usr/local/mysql/bin " >> /etc/profile
source /etc/profile
8.初始化資料庫
bin/mysqld --initialize --user=mysql --datadir=/mydata/data3306 --basedir=/usr/local/mysql --explicit_defaults_for_timestamp
bin/mysqld --initialize --user=mysql --datadir=/mydata/data3307 --basedir=/usr/local/mysql --explicit_defaults_for_timestamp
這裡會提示乙個臨時密碼,一定要記住!!
9.啟動兩個不同埠的mysql
mysqld_multi report 檢視下兩個服務
reporting mysql servers
no groups to be reported (check your gnrs)
這樣輸出的話,就證明/etc/my.cnf檔案配置錯誤了
例項沒有起來
reporting mysql servers
mysql server from group: mysqld3306 is not running
mysql server from group: mysqld3307 is not running
顯示的如上的話,證明例項已經識別了
在執行如下命令開啟例項
mysqld_multi start 3306,3307
再次檢視狀態
mysqld_multi report
mysql server from group: mysqld3306 is running
mysql server from group: mysqld3307 is running
檢視ps aux | grep mysql
netstat -antpl | grep 330
如果有相關的程序,證明啟動成功
10.訪問資料庫
mysql -u root -p -s /tmp/mysql3306.sock //這裡一定要指定sock檔案,否則啟動失敗的
enter password:
mysql -u root -p -s /tmp/mysql3307.sock
enter password:
11.修改root密碼
mysql -u root -p -s /tmp/mysql3307.sock
mysql> alter user 'root'@'localhost' identified by '123456';
mysql> grant all privileges on *.* to root@'192.168.1.%';
mysql> flush privileges;
同樣,登陸到另乙個節點修改密碼
mysql -u root -p -s /tmp/mysql3306.sock
mysql> alter user 'root'@'localhost' identified by '123456';
mysql> grant all privileges on *.* to root@'192.168.1.%';
mysql> flush privileges;
12.關閉某個例項
mysqladmin -uroot -prootpwd -s /tmp/mysql3306.sock shutdown
13.開啟自啟動
echo "/usr/local/mysql/bin/mysqld_multi --defaults-extra-file=/etc/my.cnf start 3306,3307" >> /etc/rc.local
同一臺伺服器上執行兩個tomcat
為了增加某一可能會經常重啟的tomcat的應用,而不影響原來的重要的應用。需要在同乙個伺服器上配置兩個tomcat。而在環境變數中已經加入了catalina home。配置第二個tomcat的方法如下 1.在新路徑下考入tomcat包。2.修改conf server.xml,需要修改三個埠,藍色為需...
兩個網域名稱公用一台伺服器及埠
解決辦法 在tomcat的service.xml檔案新增host hostname www.test01.com unpackwars true autodeploy true xmlvalidation false xmlnamespaceaware false contextpath docba...
一台伺服器搭建部署兩個或多個Redis例項
今天程式那邊說測試服裡面有兩個專案,為了資料不衝突,想一台伺服器搞兩個redis例項,然後自己這邊查詢了一下,確實可以這麼整,只需要區分埠號和區分配置檔案方面就行,原理與nginx和tomcat等新增容器單例項多應用應該差不多,做個筆記記錄一下。1 複製新的配置檔案,改變配置名稱 2 修改配置檔案裡...