顯示具有 centos 標籤的文章。 顯示所有文章
顯示具有 centos 標籤的文章。 顯示所有文章

2020-05-28

Centos7 Mysql5.7 安裝

為什麼不用 mysql80 ?
別不信邪,因為很多實驗數據結果顯示,在 < 300 threads 時
效能 mysql5.6 > mysql5.7 > mysql8
不是版本愈高就愈好,而是要選擇適合你的。小型網站或使用者不多的不一定要拿牛刀,MySQL 在Oracle 接管後進步很緩慢,差別真的不大。
但本安裝步驟不分版本,稍改一下版本字元即可通用


如果你只想安裝 mysql,不 care 版本,
1. 安裝前看一下版本
# yum info mysql-community-server
Available Packages
Name        : mysql-community-server
Arch        : x86_64
Version     : 5.6.48
Release     : 2.el7
....
....

2. 安裝
# yum install mysql-community-server



安裝指定版本,這裡是 mysql 5.7

0.檢查 repo source 是否已有 mysql57
# yum repolist enabled | grep "mysql.*-community.*"
!mysql-connectors-community/x86_64 MySQL Connectors Community                153
!mysql-tools-community/x86_64      MySQL Tools Community                     110
!mysql56-community/x86_64          MySQL 5.6 Community Server                530
不符合我們版本


1. 取 mysql community 5.7 版最新安裝檔
毋須指定 release no, architecture independ (例 mysql57-community-release-el7-xx.rpm)
# wget https://repo.mysql.com/mysql57-community-release-el7.noarch.rpm

2. 安裝 (# 提示字 就是 root 身分,你應該知道的)
安裝 mysql5.7 安裝源(repo source)
# yum localinstall mysql57-community-release-el7.rpm

3. 檢查資源狀態
# yum repolist all | grep mysql5
mysql55-community/x86_64            MySQL 5.5 Community Server   disabled
mysql55-community-source            MySQL 5.5 Community Server - disabled
mysql56-community/x86_64            MySQL 5.6 Community Server   enabled:    530
mysql56-community-source            MySQL 5.6 Community Server - disabled
mysql57-community-dmr/x86_64        MySQL 5.7 Community Server D disabled
mysql57-community-dmr-source        MySQL 5.7 Community Server D disabled
enable  的還是 mysql56, 意指目前還是預設指向 mysql56

4. 切換 mysql 安裝來源
關56
# yum-config-manager --disable mysql56-community
開57
# yum-config-manager --enable mysql57-community-dmr
切換完你可以再檢查一下 (可略)
# yum repolist all | grep mysql5 是否已切換了
或第一步驟指令再檢查一下 (可略)
# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64 MySQL Connectors Community                 153
mysql-tools-community/x86_64      MySQL Tools Community                      110
mysql57-community-dmr/x86_64      MySQL 5.7 Community Server Development     424

5. 安裝
# yum install mysql-community-server -y

6. 啟動服務 & 檢查服務狀態
# systemctl start mysqld
# systemctl status mysqld

Active: active (running)


6-1. root 的預設密碼在哪裡?
根據官網給的資訊,預設密碼在 /var/log/mysqld.log ,用以下指令
# sudo grep 'temporary password' /var/log/mysqld.log

# sudo grep 'temporary password' /var/log/mysqld.log

2020-05-28T09:47:04.213709Z 1 [Note] A temporary password is generated for root@localhost: #c3/f5KDwtko


登入試試
# mysql -uroot -p

# mysql -uroot -p

Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.7.30


Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> 

成功!!!

6-2. 變更密碼
在 mysql> 下變更密碼

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('我的新密碼');

Query OK, 0 rows affected, 1 warning (0.00 sec)

下次登入即可使用該密碼

6-3. 開機自動執行
# systemctl enabled mysqld
安裝步驟到此全部完成!!!



7. 追加,安裝附屬套件!!!
安裝 Shared compat libraries for MySQL ,我們程式 compile 所需 lib 及 python mysql connector 需要。
# yum install mysql-community-libs-compat

註:libmysqlclient.so.18、libmysqlclient.so



2020-05-18

無廢話 crontab 設定


[排程]
* 檔案位置
nano /etc/crontab

* 內容格式
# ┌───────────── 分鐘   (0 - 59)
# │ ┌─────────── 小時   (0 - 23)
# │ │ ┌───────── 日     (1 - 31)
# │ │ │ ┌─────── 月     (1 - 12)
# │ │ │ │ ┌───── 星期幾 (0 - 7,0 是週日,6 是週六,7 也是週日)
# │ │ │ │ │
# * * * * *
# 台灣時間半夜3點15分 (系統為格林威治時間)
15 19 * * *  root  /bin/mysqldump -umyname -p密碼 mytest_db | gzip > /aws/share/mysql/mytest_db_auto_bak_`date '+\%Y\%m\%d'`.sql.gz




goofsy 的設定與自動/手動掛載

安裝

$ go get github.com/kahing/goofys
$ go install github.com/kahing/goofys


掛載 AWS S3 bucket 的 package

[goofsy 設定]
在 [HOME]/.aws/ 下有兩個檔案要設,格式如下 (參考 https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html)
1. ~/.aws/credentials
[default]
aws_access_key_id=AKxxxxxxx12345QCQCEE 
aws_secret_access_key=y8lkHqIxxxxxxxzq54dd
2. ~/.aws/config
[default]
region=us-west-2
output=json

3. 手動 mount 指令
$ $GOPATH/bin/goofys <bucket> <mountpoint>
例如
$ $GOPATH/bin/goofys my-s3-bucket /aws/s3

4. 手動 umount 指令
指令記得離開該目錄,然後 umount 該目錄
$ umount /aws/s3

5. copy goofys 至系統目錄(path for all users)以供執行
$ cp ~/go/bin/goofys /usr/bin

6. 掛入 fstab
  * 安裝 fuse (Filesystem in Userspace) 
  $ yum install fuse
  * 位址 /etc/fstab
  * 格式
    goofys#bucket   /mnt/mountpoint        fuse     _netdev,allow_other,--file-mode=0666,--dir-mode=0777    0       0
  * 實例
    goofys#aws-share   /aws/share        fuse     _netdev,allow_other,--file-mode=0666,--dir-mode=0777    0       0
  * 掛載
  $ mount -a

其它注意事項,可參考 https://github.com/kahing/goofys/issues/433#issuecomment-512903339

2015-11-18

當你的 server 有需要換 pem key 的時候要怎麼做呢?

有時候我們會需要換掉 server 上的 pem key, 

當你的 server 有需要換 pem key 的時候要怎麼做呢?



2014-07-31

centos6 下如何安裝 pyenv?

在 centos6 下要如何安裝 pyenv?
 
首先安裝程式開發需要用到的套件
#yum install -y gcc gcc-c++ make git patch openssl-devel zlib-devel readline-devel sqlite-devel bzip2-devel

2014-06-10

Centos6.x 下 Apache2.2 + mod_wsgi + django embedded mode 之安裝設定(無廢話)

前言
Django 要能透過 mod_wsgi 結合 Apache 正常運作首先
1. 你必需要安裝好 Apache
2. 你必需要安裝好 Python, 請參考這篇
3. Apache 必需安裝好 mod_wsgi, 請參考 這篇

安裝 Django
接下來就是安裝 Django, 安裝方法很簡單, 指令如下(這裡我是雙系統, python/pip, python3.3/pip3.3, 請依自己環境使用 pip 或pipx.x)
#pip3.3  install  django


2014-06-05

mod_wsgi 跟 Apache 的 config (無廢話)

若你要安裝 mod_wsgi 請看這篇
若你要設定 mod_wsgi 使其運作則請繼續

環境
Apache2.2
mod_wsgi 4.1.3




httpd.conf 設定
打開 httpd.conf 找到一堆 LoadModule 的地方, 在下方加入以下這行
LoadModule wsgi_module modules/mod_wsgi.so
存檔離開, 重啟 apache
#apachectl restart

若 wsgi 成功運作則你可以在 [apache]/log/error_log 看到以下訊息
 Apache/2.2.15 (Unix) DAV/2 mod_wsgi/4.1.3 Python/3.3.3 configured


在 Centos 下安裝 mod_wsgi (無廢話版)

前言
mod_python 及 mod_wsgi 要安裝哪一個較好?
若你 goo 完資料後答案很明顯, 就是 mod_wsgi. 因為
1. mod_wsgi 效率較好
2. mod_python 最後會淘汰不再更新



2014-04-17

如何在 Centos 6 下安裝 Python3.4

Centos6 內建的 Python 是 2.6.6 版
如果你將內建的 Python upgrade 成 python 2.7 或以上版本, 那麼你將會遇到毀滅性的災難 (在 Ubuntu 內移除 python 也是相同的情況)
這是因為  Centos 6 的 image 內建工具許多都是使用 Python 2.6 來運作, 一旦沒有 python 2.6, Centos 6 連最基本的 yum 都動不了

以下將教你如何安裝 python 3.4 於 Centos6 而不會覆蓋影響到原來的 python2.6.6. 也就是 python 3.4 和 python 2.6 並存於 Centos6  (雖以 python 3.4 為例, 不過其它 python 版本均同 )

2014-02-26

CentOS6 php 無法使用 ftp_connect 的解決辦法

雖然常常遇到,但每每遇到又會忘記,所以在此筆記。

在 Security Enhanced Linux 下,Apache 可能不能如你原來習慣的方式使用。

在 PHP 下,當你遇到連 connect 都會失敗時
<testftp.php>
$conn_id = ftp_connect($ip,$port,$timeout);
if (!$conn_id)
{
    print "FTP connect failed!!";
    exit();
}